-
Notifications
You must be signed in to change notification settings - Fork 56
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
Consider approach to allow importmap #725
Comments
It certainly cannot be avoided in a published version as the users won't have node_modules, so I guess you mean the development version? In that case I guess the goal here is performance, but it's unclear why it is a concern as modern bundlers don't rebuild nonmodified dependencies, i.e. there'll be no gain normally, assuming you use DLL or split chunks for node_modules in your bundler (webpack can do it). |
In the mentioned setup, I'd just upload the node_modules to the extension store. |
I still don't see how it's better than a standard split-chunk build. Assuming you mean copying node_modules into the uploaded zip, it seems worse than building it because node_modules often contains a whole lot of extraneous stuff such as different versions of the build. |
You can use import maps in a background pages in Firefox and Safari. But since import maps can't be used in a service worker, this likely can't be done until that is resolved. |
In today's meeting (meeting notes at https://github.com/w3c/webextensions/blob/main/_minutes/2024-11-21-wecg.md), I mentioned that extension pages and background pages can embed import maps. This is wrong, because I briefly forgot that import maps require a CSP nonce to be declared. Nevertheless I am supportive of supporting import maps as a capability, but that it requires work on the web platform before we can consider it for extensions. Notably, service workers do not support import maps yet, and content scripts do not have first-class module support. In Firefox there is a bug that requests support for import maps in content scripts, at https://bugzilla.mozilla.org/show_bug.cgi?id=1765275 |
Import maps aren't currently possible within extensions as they require a nonce within a strict CSP environment.
This makes extension authors have to bundle their JS dependencies from node_modules which could be avoided.
Where the following script isn't possible:
Potential solutions:
Allowing a static keyword to be permitted to specify a nonce
After loading file content for HTML / JavaScript the browser could choose to inject in a nonce for that pageload.
HTML example:
JavaScript example:
Positives
Negatives
Relax the policy of import map specifically for extensions
Consider relaxing the import map CSP policy to permit HTML parsed policies.
Positives
Negatives
Allow specifying an import map file via the manifest.json
Positives
Negatives
The text was updated successfully, but these errors were encountered: