Skip to content

Add rspack v2 support#975

Merged
justin808 merged 5 commits intomainfrom
jg/rspack-v2-upgrade
Mar 16, 2026
Merged

Add rspack v2 support#975
justin808 merged 5 commits intomainfrom
jg/rspack-v2-upgrade

Conversation

@justin808
Copy link
Copy Markdown
Member

@justin808 justin808 commented Mar 13, 2026

Summary

  • Accept both rspack v1 and v2 in peer deps (^1.0.0 || ^2.0.0-0) so users aren't forced to upgrade rspack
  • CI tests against rspack v2 beta (dev deps pinned to 2.0.0-beta.6)
  • Add requireOrError mocks to 2 rspack test files (Jest can't require() rspack v2's pure ESM)
  • Add version compatibility docs noting rspack v2 requires Node.js 20.19.0+
  • No source code changes — shakapacker doesn't use any of the 30+ APIs removed/changed in v2

Closes #974

Key details

Pure ESM: Rspack v2 ships as ESM-only. This works at runtime because Node 20.19.0+ supports require() of ESM modules natively (rspack v2 itself requires Node 20.19.0+). Jest's CJS runtime can't handle this, so tests mock requireOrError — the same pattern already used by other rspack test files.

No API changes needed: SubresourceIntegrityPlugin, CssExtractRspackPlugin, SwcJsMinimizerRspackPlugin, LightningCssMinimizerRspackPlugin, EnvironmentPlugin, builtin:swc-loader — all work identically in v2.

Backward compatible: Users on rspack v1 are unaffected. The peer dep range accepts both ^1.0.0 and ^2.0.0-0.

Test plan

  • yarn install — no resolution errors
  • yarn build — TypeScript compilation succeeds
  • yarn test — 44 suites, 438 tests all passing
  • yarn lint — clean
  • CI green
  • Integration test with a real Rails app using rspack v2

🤖 Generated with Claude Code

Summary by CodeRabbit

Release Notes

  • Documentation

    • Added Version Compatibility section detailing Rspack v1 and v2 support
    • Added upgrade benefits and migration guidance
    • Expanded installation instructions with multiple package manager examples
  • Chores

    • Updated dependencies to support Rspack v2 beta alongside v1

Update peer dependencies to require @rspack/core and @rspack/cli ^2.0.0-0,
and pin dev dependencies to 2.0.0-beta.6 for testing.

Rspack v2 ships as pure ESM, which can't be require()'d by Jest's CJS
runtime. Add requireOrError mocks to the two rspack test files that
previously loaded @rspack/core directly, consistent with the pattern
already used in other rspack test files (plugins, optimization, rules).

No source code changes needed — shakapacker's rspack integration code
doesn't use any of the 30+ APIs removed or changed in v2.

Closes #974

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 13, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: dad98441-1f15-4aba-93cf-2b87b3394523

📥 Commits

Reviewing files that changed from the base of the PR and between b259a0e and eb3cb27.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (4)
  • docs/rspack.md
  • package.json
  • test/package/bundlerUtils.rspack.test.js
  • test/package/rspack/index.test.js

Walkthrough

This pull request adds Rspack v2 beta support while maintaining v1 compatibility. Changes include updated peer and dev dependencies to allow both major versions, expanded documentation with version compatibility details and installation instructions, and Jest mocks to handle Rspack v2's ESM-only nature.

Changes

Cohort / File(s) Summary
Documentation Updates
docs/rspack.md
Added Version Compatibility section detailing support for Rspack v1 and v2, Node.js requirements, and benefits of upgrading. Expanded installation instructions for multiple package managers (npm, yarn, pnpm, bun).
Dependency Management
package.json
Updated devDependencies to pin @rspack/cli and @rspack/core to 2.0.0-beta.6. Updated peerDependencies to allow either ^1.0.0 or ^2.0.0-0.
Test Mocking for ESM Modules
test/package/bundlerUtils.rspack.test.js, test/package/rspack/index.test.js
Added Jest mocks for @rspack/core and rspack-manifest-plugin to handle their ESM-only nature in v2. Updated test assertions to instantiate plugin constructors and verify internal state.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰✨ A rabbit hops through version streams,
From v1 lands to v2 dreams,
Mocks and docs now dance as one,
Rspack compatibility—beautifully spun!

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch jg/rspack-v2-upgrade
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@claude
Copy link
Copy Markdown
Contributor

claude bot commented Mar 13, 2026

Review: Upgrade rspack support from v1 to v2

Overall this is a clean and well-reasoned upgrade. The "no source code changes needed" story checks out based on the referenced breaking-changes analysis, and the test mock approach is consistent with what the other rspack test files already do. A few things to address before merging:

Required

1. Node.js engine version must be updated

The PR description explicitly states: "rspack v2 requires Node 20.19.0+" (for native require() of pure-ESM modules). The engines.node field in package.json is still >= 20, which allows Node 20.0–20.18.x. Users on those versions will install the package successfully, then hit an opaque runtime error the first time rspack is loaded. This should be tightened to >= 20.19.0 (or at minimum >= 20.19).

2. @rspack/plugin-react-refresh peer dep needs attention

The peer dep is still ^1.0.0, which targets rspack v1. Please verify (and document here) whether v1 of this plugin works with rspack v2 or whether the range needs bumping. If v1 is incompatible, users upgrading rspack will silently end up with a broken React Fast Refresh setup.

3. Missing CHANGELOG entry

Dropping rspack v1 and requiring rspack v2 is a breaking change for existing rspack users. Per the project guidelines this warrants a ### Breaking or ### Changed entry under [Unreleased] (use /update-changelog for guided formatting).

Minor

4. bundlerUtils.rspack.test.js mock uses plain functions, not jest.fn()

The existing rspack test files (plugins.test.js, optimization.test.js, index.test.js) all use jest.fn(function(){…}) in their requireOrError mocks. The new mock block in bundlerUtils.rspack.test.js uses bare constructor functions, which means the mock constructors can't be spied on if assertions are ever added. Consider aligning with the established pattern.

5. Dev dep beta pin has no range

"@rspack/cli": "2.0.0-beta.6" is an exact pin with no caret or tilde. That's a deliberate and defensible choice (reproducible CI), but it means the lockfile won't move to newer betas automatically. A comment in the PR or a follow-up task to unpin once v2 stable ships would help future maintainers.

Change peer deps from ^2.0.0-0 to ^1.0.0 || ^2.0.0-0 so users
aren't forced to upgrade rspack just to get the latest shakapacker.

Add version compatibility section to docs/rspack.md noting that
rspack v2 requires Node.js 20.19.0+ (due to pure ESM).

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@justin808 justin808 changed the title Upgrade rspack support from v1 to v2 Add rspack v2 support Mar 13, 2026
Summarize key v2 benefits: persistent cache with proper invalidation,
stable incremental compilation, better tree shaking, unified target
config, stricter export validation, RSC support, and performance.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@claude
Copy link
Copy Markdown
Contributor

claude bot commented Mar 13, 2026

Review Summary

The approach here is solid — accepting ^1.0.0 || ^2.0.0-0 in peer deps, mocking requireOrError so Jest's CJS runtime can handle rspack v2's pure-ESM package, and keeping no source changes. The strategy is well-reasoned.

Issues to address

Must fix:

  • @rspack/plugin-react-refresh peer dep still only lists ^1.0.0 while the other rspack packages now accept v2. If there's a v2-compatible release of this plugin, the range should be updated. If there isn't one yet, that's worth calling out explicitly in the docs/PR notes so users know HMR/React Fast Refresh may not work with rspack v2.

Should fix:

  • bundlerUtils.rspack.test.js uses plain constructor functions in its requireOrError mock rather than jest.fn() — inconsistent with every other rspack test file in this PR and in the test suite. See inline comment for a suggested replacement.
  • docs/rspack.md: "If you're using rspack v1, any Node.js 20+ version works" is misleading — rspack v1 supports Node 16+. Suggested fix inline.

Nice to have:

  • The exact beta pin (2.0.0-beta.6) in dev deps is reasonable for now, but worth adding a tracking note (issue or TODO comment) to bump to ^2.0.0 once v2 stable ships.

