fix(build): resolve non-hoisted SWC helpers#1994
Open
NathanDrake2406 wants to merge 1 commit into
Open
Conversation
commit: |
Pages Router builds failed when server-side page code required @swc/helpers and the package was not visible from the app root node_modules. Next.js does not rely on that hoisting; it aliases @swc/helpers/_ to an installed helper copy and bundles the helper. Resolve the helper package from the app, nested Next install, pnpm virtual store, or vinext package context, then add the equivalent Vite alias. Adjust the deploy-suite adapter to run npm-declared throwaway fixtures through its pnpm-owned install path and direct vinext binary calls so the upstream fixture reaches the runtime assertion. Regression coverage ports the upstream handle-non-hoisted-swc-helpers fixture and verifies the original upstream deploy-suite file.
80acf77 to
f791f43
Compare
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.
Overview
@swc/helperswithout an app-root helper install.@swc/helpers/_to a concrete installed helper package, including pnpm virtual-store layouts.packages/vinext/src/index.ts,tests/pages-router.test.ts,scripts/e2e-deploy.sh@swc/helpersvisible from their rootnode_modulesfor server page builds.Why
Next.js treats SWC helpers as framework-owned build/runtime helpers, not app-root dependencies. Its server externalization explicitly keeps
@swc/helpersbundled, and its compiler aliases@swc/helpers/_to an installed helper copy. Vinext already bundles server deps, but without the alias Vite/Rolldown resolvedrequire('@swc/helpers/_/_object_spread')from the page file and failed when the helper was not hoisted.handle-non-hoisted-swc-helpersPages Router fixture into vinext coverage.packageManagermetadata in temp apps and calls the linkedvinextbinary directly after install.What changed
getServerSidePropsrequires@swc/helpers/_/_object_spreadand helpers are not app-hoistedhello world.packageManager, orpnpm execrechecks deps after init mutations.Maintainer review path
packages/vinext/src/index.ts: reviewresolveSwcHelpersUnderscoreDir()and the@swc/helpers/_alias wiring.tests/pages-router.test.ts: review the ported fixture and assertion against the upstream Pages Router test.scripts/e2e-deploy.sh: review the temp manifest package-manager normalization and directnode_modules/.bin/vinextcalls.Validation
vp test run tests/pages-router.test.ts -t "non-hoisted SWC helpers"vp env exec --node 24 ./scripts/run-nextjs-deploy-suite.sh /Users/nathan/Projects/vinext/.refs/nextjs-v16.2.6 --retries 0 -c 1 --debug test/e2e/handle-non-hoisted-swc-helpers/index.test.tsvp fmt --check packages/vinext/src/index.ts tests/pages-router.test.tsvp check packages/vinext/src/index.ts tests/pages-router.test.tsbash -n scripts/e2e-deploy.shvp check --fix, full check, staged unit/integration tests, knipRisk / compatibility
@swc/helpers/_...specifiers that would otherwise fail or depend on hoisting.References
@swc/helpersshould not be externalized because hoisting cannot be relied on.@swc/helpers/_alias this PR mirrors for Vite.