Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSS modules with path which contains spaces does not work as expected #1626

Open
JounQin opened this issue Dec 26, 2024 · 2 comments
Open

CSS modules with path which contains spaces does not work as expected #1626

JounQin opened this issue Dec 26, 2024 · 2 comments

Comments

@JounQin
Copy link
Contributor

JounQin commented Dec 26, 2024

Bug report

Actual Behavior

generated src_render_js.js:

image

source render.js:

import * as styles from './space folder/render.module.css';

export function render() {
  const el = document.createElement('div');
  el.className = styles.text; // styles.text contains a space which breaks styling
  document.getElementsByTagName('body')[0].appendChild(el);
  el.innerHTML = 'hello, world';
}

Expected Behavior

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

The generated class is src-space folder-render-module__text-WVNeAh which contains a space, but it's not possible to escape spaces, so the spaces in path should be changed to __ for example.

How Do We Reproduce?

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

Run pnpm dev:webpack

Please paste the results of npx webpack-cli info here, and mention other relevant information

@JounQin
Copy link
Contributor Author

JounQin commented Dec 26, 2024

I tried to add space pattern into

const filenameReservedRegex = /[<>:"/\\|?*]/g;
and then it works as expected, I'd raise a PR if it is accepted.

@JounQin
Copy link
Contributor Author

JounQin commented Dec 26, 2024

Not sure if #997 related.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant