System info
- Rspack: 2.1.3
- Node.js: 24.15.0
- Platform: macOS arm64
Minimal reproduction
Compile the same entry twice with builtin CSS Modules enabled. The only relevant difference between the client and SSR configurations is generator.exportsOnly:
const common = {
experiments: {
css: true,
},
module: {
rules: [
{
test: /\.module\.css$/,
type: 'css/module',
generator: {
localIdentName: '[local]-[hash:base64:6]',
},
},
],
},
};
// client build
{
...common,
module: {
rules: [
{
test: /\.module\.css$/,
type: 'css/module',
generator: {
exportsOnly: false,
localIdentName: '[local]-[hash:base64:6]',
},
},
],
},
}
// SSR build
{
...common,
target: 'node',
module: {
rules: [
{
test: /\.module\.css$/,
type: 'css/module',
generator: {
exportsOnly: true,
localIdentName: '[local]-[hash:base64:6]',
},
},
],
},
}
Import a class named external from the same style.module.css file in both builds.
Actual behavior
The generated local identifiers differ:
- client (
exportsOnly: false): external-WlNYTF
- SSR (
exportsOnly: true): external-UmUtc0
If exportsOnly is forced to false in both builds, both sides generate external-WlNYTF.
This reproduces with a regular .module.css import, so it is not specific to a framework or SFC integration.
Expected behavior
exportsOnly should control whether CSS assets are emitted, but should not affect CSS Modules local identifier generation. The SSR and client compilations must produce identical class names for the same resource and local name.
Impact
SSR markup contains a class name that does not match the client CSS output. This can cause missing styles and hydration mismatches in applications that use builtin CSS Modules with exportsOnly: true for the server build.
by OpenAI Codex
System info
Minimal reproduction
Compile the same entry twice with builtin CSS Modules enabled. The only relevant difference between the client and SSR configurations is
generator.exportsOnly:Import a class named
externalfrom the samestyle.module.cssfile in both builds.Actual behavior
The generated local identifiers differ:
exportsOnly: false):external-WlNYTFexportsOnly: true):external-UmUtc0If
exportsOnlyis forced tofalsein both builds, both sides generateexternal-WlNYTF.This reproduces with a regular
.module.cssimport, so it is not specific to a framework or SFC integration.Expected behavior
exportsOnlyshould control whether CSS assets are emitted, but should not affect CSS Modules local identifier generation. The SSR and client compilations must produce identical class names for the same resource and local name.Impact
SSR markup contains a class name that does not match the client CSS output. This can cause missing styles and hydration mismatches in applications that use builtin CSS Modules with
exportsOnly: truefor the server build.by OpenAI Codex