-
-
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
Fix SW packaging in web extensions #8424
Conversation
@olistic how would we implement real module support when it comes to importing code into background sw? Or is that not necessary since parcel would be the "bundler" anyhow :-?... Just thinking outloud, since this PR is more of a hack to get over real-import and bundle them all into the output file (instead of using importScript/proper module import (?)) |
Right now it's not necessary since Parcel is bundling the SW code anyhow, and since it leaves the |
Yeah, so the way to actually fix that is to fix the js transformer to output service worker module... tbh I'm not sure how useful it will be, since bgsw are loaded in the background anyhow. BTW, thanks for the patch - I incorporated it into my fork of this packager. (used in plasmo: https://github.com/PlasmoHQ/plasmo/) |
@devongovett Thanks for merging. Any idea when this will be released? |
Working on testing and preparing a release soon (next few weeks hopefully). In the meantime, you could try out the nightly releases. |
↪️ Pull Request
This PR fixes the packaging of Service Workers using ES Modules in the
webextension
config.The JS transform does not support ES Modules for service workers:
parcel/packages/transformers/js/src/JSTransformer.js
Lines 575 to 577 in 3329469
Instead, it sets
outputFormat
toglobal
(docs). For that reason, thetype=module
is removed when packaging the extension.Related issue: #1747.
🚨 Test instructions
Here's a repo in which builds fail with
2.7.0
but pass with this PR:https://github.com/olistic/parcel-webextension-repro
✔️ PR Todo