-
Notifications
You must be signed in to change notification settings - Fork 159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
In fastboot sandbox the URL
global object is not WHATWG URL
#816
Comments
Ya, this is a pretty annoying bug. Thanks for reporting! We need to figure out if this will be a breaking change though 🤔 |
Maybe pass |
just ran into this with |
I tried creating
|
@burritoIand Check your version of ember-cli-fastboot. const { URL } = require('url');
module.exports = function(environment) {
return {
sandboxGlobals: { URL }
};
}; |
@nag5000 thank you for the suggestion, I indeed am on 2.2.2
|
Caused by actually broken FastBoot, messing up with the `URL` global: ember-fastboot/ember-cli-fastboot#816
Just tripped over this. In an addon, where I cannot influence the sandbox globals, I had to revert to this ugly check: const URLConstructor: typeof URL =
typeof URL === 'function' ? URL : (URL as { URL: typeof URL }).URL; Would be nice to get this fixed in a stable v3!?
If we want to keep compatibility with the {
Url: [Function: Url],
parse: [Function: urlParse],
resolve: [Function: urlResolve],
resolveObject: [Function: urlResolveObject],
format: [Function: urlFormat],
URL: [class URL],
URLSearchParams: [class URLSearchParams],
domainToASCII: [Function: domainToASCII],
domainToUnicode: [Function: domainToUnicode],
pathToFileURL: [Function: pathToFileURL],
fileURLToPath: [Function: fileURLToPath]
} Doable, but also kinda ugly. |
@simonihmig I've been struggling trying to get this to work in my app, even when using sandbox globals as below:
My app code looks like:
edit 1I got the above to work when using the latest 3.X beta version of this library edit 2Testing using ember-cli-fastboot-testing fails despite identical configuration (different lib but somewhat related so leaving here)
|
Bumping my version of ember-source to 3.22 solved this issue for me. The code throwing the exception is not gone, no other changes needed. |
we are dropping official support for fastboot from ember-data's test suite due to this issue as you cannot remove ember-fetch (not compatible with embroider-optimized / ember/ember-data 5.0) and also use ember-data due to the inability to use or expose globals like AbortController. |
Since Node.js 10 the
URL
is available as global variable, and it is WHATWG URL API - "Browser-compatible URL class, implemented by following the WHATWG URL Standard".But under fastboot I can not use
new URL(...)
, because sandbox globals assignsURL
torequire('url')
.ember-cli-fastboot/packages/fastboot/src/sandbox.js
Lines 17 to 26 in 9e0b053
It's very confusing because:
globalThis.URL === require('url').URL
new URL(...)
in app that will be valid for both environments - browser and fastboot.Instead, I have to write like this
IS_FASTBOOT ? new URL.URL(...) : new URL(...)
or usebuildSandboxGlobals
to assignURL
torequire('url').URL
instead of defaultrequire('url')
.In my opinion, the
URL
global variable in fastboot should be the same as for Node.js:Also, it make sense because support of Node < 10 has been dropped here (#695).
The text was updated successfully, but these errors were encountered: