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

feat: CSS modules (early experimental support) #2489

Closed
wants to merge 87 commits into from
Closed

Conversation

chaance
Copy link
Collaborator

@chaance chaance commented Mar 25, 2022

Hi

@chaance chaance changed the title [DRAFT] feat: CSS modules feat: CSS modules (early experimental support) May 18, 2022
@chaance chaance marked this pull request as ready for review May 18, 2022 17:21
@MichaelDeBoey
Copy link
Member

@chaance It seems like we have some conflicts to resolve here

@chaance chaance marked this pull request as draft June 3, 2022 14:36
@wingleung
Copy link

@chaance just letting you know, I've been testing this in a PoC we're running and found out the :global and :local doesn't seem to resolve correctly.

for example, if the source css has the following code

:global .someGlobalClass :local .aLocalClass {
  background: red;
}

usually with parcel, which I think remix uses for css modules, it gets compiled to something like this

.someGlobalClass ._src_styles_module__aLocalClass {
  background: red;
}

however in this remix implementation I currently run into something like this, where .header-module is just the place where I use the :global/:local scope

:global .header-module__wSWGuW_someGlobalClass :local .header-module__wSWGuW_aLocalClass {
  background: red;
}

@devongovett
Copy link
Contributor

The :global and :local pseudo classes are not supported by Parcel CSS without the function syntax. Eg :global(.someGlobalClass)

@wingleung
Copy link

thanks @devongovett! that seems to work idd.

It's odd because I tested it with Parcel 2 and it did seem to compile correctly with just :global and :local
👉 https://codesandbox.io/s/parcel-2-css-modules-example-forked-tcejyi?file=/src/styles.module.css
parcel-2-css-module

@devongovett
Copy link
Contributor

Yes, Parcel 2 falls back to postcss-modules when it detects legacy syntax for backward compatibility.

code: source,
cssModules: true,
minify: process.env.NODE_ENV === "production",
analyzeDependencies: true,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chaance @devongovett when I use the url() function, the value in the url() gets hashed but never replaced again with the final result.

input

.container {
  background-image: url(https://images.unsplash.com/photo-1593288942460-e321b92a6cde)
}

output

.layout-module___9D6bia_container {
    background-image: url(mHxWpW);
}

This is because analyzeDependencies is set to true here but there is no process to replace those hashes with the actual results. more info

Does it need to be enabled? if so, we need to add a process to replace the hashes with the final urls again.

@wingleung
Copy link

any updates on this? 🙂

@chaance
Copy link
Collaborator Author

chaance commented Aug 26, 2022

@wingleung This is on hold as we're working on some bigger compiler updates that may impact our implementation quite a bit. I'm working on a public roadmap for this and other work to provide some transparency here.

@mikestopcontinues
Copy link

mikestopcontinues commented Dec 11, 2022

To anyone landing on this page, active work is happening here...

@chaance
Copy link
Collaborator Author

chaance commented Dec 13, 2022

Closing in favor of #4852

@chaance chaance closed this Dec 13, 2022
@markdalgleish markdalgleish mentioned this pull request Dec 13, 2022
2 tasks
@MichaelDeBoey MichaelDeBoey deleted the feature/css-modules branch December 15, 2022 19:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants