Skip to content

[Bug] css module path with spaces does not work as expected, rspack works by the way #4278

@JounQin

Description

@JounQin

https://github.com/JounQin/rspack-css-modules-spaces

{
  "@rspack/cli": "^1.1.8",
  "@rspack/core": "^1.1.8",
  "@rsbuild/core": "^1.1.13"
}

When running pnpm dev:rspack, the generated class name is rspack-repro-_src_space_folder_render_module_css-text which works as expected, but for pnpm dev:rsbuild, it's src-space folder-render-module__text-DF713n in html and .src-space\ folder-render-module__text-DF713n in .css file.

And it's not possible to escape spaces into html.

https://stackoverflow.com/questions/50812118/is-it-possible-to-use-the-space-character-in-css-class-names

The original el.classList.add(styles.text) throws:

https://github.com/JounQin/rspack-css-modules-spaces/blob/4d081a81dafb914b63d3800e06cc3bb62032224c/src/render.js#L5

Uncaught (in promise) InvalidCharacterError: Failed to execute 'add' on 'DOMTokenList': The token provided ('src-space folder-render-module__text-DF713n') contains HTML space characters, which are not valid in tokens.
    at Module.render (render.js:6:1)
    at index.js:2:1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions