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

fix: correct css modules hashing to match Webpack when leading digit #8735 #8778

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

daveskybet
Copy link

@daveskybet daveskybet commented Dec 19, 2024

Summary

As detailed in #8735 Rspack is currently out of sync with a recent change in Webpack around how css module hashes that lead with a digit are handled.

Current Rspack functionality removes all digits from the start of the hash so that hashed classnames never start with a digit, however this produces an edge case where when the hash is entirely digits it is reduced down to an empty string.

Webpack fixed this issue recently to instead prepend hashes starting with a digit with a underscore character ("_") - https://github.com/webpack/webpack/blob/964c0315df0ee86a2b4edfdf621afa19db140d4f/lib/dependencies/CssLocalIdentifierDependency.js#L81

This commit updates the regex/replace functionality to match Webpack's implementation.

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

@CLAassistant
Copy link

CLAassistant commented Dec 19, 2024

CLA assistant check
All committers have signed the CLA.

@github-actions github-actions bot added the release: bug fix release: bug related release(mr only) label Dec 19, 2024
Copy link

netlify bot commented Dec 19, 2024

Deploy Preview for rspack canceled.

Built without sensitive environment variables

Name Link
🔨 Latest commit 82171fe
🔍 Latest deploy log https://app.netlify.com/sites/rspack/deploys/67655d83cc11ca000830425e

@daveskybet daveskybet force-pushed the correct_css_module_hashing_8735 branch from 9182c67 to 73d734d Compare December 19, 2024 13:15
@LingyuCoder LingyuCoder force-pushed the correct_css_module_hashing_8735 branch from 73d734d to d1d608b Compare December 20, 2024 02:31
Copy link

codspeed-hq bot commented Dec 20, 2024

CodSpeed Performance Report

Merging #8778 will not alter performance

Comparing daveskybet:correct_css_module_hashing_8735 (82171fe) with main (52c2309)

Summary

✅ 1 untouched benchmarks

@daveskybet daveskybet force-pushed the correct_css_module_hashing_8735 branch 2 times, most recently from 308b69a to 60666fa Compare December 20, 2024 09:31
@daveskybet daveskybet force-pushed the correct_css_module_hashing_8735 branch from 60666fa to 82171fe Compare December 20, 2024 12:05
Copy link
Contributor

@ahabhgk ahabhgk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks! @LingyuCoder Can you help to run the CI and merge this?

@ahabhgk ahabhgk enabled auto-merge (squash) December 24, 2024 04:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release: bug fix release: bug related release(mr only)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants