ember-fastboot / ember-fastboot/ember-cli-fastboot

Fastboot incompatible with modern state of the ecosystem

Open
#913 3 comments 1 reaction 0 assignees View on GitHub
Dominant language
JavaScript
Stars
850
Forks
161
Avg merge
17h 45m
Merged PRs (30d)
19

Description

Issues:

- Expected globals are not present, such as `fetch`, `Headers` `ReadableStream` etc.
- ~`buildSandboxGlobal` no longer runs, so there is no way to enhance the built in globals with WHATWG spec implementations of APIs such as `AbortController` and `fetch` even when these things exist as globals in node.~ (this turned out to be a config mishap for ember-cli-fastboot-testing see https://github.com/embermap/ember-cli-fastboot-testing/issues/488)
- `fastbootDependencies` does not allow whitelisting local dependencies, which prevents applications from addressing this shortcoming short of using `pnpm patch` to splice in new globals. For instance the following fails to resolve with `Fastboot.require`

```json
{
"dependencies": {
"fastboot-abort-controller": "file:./fastboot-overrides/abort-controller"
},
"fastbootDependencies": [
"fastboot-abort-controller",
]
}
```

Example recommended config for use with EmberData and fetch

```js
/* global ReadableStream, WritableStream, TransformStream */
module.exports = function (environment) {
return {
buildSandboxGlobals(defaultGlobals) {
return Object.assign({}, defaultGlobals, {
AbortController,
fetch: fetch,
ReadableStream:
typeof ReadableStream !== 'undefined' ? ReadableStream : require('node:stream/web').ReadableStream,
WritableStream:
typeof WritableStream !== 'undefined' ? WritableStream : require('node:stream/web').WritableStream,
TransformStream:
typeof TransformStream !== 'undefined' ? TransformStream : require('node:stream/web').TransformStream,
Headers: typeof Headers !== 'undefined' ? Headers : undefined,
});
},
};
};

```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.