This is a minimal reproduction repository for an issue with Rspack css module's composes functionality.
When using native css modules support in rspack and changing the exportConvention to camel-case, Rspack doesn't export the composed class name list to the camel case version, only the old class name.
Rspack has experimental support for native css modules which also supports the css-modules spec
In the css-modules specification, there's a composes keyword which allows a class to inherit the styles from another class.
for example:
/* src/style.module.css */
.first-class {
color: red;
}
.second-class {
composes: first-class;
background: green;
}the way it's implemented is that when the second class name is exported into js-land, it's a space separated list of both class name identifiers.
that way when you put this on your HTML node's class property it'll get the styles from both classes.
When using the exporConvention: 'camel-case option in module.generator["css/auto"].exportsConvention, the composed class list string is not exported to the camel case version of the class name.
But it is exported to the original class name.
for example:
// src/index.js
import styles from "./style.module.css";
console.log(styles["second-class"]); // ✅ "first-class second-class"
console.log(styles.secondClass); // ❌ "first-class" (missing "second-class")The expected behavior is that both styles["second-class"] and styles.secondClass would output the same string: "first-class second-class".
I assume this has something to do with this bug.
Maybe they even have the same root cause.
- Clone this repository
- Run
pnpm install - Run
pnpm test - The test should fail the last assertion