feat: add node compatibility guard and lazy command loading for rspack#1397
Open
dannyhw wants to merge 2 commits into
Open
feat: add node compatibility guard and lazy command loading for rspack#1397dannyhw wants to merge 2 commits into
dannyhw wants to merge 2 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: 609ce32 The changes in this PR will be included in the next version bump. This PR includes changesets to release 6 packages
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 |
This was referenced Jul 6, 2026
dannyhw
commented
Jul 6, 2026
- unit-test ensureNodeSupportsRspack against mocked rspack/node versions, including the ^20.19.0 || >=22.12.0 range boundaries - assert the rspack commands module registers without loading @rspack/core (a throwing @rspack/core mock fails the suite on any eager load) - assert lazy bundle/start run the guard before importing the command modules and skip them entirely when the guard throws - lower dynamic import() to require() in the jest babel env only; published output keeps import() as-is
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Part of the Rspack 2 support effort — PR 2b of the stack, stacked on #1394 (
feat/rspack-2-foundations), so the diff against its base shows only this PR's changes.Rspack 2 is published as a pure ESM package with
engines.node: "^20.19.0 || >=22.12.0"— the Node versions where loading ESM throughrequire()is supported. On older Node versions, touching@rspack/corev2 crashes with an obscureERR_REQUIRE_ESM.This PR makes that failure mode actionable:
ensureNodeCompat.ts(new): raises a clearCLIError("Rspack X requires Node.js ^20.19.0 || >=22.12.0 — found Y. Upgrade Node.js or use @rspack/core@1 instead.") when the installed Rspack major is ≥ 2 and the current Node version is unsupported. Uses the version-detection helpers from feat: add rspack version detection helpers #1394, which resolve@rspack/core/package.jsonwithout importing the package — safe on any Node version.commands/rspack/index.ts: thestart/bundlecommand modules are now imported lazily inside the commandfuncs. The guard runs before@rspack/coreis touched, and loadingreact-native.config.jsno longer imports the bundler at all.profile/index.ts: refactored onto the shared version helper (getRspackVersion) instead of importingrspackVersionfrom@rspack/core— no behavior change; the version-routing logic is identical.start.tsandbundle.tsare untouched.The only user-visible change (the friendlier Node-version error) is covered by a patch changeset.
References
agent_context/rspackv2-jul2026/design.mdValidation
All run at the repo root on this branch (workspace catalog is still Rspack 1.x, as expected at this point in the stack):
pnpm install— cleanpnpm turbo run typecheck test --force— 17/17 tasks successful (packages/repackunit suite: 29 suites, 280 tests, 22 snapshots — all passing)pnpm lint:ci— clean (460 files, no fixes)