Skip to content

ItamarGronich/rspack-css-compose

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Description

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.

Context

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.

Issue

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")

Expected Behavior

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.

Reproduction Steps

  1. Clone this repository
  2. Run pnpm install
  3. Run pnpm test
  4. The test should fail the last assertion

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors