Skip to content

Commit

Permalink
fix(turbopack): Fix CSS Modules class name for lightningcss mode (ver…
Browse files Browse the repository at this point in the history
…cel/turborepo#7718)

### Description

`lightningcss` enforces the class name to end with `[local]`.

See: https://lightningcss.dev/css-modules.html#css-grid

### Testing Instructions

I'll add a test soon.

Closes PACK-2731
  • Loading branch information
kdy1 authored Mar 13, 2024
1 parent 1dc8947 commit 36c08c0
Show file tree
Hide file tree
Showing 26 changed files with 123 additions and 34 deletions.
4 changes: 2 additions & 2 deletions crates/turbopack-css/src/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -539,11 +539,11 @@ async fn process_content(
CssModuleAssetType::Module => Some(lightningcss::css_modules::Config {
pattern: Pattern {
segments: smallvec![
Segment::Local,
Segment::Literal("__"),
Segment::Name,
Segment::Literal("__"),
Segment::Hash,
Segment::Literal("__"),
Segment::Local,
],
},
dashed_idents: false,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import style from "./style.module.css";

console.log(style);
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.module-style {
grid-template-areas: 'checkbox avatar content actions menu';
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
(globalThis.TURBOPACK = globalThis.TURBOPACK || []).push([
"output/crates_turbopack-tests_tests_snapshot_css_css-modules_input_index_250a0b.js",
{},
]);
(globalThis.TURBOPACK_CHUNK_LISTS = globalThis.TURBOPACK_CHUNK_LISTS || []).push({
"path": "output/crates_turbopack-tests_tests_snapshot_css_css-modules_input_index_250a0b.js",
"chunks": [
"output/crates_turbopack-tests_tests_snapshot_css_css-modules_input_style_module_71f14f.css",
"output/crates_turbopack-tests_tests_snapshot_css_css-modules_input_8abc52._.js"
],
"source": "entry"
});

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 36c08c0

Please sign in to comment.