What looks good

  • Peer dep range ^2.0.0-0 correctly includes pre-releases, which ^2.0.0 alone would not.
  • rspack/index.test.js mock is well-structured: uses jest.fn(), falls through to requireActual for unrecognized modules, and includes all the constructors the module under test needs.
  • yarn.lock cleanup is clean — removal of @module-federation/*, webpack-bundle-analyzer, @rspack/dev-server and friends all make sense as v2 dropped those dependencies.
  • No source code changes needed is a good sign for API stability between v1 and v2.

@claude
Copy link
Copy Markdown
Contributor

claude bot commented Mar 13, 2026

PR Review: Add rspack v2 support

Overall this is a clean, well-scoped change. The approach of mocking requireOrError to handle rspack v2's pure-ESM constraint in Jest is sound and consistent with patterns used elsewhere in the test suite. A few items worth addressing:

Issues

1. @rspack/plugin-react-refresh peer dep not updated

The PR updates @rspack/cli and @rspack/core peer dep ranges to ^1.0.0 || ^2.0.0-0, but @rspack/plugin-react-refresh is still pinned to ^1.0.0. If a v2-compatible version of that plugin ships (or if v1 is incompatible with rspack v2), users enabling React Fast Refresh will hit resolution errors. This should be verified and the range updated if needed.

2. Inconsistency between the two new mocks

bundlerUtils.rspack.test.js uses plain constructor functions, while rspack/index.test.js uses jest.fn(function ...). Beyond stylistic inconsistency, the plain-function mock in bundlerUtils.rspack.test.js throws new Error(...) for any module other than @rspack/core, whereas index.test.js correctly falls through to jest.requireActual. If the bundlerUtils code path ever invokes requireOrError for a second module (e.g. rspack-manifest-plugin), the test will throw rather than gracefully fall through. The index.test.js fallback pattern is safer and more consistent.

3. Documentation inconsistency: beta status and semver range

docs/rspack.md states the supported range as `^2.0.0` but the actual peer dep is `^2.0.0-0` (which admits pre-releases). More importantly, rspack v2 is still in beta; the docs do not call this out, which could lead users to treat it as a stable release. A brief note and correcting the semver range in the docs would be clearer.

Minor

  • devDeps are pinned to the exact beta string 2.0.0-beta.6. A short inline comment explaining why it is pinned rather than ranged would help future maintainers.
  • The func-names ESLint disable added to index.test.js is necessary, but a brief comment explaining the named-function pattern (required so instanceof checks on jest.fn constructor instances work correctly) would help contributors unfamiliar with the idiom.

@claude
Copy link
Copy Markdown
Contributor

claude bot commented Mar 15, 2026

Review: Add rspack v2 support

Overall this is a clean, well-scoped PR. The approach — accepting both v1 and v2 in peer deps, pinning v2 beta in dev deps for CI, and mocking requireOrError to work around Jest's CJS limitation with ESM-only rspack v2 — is the right strategy. The docs section is thorough. A few things worth addressing before merging:

Issues

Test mock duplication (medium)
The @rspack/core mock factory is copy-pasted verbatim across two test files, and the copies are already diverging: bundlerUtils.rspack.test.js is missing SubresourceIntegrityPlugin, SwcJsMinimizerRspackPlugin, and LightningCssMinimizerRspackPlugin. Extract a shared factory (e.g. test/helpers/rspackCoreMock.js) so there's one place to maintain it.

^2.0.0-0 peer dep range accepts all pre-releases (minor)
^2.0.0-0 matches 2.0.0-alpha.1, 2.0.0-beta.1, etc. The minimum tested version is beta.6 — users on an earlier pre-release could hit issues. Document the floor (or use >=2.0.0-beta.6 <3.0.0) and mention it in the version compatibility docs.

@rspack/cli v2 removes @rspack/dev-server (worth confirming)
The v1 CLI had @rspack/dev-server as a direct dependency. The v2 CLI no longer does. If rspack users rely on the dev server through the CLI transitively, this is a silent breakage when they upgrade. The PR description says no API changes were needed, but this transitive dep change should be explicitly confirmed as non-breaking.

Observations

  • Assertions changed from toBeInstanceOf(Function)jest.isMockFunction(...). The new assertions only confirm the mock is wired up, not the production interface shape. Since the mock is under our control this is mostly harmless, but the tests provide less confidence than before.
  • Pinning exact beta versions in devDependencies (no ^) is the right call for deterministic CI — just needs a manual bump when 2.0.0 stable ships.
  • The yarn.lock cleanup (removal of @module-federation/runtime-tools, webpack-bundle-analyzer, @rspack/dev-server, etc.) is a nice side effect of the v2 upgrade — significantly leaner dependency graph.
  • CI green + real Rails app integration test (both marked incomplete) should be confirmed before merging.

@claude
Copy link
Copy Markdown
Contributor

claude bot commented Mar 15, 2026

Review: Add rspack v2 support

The approach is sound - accepting both v1 and v2 in peer deps with no source changes is clean, and using requireOrError mocks to handle ESM-only rspack v2 in Jest follows the existing pattern.

Must-fix: None - no bugs or security issues found.

Should-fix:

  1. Duplicate @rspack/core mock boilerplate (inline comment on rspack/index.test.js): The same 8-plugin mock is now duplicated verbatim across four test files. When rspack v2 stable lands, all four need synchronised updates. A shared helper would eliminate drift risk. Fine as a follow-up issue/PR, but worth tracking now.

  2. CssExtractRspackPlugin mock scope inconsistency (inline comment on bundlerUtils.rspack.test.js): In bundlerUtils.rspack.test.js the constructor is created at factory-closure scope (singleton), while the identical mock in index.test.js creates it inside the if branch (fresh per call). Harmless today but can confuse future authors checking constructor call counts.

Informational:

  • ^2.0.0-0 peer dep range (inline on package.json): intentional for the beta period, but plan to tighten to ^2.0.0 after stable ships so users are not silently pulled onto future pre-releases.
  • Pinned beta in devDependencies (inline on docs/rspack.md): a tracking issue now would help ensure the pin is widened when 2.0.0 stable releases.
  • func-names ESLint disable missing in bundlerUtils.rspack.test.js: index.test.js got the disable added but this file did not. Currently lint-clean, worth noting if rule severity changes.
  • @rspack/plugin-react-refresh v2 gap: doc note is clear, but a linked issue would help users find it.
  • Integration test still pending in test plan - worth completing before marking ready for review.

@justin808 justin808 marked this pull request as ready for review March 16, 2026 04:15
@justin808 justin808 merged commit 2df4659 into main Mar 16, 2026
87 checks passed
@justin808 justin808 deleted the jg/rspack-v2-upgrade branch March 16, 2026 04:15
const CssExtractRspackPlugin = jest.fn(function (options) {
this.options = options
})
CssExtractRspackPlugin.loader = "css-extract-rspack-loader"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The CssExtractRspackPlugin constructor is created once at the module factory level (outside requireOrError), meaning the same mock instance is shared across all calls within this test file. If any test spies on or modifies this constructor, that state leaks to subsequent tests.

In contrast, rspack/index.test.js creates it fresh inside requireOrError on each call. Consider moving it inside the requireOrError callback here too, for consistency and to avoid potential test pollution.

Suggested change
CssExtractRspackPlugin.loader = "css-extract-rspack-loader"
return {
requireOrError: (moduleName) => {
if (moduleName === "@rspack/core") {
const CssExtractRspackPlugin = jest.fn(function (options) {
this.options = options
})
CssExtractRspackPlugin.loader = "css-extract-rspack-loader"
return {

this.options = options
})
CssExtractRspackPlugin.loader = "css-extract-rspack-loader"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The CssExtractRspackPlugin mock here is missing the .loader static property. getStyleRule.ts:29 accesses requireOrError("@rspack/core").CssExtractRspackPlugin.loader at runtime, so if any test in this file exercises the CSS style rule path, it'll get undefined as the loader string instead of a real value.

bundlerUtils.rspack.test.js correctly sets CssExtractRspackPlugin.loader = "css-extract-rspack-loader" — this mock should do the same.

Suggested change
CssExtractRspackPlugin.loader = "css-extract-rspack-loader"
return {

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 16, 2026

Greptile Summary

This PR adds rspack v2 support to Shakapacker by widening peer dependency ranges to accept both v1 (^1.0.0) and v2 (^2.0.0-0), pinning dev dependencies to 2.0.0-beta.6 for CI testing, and adding requireOrError mocks to two rspack test files so Jest can handle rspack v2's pure ESM exports. No source code changes are needed — all existing rspack APIs used by Shakapacker work identically in v2.

  • Peer deps: @rspack/core and @rspack/cli now accept ^1.0.0 || ^2.0.0-0; @rspack/plugin-react-refresh intentionally remains at ^1.0.0 (documented)
  • Test mocks: bundlerUtils.rspack.test.js and rspack/index.test.js now mock requireOrError to provide fake @rspack/core constructors, following the same pattern as the existing plugins.test.js and optimization.test.js files
  • Docs: New "Version Compatibility" section in docs/rspack.md with Node.js 20.19.0+ requirement for v2, CI coverage notes, and a "Why upgrade" feature list
  • Minor concern: The requireOrError mock in rspack/index.test.js creates new mock objects per call (inside the if branch), inconsistent with the stable-reference pattern used in bundlerUtils.rspack.test.js

Confidence Score: 4/5

  • This PR is safe to merge — it makes no source code changes, only widens peer deps and updates test mocks for rspack v2 ESM compatibility.
  • Score of 4 reflects: no production source code changes, well-documented backward compatibility, and the established mock pattern from existing test files. Deducted one point for the inconsistent mock structure between test files and the use of a beta dependency (2.0.0-beta.6) which the docs acknowledge should be revisited at stable release.
  • test/package/rspack/index.test.js has an inconsistent mock pattern compared to other test files that could cause confusion if tests are expanded.

Important Files Changed

Filename Overview
docs/rspack.md Adds a comprehensive "Version Compatibility" section documenting rspack v1/v2 support, Node.js requirements, and reasons to upgrade. Well-written and accurate.
package.json Updates peer deps to accept rspack v1 and v2, pins dev deps to 2.0.0-beta.6. React refresh plugin peer dep remains on v1 only, which is documented.
test/package/bundlerUtils.rspack.test.js Adds requireOrError mock for rspack v2 ESM compatibility. Mock is well-structured with CssExtractRspackPlugin defined at a stable scope. Updated assertions verify constructor behavior rather than just instanceof checks.
test/package/rspack/index.test.js Adds requireOrError mock for rspack v2 ESM compatibility. Contains duplicated mock logic that creates new mock objects per call, inconsistent with the bundlerUtils test mock structure.
yarn.lock Lock file updated to reflect rspack v2 beta dependencies. Removes rspack v1 transitive deps (module-federation packages) and adds v2 equivalents.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["package.json peerDeps"] -->|"^1.0.0 || ^2.0.0-0"| B{"@rspack/core version?"}
    B -->|v1 CJS| C["require() works natively"]
    B -->|v2 ESM| D{"Runtime environment?"}
    D -->|"Node 20.19.0+"| E["require() of ESM works natively"]
    D -->|"Jest CJS runtime"| F["requireOrError mock needed"]
    
    F --> G["bundlerUtils.rspack.test.js"]
    F --> H["rspack/index.test.js"]
    F --> I["rspack/plugins.test.js (existing)"]
    F --> J["rspack/optimization.test.js (existing)"]
    
    C --> K["No code changes needed"]
    E --> K
Loading

Last reviewed commit: eb3cb27

Comment on lines +33 to +71
jest.mock("../../../package/utils/requireOrError", () => ({
requireOrError: (moduleName) => {
if (moduleName === "@rspack/core") {
const CssExtractRspackPlugin = jest.fn(function (options) {
this.options = options
})
CssExtractRspackPlugin.loader = "css-extract-rspack-loader"

return {
DefinePlugin: jest.fn(function (definitions) {
this.definitions = definitions
}),
EnvironmentPlugin: jest.fn(function (env) {
this.env = env
}),
ProvidePlugin: jest.fn(function (definitions) {
this.definitions = definitions
}),
HotModuleReplacementPlugin: jest.fn(),
ProgressPlugin: jest.fn(),
CssExtractRspackPlugin,
SubresourceIntegrityPlugin: jest.fn(function (options) {
this.options = options
}),
SwcJsMinimizerRspackPlugin: jest.fn(),
LightningCssMinimizerRspackPlugin: jest.fn()
}
}
if (moduleName === "rspack-manifest-plugin") {
return {
RspackManifestPlugin: jest.fn(function (options) {
this.options = options
})
}
}
return jest
.requireActual("../../../package/utils/requireOrError")
.requireOrError(moduleName)
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Duplicated mock creates new objects per call

The requireOrError mock for "@rspack/core" creates new CssExtractRspackPlugin (and other constructor) instances on every invocation, since the factory is defined inline inside the if branch. Compare with bundlerUtils.rspack.test.js where CssExtractRspackPlugin is defined once outside the if block, so repeated calls to requireOrError("@rspack/core") return the same constructor reference.

This matters because the production code calls requireOrError("@rspack/core") multiple times (e.g. in bundlerUtils.ts:getBundler() and getCssExtractPlugin()). With this mock, each call gets a different CssExtractRspackPlugin constructor, so getCssExtractPlugin() and getBundler().CssExtractRspackPlugin would not be referentially equal. The tests happen to pass because none assert referential equality here, but this inconsistency between the two test files could cause confusing failures if tests are expanded later.

Consider hoisting the @rspack/core mock object outside the if branch (matching the pattern in bundlerUtils.rspack.test.js), or extracting a shared mock factory to reduce duplication across the three rspack test files that mock requireOrError.

}
if (moduleName === "rspack-manifest-plugin") {
return {
RspackManifestPlugin: jest.fn(function (options) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The @rspack/core mock is now duplicated across three test files (bundlerUtils.rspack.test.js, rspack/index.test.js, and rspack/plugins.test.js). Each one varies slightly (e.g., plugins.test.js throws on unknown modules and doesn't include DefinePlugin/ProvidePlugin; this file lacks the .loader property on CssExtractRspackPlugin).

Consider extracting a shared __mocks__/@rspack/core.js factory or a test/helpers/rspackCoreMock.js helper that all three files can import. This would make future plugin additions (or removals) a single-site change and prevent the current divergence from growing.

@@ -51,8 +51,8 @@
"devDependencies": {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pinning to an exact beta version (2.0.0-beta.6) is intentional and documented, which is good. Just a reminder that when rspack v2 hits stable, these two lines need a follow-up PR to either widen to ^2.0.0 or update to the stable release — there's no automated signal for that. Might be worth opening a tracking issue now so it doesn't get lost.

@claude
Copy link
Copy Markdown
Contributor

claude bot commented Mar 16, 2026

Review: Add rspack v2 support

The approach here is sound: accepting both v1 and v2 in peer deps, pinning CI devDeps to a beta, and mocking the ESM-only v2 in Jest tests is the right way to handle this. The docs section is clear and useful. A few things worth following up on:

Bugs / latent issues

Missing CssExtractRspackPlugin.loader in rspack/index.test.js: the mock omits the static .loader property that getStyleRule.ts:29 reads at runtime. bundlerUtils.rspack.test.js sets it correctly. Tests pass today because no current test in index.test.js exercises the CSS style-rule path, but this will fail silently if that coverage is added later. See inline comment: #975 (comment)

Maintainability

Duplicate @rspack/core mock in three test files: bundlerUtils.rspack.test.js, rspack/index.test.js, and the pre-existing rspack/plugins.test.js each inline their own version with small variations (different plugin sets, different fallback behaviour, missing .loader). A shared helper (e.g. test/helpers/rspackCoreMock.js) would make future plugin changes a single-site edit. See inline: #975 (comment)

CssExtractRspackPlugin instantiated at factory level in bundlerUtils.rspack.test.js: created once outside requireOrError, so the same mock object is shared across all calls in that file. rspack/index.test.js creates it fresh per call. Inconsistent; the shared instance could accumulate spy state across tests. See inline: #975 (comment)

Beta pin needs a follow-up issue: the docs note that 2.0.0-beta.6 should be revisited when stable ships, but there is no tracking mechanism. Worth opening an issue so it does not get forgotten. See inline: #975 (comment)

Minor

The test plan integration-test item (real Rails app with rspack v2) is still unchecked. Low risk given no source changes, but worth a follow-up post-merge.

justin808 added a commit that referenced this pull request Mar 16, 2026
Added entries for rspack v2 support (PR #975) and config exporter fixes (PR #914).
justin808 added a commit that referenced this pull request Mar 17, 2026
### Summary

Adds the v9.7.0 changelog section with release notes for all
user-visible changes since v9.6.1:

- **Added**: rspack v2 support (PR #975)
- **Fixed**: Config exporter path traversal and annotation format
validation (PR #914)
- **Fixed**: `webpack-subresource-integrity` v5 named export handling
(PR #978, fixes #972)

Version diff links at the bottom of the file are updated accordingly.

### Pull Request checklist

- [x] ~Add/update test to cover these changes~
- [x] ~Update documentation~
- [x] Update CHANGELOG file

### Other Information

Non-user-visible PRs (#920, #965, #970, #971, #977, #979, #981, #982)
were intentionally excluded per changelog policy.

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Low Risk**
> Documentation-only change updating `CHANGELOG.md`; no runtime code or
dependency changes are introduced in this PR.
> 
> **Overview**
> Adds a new `v9.7.0` section to `CHANGELOG.md` documenting user-visible
changes (rspack v2 support and two fixes around config export
security/validation and `webpack-subresource-integrity` v5 exports).
> 
> Updates the compare links at the bottom so `[Unreleased]` now compares
from `v9.7.0`, and adds the new `[v9.7.0]` tag link.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
8942a43. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **New Features**
  * Added rspack v2 support

* **Bug Fixes**
  * Improved security and validation handling

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Claude Opus 4.6 <[email protected]>
justin808 added a commit that referenced this pull request Mar 18, 2026
## Summary

- Accept both rspack v1 and v2 in peer deps (`^1.0.0 || ^2.0.0-0`) so
users aren't forced to upgrade rspack
- CI tests against rspack v2 beta (dev deps pinned to `2.0.0-beta.6`)
- Add `requireOrError` mocks to 2 rspack test files (Jest can't
`require()` rspack v2's pure ESM)
- Add version compatibility docs noting rspack v2 requires Node.js
20.19.0+
- **No source code changes** — shakapacker doesn't use any of the 30+
APIs removed/changed in v2

Closes #974

## Key details

**Pure ESM:** Rspack v2 ships as ESM-only. This works at runtime because
Node 20.19.0+ supports `require()` of ESM modules natively (rspack v2
itself requires Node 20.19.0+). Jest's CJS runtime can't handle this, so
tests mock `requireOrError` — the same pattern already used by other
rspack test files.

**No API changes needed:** `SubresourceIntegrityPlugin`,
`CssExtractRspackPlugin`, `SwcJsMinimizerRspackPlugin`,
`LightningCssMinimizerRspackPlugin`, `EnvironmentPlugin`,
`builtin:swc-loader` — all work identically in v2.

**Backward compatible:** Users on rspack v1 are unaffected. The peer dep
range accepts both `^1.0.0` and `^2.0.0-0`.

## Test plan

- [x] `yarn install` — no resolution errors
- [x] `yarn build` — TypeScript compilation succeeds
- [x] `yarn test` — 44 suites, 438 tests all passing
- [x] `yarn lint` — clean
- [ ] CI green
- [ ] Integration test with a real Rails app using rspack v2

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 4.6 <[email protected]>
justin808 added a commit that referenced this pull request Mar 18, 2026
### Summary

Adds the v9.7.0 changelog section with release notes for all
user-visible changes since v9.6.1:

- **Added**: rspack v2 support (PR #975)
- **Fixed**: Config exporter path traversal and annotation format
validation (PR #914)
- **Fixed**: `webpack-subresource-integrity` v5 named export handling
(PR #978, fixes #972)

Version diff links at the bottom of the file are updated accordingly.

### Pull Request checklist

- [x] ~Add/update test to cover these changes~
- [x] ~Update documentation~
- [x] Update CHANGELOG file

### Other Information

Non-user-visible PRs (#920, #965, #970, #971, #977, #979, #981, #982)
were intentionally excluded per changelog policy.

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Low Risk**
> Documentation-only change updating `CHANGELOG.md`; no runtime code or
dependency changes are introduced in this PR.
> 
> **Overview**
> Adds a new `v9.7.0` section to `CHANGELOG.md` documenting user-visible
changes (rspack v2 support and two fixes around config export
security/validation and `webpack-subresource-integrity` v5 exports).
> 
> Updates the compare links at the bottom so `[Unreleased]` now compares
from `v9.7.0`, and adds the new `[v9.7.0]` tag link.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
8942a43. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **New Features**
  * Added rspack v2 support

* **Bug Fixes**
  * Improved security and validation handling

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Claude Opus 4.6 <[email protected]>
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.

Add rspack v2 support

1 participant