-
Notifications
You must be signed in to change notification settings - Fork 29
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
Add a check on app block for preventing importmap #647
Comments
@yoavweiss I vaguely recall having us having a discussion about this. Did this change after all? |
Multiple import maps are shipping in Chromium 133, which will reach Chrome stable in early February. At the same time, I haven't started the WebKit implementation just yet. |
Also note that if you're using an import map in browsers that don't support multiple import maps, even a module script loaded before your import map would break the theme. |
I didn't know about multiple import maps, that's so cool! I still think we should have at least a warning in app blocks to discourage app author to do it until multiple import maps are widely supported. |
I tend to agree we need to avoid those scenarios until coverage is better, or alternatively load a polyfill to smooth the gaps over in UAs that don't support multiple import maps. |
I actually was not even aware of the limitation regarding a module being loaded before the importmap. That's good to know! And even easier for app dev to not realize that this may break based on the theme (Dawn does not use module anywhere, while all our newer themes do). We should play it safe here! |
TBF I'm not sure the building blocks are there. IIRC the API for app blocks & assets is fairly limited.
From what I understand and remember, this means that the platform controls how the scripts are injected (and IIRC at the bottom of Same for app embeds. You'd target the bottom of The only surface I could think of is an app embed that targets EDIT: I guess a |
Yes, the problem are app embed in the . An app embed in the head could do this:
The module If the same app embed would be on Prestige or Impact, it would break the theme. :D |
Yeah that's fair and I think a reasonable ask. Check requirements
|
Multiple import maps are shipping soon in Chromium and in a future Safari. But given our legacy browser support requirements, we'd probably also need a polyfill that catches the errors multiple import maps cause in (soon-to-be) legacy browsers and recovers from them (e.g. by loading them again using system.js). |
@guybedford pointed out to me that es-module-shims is the right polyfill for this, and that it recently got multiple import map support. |
I’ve been using this polyfill for nearly 2 years on our themes using importmap, never had a problem, it works really well! |
Hello!
In our recent themes I am using import map. Those are awesome.
However, while this has not happened yet, I’m pretty sure some app dev will create an app block in the head that create an import map.
Because only one import map can exist per document, if an app create an import map this will break the theme completely. An app dev might not realize it if they are testing on a theme (such as Dawn) that is not using import map.
As a prevention, theme checker should emit an error if an app block contains a script whose type is importmap (https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script/type/importmap).
Thanks
The text was updated successfully, but these errors were encountered: