-
-
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
Parcel WebExtension fails to bundle modules under some conditions (build + mv2, or mv3 & --no-scope-hoist) #8071
Comments
|
I have the same problem (at least it looks like it) and did some digging. Turns out the WebExtensionPackager is not compatile wit the code-splitting feature. If bundles get split off, it does not add the split-off bundles to the manifest. From what it looks like it only does a naive find-and-replace. I have a simple workaround here: https://github.com/Kjoep/parcel/tree/prevent_losing_webextension_deps (use it for config-webextension). This turns off the code-splitting for web extensions. |
I think it's the same issue, yeah. Looking at my broken builds - I get split bundles, and only one of the scripts makes it to manifest. Also it seems that parcel is trying to reuse the code between background and content, which doesn't work. |
Is there a way to disable code-splitting without forking parcel? 😛 |
Getting the same issue here as @Stvad. Seems like web extension production build is not robust (it works well in I followed the changes from @Kjoep and simply added this to
Command: Without no content hash, I get this error: |
If someone could provide a minimal reproduction that would be helpful, otherwise I'll try to make one in the next few weeks. |
@101arrowz here's my reproduction: https://github.com/lukaw3d/reproduce-parcel-webextension-codesplitting-broken
background page throws |
Thanks, I've reproduced the issue and am working on fixing it now. |
To be fair, the codesplitting does not seem very important for webextensions, as they are loaded locally, not over the network. It might be acceptable to automatically turn the feature off. |
Individual files have to be smaller than 4MB when publishing Firefox extensions: |
I'd say PREFERABLE |
@101arrowz Thank so much for starting work on the issue! |
I haven't been able to properly look at this. For now we should probably just document the issue and add the code-splitting removal fix into the docs. |
@101arrowz Thank you for replying, great, that's something! Can you please share here for now how to remove code-splitting? |
This comment seems to work: #8071 (comment) |
@101arrowz
I still get only 1 file: |
This started happening to us when we moved from 2.4.1 to 2.7.0. |
@calclavia's solution above fixed this for me in parcel v2.7.0. I did not also need to use |
When parcel bundles the extension not all modules are correctly included. For more information see parcel-bundler/parcel#8071.
When parcel bundles the extension not all modules are correctly included. For more information see parcel-bundler/parcel#8071.
probably not stale |
Yep, not stale.
…On 3/27/2023 10:35 AM, Vlad Sitalo wrote:
probably not stale
—
Reply to this email directly, view it on GitHub
<#8071 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABQWBM7VQKVPMRMRHZX4QODW6EN2TANCNFSM5VMUSVXA>.
You are receiving this because you commented.Message ID:
***@***.***>
|
Possibly fixed by #9068 - can someone please test? I encountered a variant of this issue locally and my changes in that PR fixed it. |
@101arrowz I tried the repro in #8071 (comment) and this appears to have been fixed 2.6.0
2.10.0
The output is not ideal because it generates two heavy popup.js files, but that's attributable to the module/no-module variants, which I think should just be disabled in extensions if possible. |
Thanks for verifying! Let's close this if the bundling failure is fixed; the module/nomodule behavior change can be handled in a separate issue. |
🐛 bug report
Under some conditions/configurations Parcel fails to package dependecies into bundles and fails in runtime.
Here is a set of conditions and results I've discovered so far (see configs below for price command definitions)
watch
mode (https://gist.github.com/Stvad/e441997e880a47026772cd6872501d2a#file-background-mv2-watch-js)--no-scope-hoist
produces working build (https://gist.github.com/Stvad/e441997e880a47026772cd6872501d2a#file-background-mv3-scope-hoist-js)--no-scope-hoist
seems to produce a working backrgound script, but not content scriptscope-hoist-js
--no-content-hash
from the build commands - I start hitting Error: Cannot read property 'hashReferences' of undefined #4145🎛 Configuration (.babelrc, package.json, cli command)
.parcelrc
package.json
parts🤔 Expected Behavior
When I run either of the build commands above - all the dependencies are bundled
😯 Current Behavior
Some (all?) dependencies are missing from the bundle and the extension fails at load time with the error like:
🔦 Context
Building https://github.com/transclude-me/extension
I've noticed this problem after migrating to Parcel 2.5.0 from 2.3.2. One noteable change that accompanied that is having to use 2 manifests so both FF and Chrome can be supported. So my directory stracture is as follows now
And code in manifest points to files up level (e.g.
"service_worker": "../background.ts",
).I've tried reverting to
src/manifest.json
structure in case this was relevant, but it didn't make the difference.I've also tried adding the following in
package.json
, in case it got reset somehow, it didn't make any difference:💻 Code Sample
transclude-me/extension@78b529e I discovered issue after this commit
🌍 Your Environment
The text was updated successfully, but these errors were encountered: