-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Uri.base is broken on Node.js #27979
Comments
One possible way to do this would be to have |
This is causing real-world breakages for Angular users in the wild (see sass/dart-sass#734). Can it be prioritized? |
This is also appears to be the cause of an odd SSR issue when working with Vue CLI 3 single-file components. In my use case, also trying to compile SCSS directly from components via webpack and the Returns the following:
It's been really difficult finding help on this issue, and would love to get more info 🙂 |
I've also faced issues with SSR. Managed to duct-tape it with with this code in our global.location= {
href: "file://"+process.cwd()+"/"
}; |
@molszanski Be aware that file paths are not substitutable for |
@nex3 Thank you Natalie for the heads up! I've read your comments and warnings. Appreciate them a lot! Luckily I can get away with this hack for now. But this will come back and bite me one day. |
This breaks even more badly when the Node.js environment is using jsdom, which is common in test environments. jsdom configures Once again, this is affecting real-world users. Can we please prioritize this issue? |
I've stumbled across this bug yesterday, it is fun to learn that the problem is known for 6 years, and it is not patched yet 😀 Many thanks for suggesting to set As it is mentioned above that the following is fragile global.location = {
href: `file://${process.cwd()}/`,
}; I decided to mention here that this variation might be more bulletproof, at my first glance: const { sep } = require('path');
const { pathToFileURL } = require('url');
global.location = {
href: `${pathToFileURL(process.cwd()).href}${sep}`,
}; |
Currently
Uri.base
doesn't work in many situations when compiled Dart code is run on Node.js. It usesglobal.location
, which is undefined in Node.js. The preamble tries to work around this by shoving a path into afile:
URL, but this is invalid in general. It breaks in all cases on Windows, and will break on POSIX systems if the path contains characters that need to be percent-escaped.This is an issue for both DDC and dart2js.
The text was updated successfully, but these errors were encountered: