Skip to content
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

Module type check should take environment into account #7047

Closed
annevk opened this issue Sep 9, 2021 · 4 comments · Fixed by #7066
Closed

Module type check should take environment into account #7047

annevk opened this issue Sep 9, 2021 · 4 comments · Fixed by #7066

Comments

@annevk
Copy link
Member

annevk commented Sep 9, 2021

If module type is not "javascript", "css", or "json", then asynchronously complete this algorithm with null, and return.

We shouldn't claim to support "css" in workers here. That results in redundant fetches and is also inconsistent with the feature proposed in #7017.

(It also doesn't match the discussion in tc39/proposal-import-attributes#111 I think.)

cc @dandclark

@annevk annevk added topic: agent The interaction with JavaScript's agent and agent cluster concepts. topic: script and removed topic: agent The interaction with JavaScript's agent and agent cluster concepts. labels Sep 9, 2021
@domenic
Copy link
Member

domenic commented Sep 9, 2021

Yeah, this is my bad for suggesting the IDL exposure-based check currently in https://html.spec.whatwg.org/#creating-a-css-module-script . I didn't realize that would result in redundant fetches. (Which you can write WPTs about by using the server; see e.g. web-platform-tests/wpt#30259 for a similar scenario.)

Probably we should keep the exposure check as the method of determining whether it's supported? But just move it to somewhere early in the pipeline... I think "fetch a single module script" would work.

@annevk
Copy link
Member Author

annevk commented Sep 9, 2021

I don't see how exposure would work for import.meta.supportsType("css")? I was thinking we'd just have an algorithm that given a module type and an agent type, returns true or false.

@domenic
Copy link
Member

domenic commented Sep 9, 2021

Sure, that would probably help more for such future scenarios. Although I'd suggest the algorithm take an environment settings object and a module type.

@dandclark
Copy link
Contributor

Seems to me like we can check for this at the same spots where we already check (before the fetch) that the asserted type is "json"/"css". I took a crack at this here: #7066

domenic pushed a commit that referenced this issue Sep 16, 2021
Currently the check that disallows creation of CSS module scripts in worker contexts only happens after the fetch for that import is performed. This change moves the check to where we check that the assertion type is a valid value. By doing so, failing that check prevents the fetch.

Closes #7047.
mfreed7 pushed a commit to mfreed7/html that referenced this issue Jun 3, 2022
Currently the check that disallows creation of CSS module scripts in worker contexts only happens after the fetch for that import is performed. This change moves the check to where we check that the assertion type is a valid value. By doing so, failing that check prevents the fetch.

Closes whatwg#7047.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

3 participants