-
Notifications
You must be signed in to change notification settings - Fork 355
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
Doesn't work in Web Worker: Error: Illegal invocation
#621
Comments
This is happens when any importer is added. Executing this code on the main thread (using just require) works fine. Reproduction: https://github.com/mischnic/sass-worker-importer (error in console) /* index.js */
// this works
require("./worker.js");
// this doesn't
const worker = new Worker("./worker.js");
worker.onerror = console.error; /* worker.js */
self.Buffer = require("buffer").Buffer;
const sass = require("sass");
const data = `$colorRed: red;
#header {
color: $colorRed;
}`;
function run() {
return sass.renderSync({
data,
importer: [
(url, prev, done) => {
return { file: url };
}
]
});
}
console.log(run().css.toString("utf8")); |
This is a great question for the Sass StackOverflow community! We try to keep this issue tracker focused on bugs and feature requests that need the core team's attention in particular, while requests for support are usually better handled by the community at large. |
For future reference (mostly so I can find it later myself): |
This is actually an issue. The illegal invocation occurs inside Primitives_currentUri: function Primitives_currentUri() {
if (!!self.location) return self.location.href;
return;
}, When we call var dartNodePreambleSelf = typeof global !== "undefined" ? global : window;
var self = Object.create(dartNodePreambleSelf); So the actual value of I'm not sure what the purpose of creating a new object from var dartNodePreambleSelf = typeof global !== "undefined" ? global : window;
var self = dartNodePreambleSelf; Although, now I'm getting errors about
Thanks |
Yes, that all correct. But that prelude is inserted by the dart compiler which in turn includes it from another package. This is the correct issue for this: mbullington/node_preamble.dart#14 |
@mischnic I was just going to edit my post to say:
Thanks! |
It was already noted that running in the browser isn't officially supported (#25), but maybe someone can give me hints on how to debug this (very hard without sourcemaps for the Dart code).
The text was updated successfully, but these errors were encountered: