Skip to content

fix: contenthash should care about ChunkGraphModule#id#2292

Merged
hyfdev merged 3 commits into
mainfrom
hyf_fix_contenthash_1274289347983287
Mar 16, 2023
Merged

fix: contenthash should care about ChunkGraphModule#id#2292
hyfdev merged 3 commits into
mainfrom
hyf_fix_contenthash_1274289347983287

Conversation

@hyfdev

@hyfdev hyfdev commented Mar 16, 2023

Copy link
Copy Markdown
Contributor

Summary

Related issue (if exists)

Fixs #2270

Types of changes

  • Docs change / Dependency upgrade
  • Bug fix
  • New feature / Improvement
  • Refactoring
  • Breaking change

Checklist

  • I have added changeset via pnpm run changeset.
  • I have added tests to cover my changes.

@changeset-bot

changeset-bot Bot commented Mar 16, 2023

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: f0de777

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 16 packages
Name Type
@rspack/binding Patch
@rspack/postcss-loader Patch
@rspack/core Patch
@rspack/cli Patch
@rspack/dev-middleware Patch
@rspack/dev-server Patch
@rspack/plugin-html Patch
benchmarkcase-rspack-react-refresh Patch
@rspack/dev-client Patch
@rspack/plugin-minify Patch
@rspack/plugin-node-polyfill Patch
@rspack/binding-darwin-arm64 Patch
@rspack/binding-darwin-x64 Patch
@rspack/binding-linux-x64-gnu Patch
@rspack/binding-win32-x64-msvc Patch
@rspack/fs Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions Bot added the team The issue/pr is created by the member of Rspack. label Mar 16, 2023
@hyfdev
hyfdev force-pushed the hyf_fix_contenthash_1274289347983287 branch from 1e95992 to b63292b Compare March 16, 2023 06:46
@hyfdev
hyfdev requested a review from underfin March 16, 2023 07:07
@hyfdev
hyfdev merged commit 6d9eb8b into main Mar 16, 2023
@hyfdev
hyfdev deleted the hyf_fix_contenthash_1274289347983287 branch March 16, 2023 07:43
@h-a-n-a

h-a-n-a commented Mar 16, 2023

Copy link
Copy Markdown
Contributor

!canary

FrozenPandaz pushed a commit to nrwl/nx that referenced this pull request Jun 29, 2026
#36136)

## Current Behavior

`NxAppRspackPlugin` maps `outputHashing: 'all'` (the default) to two
different hash placeholders: `output.filename` uses `[contenthash]`, but
`output.chunkFilename` uses `[chunkhash]`. rspack's `[chunkhash]` hashes
a chunk's module bodies but not each contained module's assigned id.
With the production default `optimization.moduleIds: 'deterministic'`, a
module's id can be renumbered by an unrelated change to the module
graph, which changes a chunk's emitted bytes without changing its
`[chunkhash]` filename. Long-term-cached clients then keep the old chunk
against a freshly built entry that references the new id and crash with
`Uncaught TypeError: Cannot read properties of null (reading 'call')`.
`optimization.realContentHash` does not mitigate this, since it only
re-hashes `[contenthash]`.

## Expected Behavior

`output.chunkFilename` uses `[contenthash]`, matching `output.filename`,
so a chunk's filename always changes when its emitted content does. This
is rspack's recommended hash for long-term caching and matches the
defaults of Angular CLI, create-react-app, and Vue CLI.

## Implementation Details

`getOutputHashFormat` in
`packages/rspack/src/plugins/utils/hash-format.ts` now uses
`[contenthash]` for `chunk` in both the `bundles` and `all` options.
Confirmed against rspack source: `[contenthash]` folds the module id
into the hash (web-infra-dev/rspack#2292, released in v0.1.2, below the
`@rspack/core ^1 || ^2` support floor) while `[chunkhash]` does not.

`@nx/webpack` carries the same `[chunkhash]` default but was
deliberately left unchanged: webpack's `[chunkhash]` already folds
module ids into the chunk hash (via `getModuleHash`), so it does not
exhibit this stale-chunk problem.

## Related Issue(s)

Fixes #36014

<!-- polygraph-session-start -->
---
[View session information
↗](https://app.trypolygraph.com/orgs/6a061dcb561c062131116eca/sessions/gh-36014-54fdd58d)
<!-- polygraph-session-end -->
FrozenPandaz pushed a commit to nrwl/nx that referenced this pull request Jul 9, 2026
#36136)

## Current Behavior

`NxAppRspackPlugin` maps `outputHashing: 'all'` (the default) to two
different hash placeholders: `output.filename` uses `[contenthash]`, but
`output.chunkFilename` uses `[chunkhash]`. rspack's `[chunkhash]` hashes
a chunk's module bodies but not each contained module's assigned id.
With the production default `optimization.moduleIds: 'deterministic'`, a
module's id can be renumbered by an unrelated change to the module
graph, which changes a chunk's emitted bytes without changing its
`[chunkhash]` filename. Long-term-cached clients then keep the old chunk
against a freshly built entry that references the new id and crash with
`Uncaught TypeError: Cannot read properties of null (reading 'call')`.
`optimization.realContentHash` does not mitigate this, since it only
re-hashes `[contenthash]`.

## Expected Behavior

`output.chunkFilename` uses `[contenthash]`, matching `output.filename`,
so a chunk's filename always changes when its emitted content does. This
is rspack's recommended hash for long-term caching and matches the
defaults of Angular CLI, create-react-app, and Vue CLI.

## Implementation Details

`getOutputHashFormat` in
`packages/rspack/src/plugins/utils/hash-format.ts` now uses
`[contenthash]` for `chunk` in both the `bundles` and `all` options.
Confirmed against rspack source: `[contenthash]` folds the module id
into the hash (web-infra-dev/rspack#2292, released in v0.1.2, below the
`@rspack/core ^1 || ^2` support floor) while `[chunkhash]` does not.

`@nx/webpack` carries the same `[chunkhash]` default but was
deliberately left unchanged: webpack's `[chunkhash]` already folds
module ids into the chunk hash (via `getModuleHash`), so it does not
exhibit this stale-chunk problem.

## Related Issue(s)

Fixes #36014

<!-- polygraph-session-start -->
---
[View session information
↗](https://app.trypolygraph.com/orgs/6a061dcb561c062131116eca/sessions/gh-36014-54fdd58d)
<!-- polygraph-session-end -->

(cherry picked from commit 15871f0)
FrozenPandaz added a commit to nrwl/nx that referenced this pull request Jul 15, 2026
…eywords (#36326)

## Current Behavior

`nx release changelog` extracts issue references from the commit body
with a bare `/(#\d+)/gm` regex, so **every** `#number` in a squashed PR
description becomes an issue link in the changelog — including other
repos' issue numbers.

For example, the [23.1.0 release
notes](https://github.com/nrwl/nx/releases/tag/23.1.0) contain:

> **rspack:** support @rspack/core@2 and @rsbuild/core@2 (multi-version
compliance) (#35682, #35764, #13420, #781)

where `#13420` is actually `web-infra-dev/rspack#13420` and `#781` is
`privatenumber/tsx#781` — upstream issues discussed in the PR
description, rendered as (bogus) `nrwl/nx` issue links. The same release
also picked up `nrwl/nx-console#3175`, `react/react#418`, and
`web-infra-dev/rspack#2292`, plus noisy same-repo PR mentions that were
merely referenced in prose.

## Expected Behavior

Issue references are only extracted from the commit body when linked via
a GitHub closing keyword (`Fixes #123`, `Closes #123`, `Resolves: #123`,
...) — the same rule GitHub itself uses to auto-link and close issues.
Cross-repo forms (`owner/repo#123`), markdown links to other repos, and
casual same-repo mentions no longer produce changelog references.

Subject-line extraction (the PR number in `(#123)` and inline issue
refs) is unchanged. Both regular commits and version plans go through
the same `extractReferencesFromCommit` function, so this fixes both
paths.

## Related Issue(s)

N/A

<!-- polygraph-session-start -->
---
[View session information
↗](https://app.trypolygraph.com/orgs/6a061dcb561c062131116eca/sessions/Fix-nx-release-changelog-scraping-other-repos-issue-numbers-7967dd62)
<!-- polygraph-session-end -->
AgentEnder pushed a commit to nrwl/nx that referenced this pull request Jul 17, 2026
…eywords (#36326)

## Current Behavior

`nx release changelog` extracts issue references from the commit body
with a bare `/(#\d+)/gm` regex, so **every** `#number` in a squashed PR
description becomes an issue link in the changelog — including other
repos' issue numbers.

For example, the [23.1.0 release
notes](https://github.com/nrwl/nx/releases/tag/23.1.0) contain:

> **rspack:** support @rspack/core@2 and @rsbuild/core@2 (multi-version
compliance) (#35682, #35764, #13420, #781)

where `#13420` is actually `web-infra-dev/rspack#13420` and `#781` is
`privatenumber/tsx#781` — upstream issues discussed in the PR
description, rendered as (bogus) `nrwl/nx` issue links. The same release
also picked up `nrwl/nx-console#3175`, `react/react#418`, and
`web-infra-dev/rspack#2292`, plus noisy same-repo PR mentions that were
merely referenced in prose.

## Expected Behavior

Issue references are only extracted from the commit body when linked via
a GitHub closing keyword (`Fixes #123`, `Closes #123`, `Resolves: #123`,
...) — the same rule GitHub itself uses to auto-link and close issues.
Cross-repo forms (`owner/repo#123`), markdown links to other repos, and
casual same-repo mentions no longer produce changelog references.

Subject-line extraction (the PR number in `(#123)` and inline issue
refs) is unchanged. Both regular commits and version plans go through
the same `extractReferencesFromCommit` function, so this fixes both
paths.

## Related Issue(s)

N/A

<!-- polygraph-session-start -->
---
[View session information
↗](https://app.trypolygraph.com/orgs/6a061dcb561c062131116eca/sessions/Fix-nx-release-changelog-scraping-other-repos-issue-numbers-7967dd62)
<!-- polygraph-session-end -->
FrozenPandaz added a commit to nrwl/nx that referenced this pull request Jul 20, 2026
…eywords (#36326)

## Current Behavior

`nx release changelog` extracts issue references from the commit body
with a bare `/(#\d+)/gm` regex, so **every** `#number` in a squashed PR
description becomes an issue link in the changelog — including other
repos' issue numbers.

For example, the [23.1.0 release
notes](https://github.com/nrwl/nx/releases/tag/23.1.0) contain:

> **rspack:** support @rspack/core@2 and @rsbuild/core@2 (multi-version
compliance) (#35682, #35764, #13420, #781)

where `#13420` is actually `web-infra-dev/rspack#13420` and `#781` is
`privatenumber/tsx#781` — upstream issues discussed in the PR
description, rendered as (bogus) `nrwl/nx` issue links. The same release
also picked up `nrwl/nx-console#3175`, `react/react#418`, and
`web-infra-dev/rspack#2292`, plus noisy same-repo PR mentions that were
merely referenced in prose.

## Expected Behavior

Issue references are only extracted from the commit body when linked via
a GitHub closing keyword (`Fixes #123`, `Closes #123`, `Resolves: #123`,
...) — the same rule GitHub itself uses to auto-link and close issues.
Cross-repo forms (`owner/repo#123`), markdown links to other repos, and
casual same-repo mentions no longer produce changelog references.

Subject-line extraction (the PR number in `(#123)` and inline issue
refs) is unchanged. Both regular commits and version plans go through
the same `extractReferencesFromCommit` function, so this fixes both
paths.

## Related Issue(s)

N/A

<!-- polygraph-session-start -->
---
[View session information
↗](https://app.trypolygraph.com/orgs/6a061dcb561c062131116eca/sessions/Fix-nx-release-changelog-scraping-other-repos-issue-numbers-7967dd62)
<!-- polygraph-session-end -->

(cherry picked from commit d7312d2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

team The issue/pr is created by the member of Rspack.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants