nextjs - 💡(How to fix) Fix Chained CSS Module `composes` not working with Turbopack [3 comments, 3 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
vercel/next.js#85296Fetched 2026-04-08 02:16:29
View on GitHub
Comments
3
Participants
3
Timeline
9
Reactions
6
Author
Timeline (top)
commented ×3labeled ×2subscribed ×2cross-referenced ×1

Code Example

.a {
    text-decoration: underline;
}

.b {
    composes: a;
    font-style: italic;
}

.c {
    composes: b;
    font-weight: bold;
}

---

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
RAW_BUFFERClick to expand / collapse

Link to the code that reproduces this issue

https://codesandbox.io/p/devbox/next-turbo-css-modules-chained-composes-issue-hjyd9c

To Reproduce

  1. Start the app in Turbopack mode (npm run dev).
  2. Note that the "text" is styled bold and italic, but not underlined.
  3. Restart the app in Webpack mode (npm run devWebpack).
  4. 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

extent analysis

TL;DR

  • The issue can be worked around by flattening the CSS composition chain to avoid relying on chained composes in Turbopack mode.

Guidance

  • Review the SCSS code to identify all instances of chained composes and consider flattening these compositions to directly include all necessary styles.
  • Verify the behavior in both Turbopack and Webpack modes after making changes to ensure consistency.
  • Consider filing an issue with the Turbopack project to request support for chained composes, as this is a current limitation.
  • Evaluate the feasibility of using Webpack for production builds if the chaining behavior is critical, given that Webpack currently supports this feature.

Example

.a {
    text-decoration: underline;
}

.b {
    composes: a;
    font-style: italic;
}

.c {
    composes: a; // Directly compose from 'a' instead of 'b'
    font-weight: bold;
    font-style: italic; // Include 'italic' from 'b' directly
}

Notes

  • This workaround may require significant changes to the CSS architecture, depending on the complexity and depth of the composition chains.
  • The long-term solution would be for Turbopack to support chained composes, but this requires a fix from the Turbopack developers.

Recommendation

  • Apply workaround: Since the issue is due to a limitation in Turbopack, applying a workaround to flatten the composition chain is the most immediate way to resolve the inconsistency between Turbopack and Webpack modes.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING