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
webextensionconfig.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
outputFormattoglobal(docs). For that reason, thetype=moduleis removed when packaging the extension.Related issue: #1747.
🚨 Test instructions
Here's a repo in which builds fail with
2.7.0but pass with this PR:https://github.com/olistic/parcel-webextension-repro
✔️ PR Todo