Skip to content

(Potential) Bug with getLocalIdent function refactor #1214

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

Closed
benmvp opened this issue Oct 22, 2020 · 1 comment
Closed

(Potential) Bug with getLocalIdent function refactor #1214

benmvp opened this issue Oct 22, 2020 · 1 comment

Comments

@benmvp
Copy link

benmvp commented Oct 22, 2020

  • Operating System: macOS 10.15.5
  • Node Version: 12.18.3
  • NPM Version: 6.14.6
  • webpack Version: 4.44.2
  • css-loader Version: 4.3.0

Expected Behavior

This PR by @evilebottnawi changed the content being passed to interpolateName (in loader-utils) from including a plus + to including \x00.

The PR doesn't give an explanation for why this part of the change was made, but as a result upgrading to css-loader v4 or higher breaks my integration with babel-plugin-react-css-modules which is still using + (through the generic-names package).

If this is not a bug I can try to get things changed in generic-names, but it would be good to at least get an understanding of why the change from + to \x00.

My expected behavior was that the class name hashes would be identical, for the same localIdentName ([folder]___[name]__[local]___[md4:contenthash:base64:5]).

Actual Behavior

The hashes are not the same because the passed in content is different.

  • For css-loader the content is: app/javascript/components/QuickAction/styles.module.scss\u0000mobile-only
  • For babel-plugin-react-css-modules the content is: app/javascript/components/QuickAction/styles.module.scss+mobile-only

css-loader is generating the classes for the CSS code whereas babel-plugin-react-css-modules is generating the classes to be used in the React markup. The actual result is that nothing on the page is styled. 😄

Code

n/a

How Do We Reproduce?

There's quite a bit of setup needed to reproduce the error, but hopefully by pinpointing the change above, this isn't necessary.

@alexander-akait
Copy link
Member

alexander-akait commented Oct 22, 2020

Sorry, it is not bug, we change our logic, please open an issue in babel-plugin-react-css-modules

If this is not a bug I can try to get things changed in generic-names, but it would be good to at least get an understanding of why the change from + to \x00.

Because you can use + character in filename, so you can have same hash for different classes in some cases, but you can't use \x00 in filenames

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

2 participants