-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
"import() is not allowed in service workers." #10025
Comments
The caniuse page you linked to is for the According to MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import
Given that the spec issue you linked to is still open, I guess this is still the case? |
Actually you can see this in the current spec: https://html.spec.whatwg.org/multipage/webappapis.html#hostloadimportedmodule
So, it throws when dynamic import is called in worklets or service workers. |
Indeed I was fooled into thinking it worked due to this Webpack plugin which transpiles Do you reckon that the same solution could be implemented here? |
🐛 bug report
import()
presumably works in some browsers:but Parcel throws an error before even trying:
parcel/packages/transformers/js/src/JSTransformer.js
Lines 778 to 785 in 4d27ec8
🎛 Configuration (.babelrc, package.json, cli command)
🤔 Expected Behavior
Parcel should create the bundle and leave the
import()
statement in there.😯 Current Behavior
💁 Possible Solution
I think it should drop the error entirely, it's not Parcel's responsibility to pre-validated code, the same way it allows the non-existent
window.restartOperatingSystem()
to be called. Making things impossible regularly makes it difficult to use Parcel.At the very least make it a warning or make it silenceable.
🔦 Context
I want to load a script on demand in background workers
💻 Code Sample
I don’t think this is related to web extensions, but here it is:
🌍 Your Environment
The text was updated successfully, but these errors were encountered: