Replies: 3 comments
-
|
Based on the documentation, this appears to be an intentional limitation, as outlined here: https://nextjs.org/docs/app/api-reference/turbopack#unsupported-and-unplanned-features |
Beta Was this translation helpful? Give feedback.
-
|
Thanks for pointing that out, my mistake for not reading that section of the documentation beforehand. That said, I’d like to highlight that the lack of support for cross-module references is a significant limitation for teams using CSS Modules at scale. Being unable to reference class names across components makes it much harder to build consistent, decoupled, modular styling systems without falling back to :global CSS or workaround with element style and CSS variables. Even if it’s currently marked as “unsupported/unplanned”, I think it deserves reconsideration. |
Beta Was this translation helpful? Give feedback.
-
|
Converted to discussions |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Link to the code that reproduces this issue
https://github.com/fakkio/next-issue-postcss-modules-values.git
To Reproduce
create-next-app(App Router, TypeScript).src/app/page.tsxsrc/app/page.module.csssrc/app/redBg.module.cssStart the app with Webpack:
✅ Rendered page is correct:
✅ Expected CSS is generated correctly:
Start the app with Turbopack (default):
❌ Rendered page is wrong:
❌ The generated CSS contains unresolved
@valuetokens, i.e. the custom color is not replaced in rebBg module and the .greenify class is different from the original one in page module:Current vs. Expected behavior
Current (Turbopack)
@valueimports from CSS Modules are not resolved — the literalcustomstring remains in the final CSS output and the greenify class has a different hash name.Expected (Webpack)
The PostCSS plugin for
@valueshould replace imported constants (e.g.,custom) with their actual values (e.g.,#0c77f8), and greenify class should match the original one, matching the behavior of the Webpack pipeline.This affects both dev and build stages.
Provide environment information
Which area(s) are affected? (Select all that apply)
CSS
Which stage(s) are affected? (Select all that apply)
next dev (local), next build (local), next start (local), Vercel (Deployed)
Additional context
No response
Beta Was this translation helpful? Give feedback.
All reactions