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
[Web Extension Transformer] doesn't support code splitting #5859
Comments
Because of the sync nature of the suggested solution, I wish there was a way to require code-splitted files synchronously (a-la- |
Well there are two ways to achieve codesplitting:
The problem with shared bundles is #4227 (for the case of simply running |
Yeah that’d be ideal, but:
Yes 🙌, I think that’s what I suggested above. |
The main thing the prevents shared bundles is
But I think there was some problem if it's set to false. |
The problem was the removal of the prelude from all descendants of the manifest when another descendant had received the prelude. Normally this is fine because they all share the same global environment, but in this case that doesn't happen. If that can be circumvented, |
(That would also be needed for #5865) |
This comment has been minimized.
This comment has been minimized.
I have news that would make this much easier to implement: almost-raw https://bugzilla.mozilla.org/show_bug.cgi?id=1536094 import(chrome.runtime.getURL('file.js')).then(mod => {console.log(mod.default)}) // manifest.json
{
"web_accessible_resources": ["file.js"]
} This works in Parcel today because the dynamic What's next for full code-spltting support:
Example input// entry-a.js
import('left-pad').then(alert) // entry-b.js
import('left-pad').then(console.log) Desired output// entry-a.js
import(chrome.runtime.getURL('left-pad.8f8a6d.js')).then(alert) // entry-b.js
import(chrome.runtime.getURL('left-pad.8f8a6d.js')).then(console.log) // left-pad.8f8a6d.js
export default (str, n) => str.padStart(n) // manifest.json
{
"web_accessible_resources": ["left-pad.8f8a6d.js"]
} |
I think #7050 unintentionally fixed this but someone should verify. |
Yep this should be fixed in the latest versions but if anyone uses dynamic import more extensively, please test it out and report back here. |
I'm trying to do what @fregante is doing, but it's failing because Parcel always seems to rewrite |
If that's the case, it means this was not fixed, as my last comment specifically suggested that Can we reopen this issue? @101arrowz |
I'm experiencing the exact same issue, is there some way to make parcel not rewrite the import? Something like webpacks |
It's probably best to create a new issue with updated repro. |
🙋 feature request
Code splitting via
import()
creates ascript
tag and injects it (Parcel source) but this doesn't work for "content scripts" in extensions because suchscript
tags are not run in the extension’s isolated world. Injecting ascript
tag is actually a way to explicitly escape the isolated world😯 Current Behavior
The code-splitted file doesn't have access to the
chrome.*
APIs like the rest of theentry.js
file does because it's injected viascript
tag directly in the page rather than being loaded as a content script.💁 Possible Solution
I'm not aware of a way to load script from a content script in the same world (only non-content scripts pages can use the
chrome.tabs.executeScript
API to do that) so I think the only solution would be to:dist/manifest.json
, before the entry, e.g."content_scripts": [{ "scripts": [ + "vendor.d186d19.js", "entry.js" ] }]
import()
is called.🔦 Context
I'm considering content-splitting to avoid bundling the same dependency over and over. In this PR the files are all 30KB+ because they all bundle their own version of a library:
but with
import()
I'd get this:The text was updated successfully, but these errors were encountered: