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

breaking: use output.hashFunction as loader cache hasher #1027

Merged

Conversation

JLHwung
Copy link
Contributor

@JLHwung JLHwung commented Jul 15, 2024

Please Read the CONTRIBUTING Guidelines
In particular the portion on Commit Message Formatting

Please check if the PR fulfills these requirements

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other... Please describe:

What is the current behavior? (You can also link to an open issue here)
The babel-loader hash function can not be changed by users. It will use sha256 and then fallback to md5.

What is the new behavior?
The hash function is now determined by the webpack option output.hashFunction. This opens the door to more performant hash such as the future webpack defaults xxhash64. Plus we don't have to update the hash function again if in the future OpenSSL drops more unsafe crypto hash functions, since users can provide the desired hashFunction in the webpack config.

Does this PR introduce a breaking change?

  • Yes
  • No

If this PR contains a breaking change, please describe the following...

The cache filename might be changed because now it aligns to the webpack option output.hashFunction, which may be different than our previous hash function choice.

  • Impact: Low
  • Migration path for existing applications: purge the babel-loader cache before upgrading babel-loader. If they are not purged, the function of babel-loader will not be impacted but doing so will save some disk space.
  • Github Issue(s) this is regarding:

Other information:

@JLHwung
Copy link
Contributor Author

JLHwung commented Jul 15, 2024

Rebased on #1026 as the utils.createHash API is not available on webpack 5.0.0.

@JLHwung JLHwung force-pushed the use-webpack-output-hashfunction-as-loader-cache-hashfunction branch 2 times, most recently from d51c415 to 41cacd9 Compare July 15, 2024 22:50
@JLHwung JLHwung force-pushed the use-webpack-output-hashfunction-as-loader-cache-hashfunction branch from 41cacd9 to 9e6f6d0 Compare July 15, 2024 22:53
@@ -181,13 +181,17 @@ async function loader(source, inputSourceMap, overrides) {

let result;
if (cacheDirectory) {
const hash = this.utils.createHash(
this._compilation.outputOptions.hashFunction,
);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@JLHwung JLHwung merged commit faafb08 into main Jul 16, 2024
16 checks passed
@JLHwung JLHwung changed the title breaking: use output.hashFunction as loader cache breaking: use output.hashFunction as loader cache hasher Aug 28, 2024
@JLHwung JLHwung mentioned this pull request Sep 4, 2024
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

Successfully merging this pull request may close these issues.

3 participants