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

CSS Module Scripts #206

Closed
Westbrook opened this issue Oct 12, 2022 · 13 comments
Closed

CSS Module Scripts #206

Westbrook opened this issue Oct 12, 2022 · 13 comments
Labels
focus-area-proposal Focus Area Proposal

Comments

@Westbrook
Copy link

Description

CSS Module Scripts allow JavaScript modules to import style sheets. They can then be applied to a document or shadow root using adoptedStyleSheets in the same way as constructible style sheets.

Not currently available cross browser (Safari) effecting adoption.

Rationale

  • CSS modules will allow styles to be loaded in component definitions without adding <style> or elements that need to be created in each element instance.
  • Authors today often use inlined CSS strings in JS modules, but many of them want to move the CSS into separate .css files.
  • Without CSS-in-JS it's difficult to ensure that CSS is loaded before the component is defined and rendered. CSS module scripts provide the same ordering guarantee.
  • Component authors may need to import a resource that is only available as an external .css file, and don't have control over the resource to wrap it in a JS module.

Specification

https://github.com/tc39/proposal-import-assertions

Tests

tc39/test262@18834b2

@Westbrook Westbrook added the focus-area-proposal Focus Area Proposal label Oct 12, 2022
@foolip foolip moved this to Proposed in Interop 2023 Oct 12, 2022
This was referenced Oct 12, 2022
@gsnedders
Copy link
Member

Specification

https://github.com/tc39/proposal-import-assertions

The integration for CSS modules is defined in HTML, too, IIRC.

Tests

tc39/test262@18834b2

These all just appear to be the general import assertions tests, nothing specifically about CSS modules?

@Westbrook
Copy link
Author

Yep, while CSS is spec'd and agreed to, I'm not sure any tests have been added for it, specifically.

@jogibear9988
Copy link

jogibear9988 commented Oct 16, 2022

And the Safari Bug for this:
https://bugs.webkit.org/show_bug.cgi?id=227967

@jogibear9988
Copy link

I think in Firefox they are also not yet ready:
https://bugzilla.mozilla.org/show_bug.cgi?id=1720570

@foolip
Copy link
Member

foolip commented Oct 17, 2022

Looks like the HTML part was defined in whatwg/html#4898 and is spread across the spec.

@foolip
Copy link
Member

foolip commented Oct 17, 2022

Tests are here:
https://wpt.fyi/results/html/semantics/scripting-1/the-script-element/css-module?label=experimental&label=master&aligned

@annevk
Copy link
Member

annevk commented Oct 28, 2022

This is part of #236 in a way and I have the same concern here with whatwg/html#7233 not being sorted. I'd really like to have clarity around CSP first.

@emilio
Copy link

emilio commented Nov 3, 2022

It'd also be good to know whether they are intended to be de-duplicated etc, see WICG/webcomponents#870 etc.

@foolip
Copy link
Member

foolip commented Nov 11, 2022

In the MDN short survey on APIs & JavaScript, "Web Components (custom elements, Shadow DOM, etc.)" was the most popular choice by a fairly wide margin, selected by ~39% of survey takers.

Web Components was split into many granular proposals, and the survey results don't tell us which aspects web developers want the most, but it's fair to say that something about Web Components is important. (I'm posting this comment on each of the split proposals.)

@nairnandu
Copy link
Contributor

Thank you for proposing CSS Module Scripts for inclusion in Interop 2023.

We wanted to let you know that this proposal was not selected to be part of Interop this year. As discussed in the issue comments, there are still open spec questions around CSP. To make progress on this area in the future it will first be necessary to ensure that the feature has a clear specification in a standards track document. We would be happy to see the proposal submitted for a future round of Interop once these spec questions are resolved.

For an overview of our process, see the proposal selection summary. Thank you again for contributing to Interop 2023!

Posted on behalf of the Interop team.

@jogibear9988
Copy link

The proposal is already in the html spec (i think)

@annevk
Copy link
Member

annevk commented Feb 6, 2023

Correct, but it has known issues as pointed out above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
focus-area-proposal Focus Area Proposal
Projects
No open projects
Status: Proposed
Development

No branches or pull requests

7 participants