Chained CSS Module `composes` not working with Turbopack
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 142k
- Forks
- 32.4k
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 351
Description
Link to the code that reproduces this issue
https://codesandbox.io/p/devbox/next-turbo-css-modules-chained-composes-issue-hjyd9c
To Reproduce
- Start the app in Turbopack mode (
npm run dev). - Note that the "text" is styled bold and italic, but not underlined.
- Restart the app in Webpack mode (
npm run devWebpack). - Note that the "text" is now also underlined.
Current vs. Expected behavior
Consider the following SCSS code which is used in the linked reproduction:
.a {
text-decoration: underline;
}
.b {
composes: a;
font-style: italic;
}
.c {
composes: b;
font-weight: bold;
}
The sample text has className={styles.c}.
Using Webpack, this composes to "c b a", which is the expected behaviour. I.e. It supports chaining of composes.
Using Turbopack, it composes only to "c b", which is unexpected.
Turbopack not supporting chaining of composes means it fails to build our web apps correctly, as they have been coded to depend on this behaviour.
Provide environment information
Operating System:
Platform: linux
Arch: x64
Version: #1 SMP PREEMPT_DYNAMIC Sun Aug 6 20:05:33 UTC 2023
Available memory (MB): 4102
Available CPU cores: 2
Binaries:
Node: 20.9.0
npm: 9.8.1
Yarn: 1.22.19
pnpm: 8.10.2
Relevant Packages:
next: 16.0.1-canary.1 // Latest available version is detected (16.0.1-canary.1).
eslint-config-next: N/A
react: 19.2.0
react-dom: 19.2.0
typescript: 5.9.3
Next.js Config:
output: N/A
Which area(s) are affected? (Select all that apply)
CSS, Turbopack
Which stage(s) are affected? (Select all that apply)
next dev (local), next build (local)
Additional context
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked CodeSandbox reproduction and run npm run dev and npm run devWebpack to compare the generated class composition. Trace Turbopack's CSS Modules handling for chained composes; done means Turbopack produces c b a and preserves the underline in both next dev and next build.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- nextjs, react, scss
- Domain
- build-system, frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 68/100