fix(build): honor project Babel configs#2360
Conversation
|
/bigbonk review for issues |
commit: |
|
|
/bigbonk review for issues |
|
/bigbonk review for issues |
|
@james-elicx Bonk workflow was cancelled. View workflow run · To retry, trigger Bonk again. |
|
/bigbonk review for issues |
|
|
Review posted to PR #2360. Summary of findings: Review SummaryThe PR's core approach is correct and matches Next.js's actual Babel loader well. The config-file selection ordering (after commit 263cb3d) exactly matches Next.js's Issues flagged:
Plus a non-blocking parity note that Next.js's per-file plugins ( I verified the test passes and lint is clean on the new file. |
|
/bigbonk review for issues |
Performance benchmarksCompared 0 improved · 0 regressed · 6 within ±1.5%
View detailed results and traces 🟢 improvement · 🔴 regression · ⚫ change below 1.5% · paired base/head |
|
|
Review posted to PR #2360. SummaryThe author already addressed all of the prior Remaining items I flagged (all non-blocking):
Verified correct: config-file ordering matches Next.js |
|
/bigbonk review for issues |
|
/bigbonk review for issues |
|
|
Review posted to PR #2360. SummaryRe-reviewed at Verified correct (the new code the prior bonk reviews didn't cover):
Items flagged (all non-blocking):
Plus the pre-existing |
|
/bigbonk review for issues |
|
|
Review posted to PR #2360. SummaryRe-reviewed at All previously-flagged carry-over items are now resolved:
Plus Verified correct: config-file ordering matches Next.js Only remaining item (non-blocking): a subtle canonical/non-canonical path mix in the node_modules gate — internally consistent (no correctness bug), worth a clarifying comment. Plus the pre-existing Nothing blocks the merge. |
|
/bigbonk review for issues |
|
/bigbonk review for issues |
|
Review posted to PR #2360. SummaryRe-reviewed at New commit verified correct:
Items flagged:
Plus carried-over non-blocking notes (canonical/non-canonical path mix needing a comment; Everything from prior passes re-verified clean. The new commit improves parity; items 1–2 are the ones worth a decision before merge. |
|
/bigbonk review for issues |
|
/bigbonk review for issues |
|
|
Review posted to PR #2360. SummaryRe-reviewed at All three prior findings are now resolved, verified against Next 16.2.7's actual
One item worth a human decision (not blocking): possible double react-refresh injection in dev — the flip side of the fast-refresh fix. The Babel plugin ( Plus minor non-blocking notes (the Nothing blocks the merge. |
|
/bigbonk review for issues |
|
|
Review posted to PR #2360. SummaryRe-reviewed at Both new commits verified correct:
Non-blocking items (carried over, unchanged this pass): possible dev double react-refresh injection (prod-only tests can't cover it — worth a manual Nothing blocks the merge. |
|
/bigbonk review for issues |
|
/bigbonk review for issues |
|
|
Review posted to PR #2360. SummaryRe-reviewed at Both new commits verified correct:
Both move toward Next parity (Next skips generation when Items flagged (all non-blocking):
Plus carried-over notes: the dev double-refresh question (prod-only tests can't cover it), the canonical/non-canonical path-mix comment, and the pre-existing |
|
/bigbonk review for issues |
|
|
Review posted to PR #2360. SummaryRe-reviewed at Two newly-surfaced items the prior 9 passes missed:
Verified correct (re-confirmed against the installed Carried over (non-blocking): the dev double-refresh interaction (prod-only tests can't cover it — manual The only newly actionable item is #1 (a small perf fix). Nothing blocks the merge. |
|
/bigbonk review for issues |
2 similar comments
|
/bigbonk review for issues |
|
/bigbonk review for issues |
There was a problem hiding this comment.
/bigbonk re-review — PR #2360 (honor project Babel configs)
Re-reviewed at 6c2c399 ("perf(build): avoid unused Babel options"), the one new commit since the last bonk pass at 7c8ef94. It directly fixes the hot-path allocation flagged as the only actionable item last pass. I re-ran vp check on all four changed source files (clean), the Babel feature test (honors a project Babel config before the JSX transform — passes), and the loadableGenerated cases (6 pass).
Previously flagged → now resolved
Per-transform allocation on the no-Babel-config common path — fixed in 6c2c399. transform.handler now bails on !configPath || id.startsWith("\0") || isViteSpecialQuery(id) before calling getOptions() (babel-config.ts:155-159), so the getOptions() factory — which spreads turbopackTranspilePackages + optimizePackageImports into a fresh array on every call (index.ts:1192-1195) — no longer runs for the ~all users who have no Babel config. getOptions() has no side effects and forceSwcTransforms is still checked immediately after, so behavior is unchanged. Pure perf win, matches AGENTS.md "avoid repeated hot-path work."
Minor / non-blocking (carried over)
-
No positive overwrite test for the Next
modulesbinary-expression form.isNextBabelModuleElement(dynamic-preload-metadata.ts:572-579) detects Next's dev/server react-loadable shape (t.binaryExpression('+', t.stringLiteral("<path> -> "), node)), but the test suite only preserves a non-Nextprefix + "x"expression — there's no test that overwrites a genuine["<path> -> ./x"]form and strips it. Thewebpackform has both preserve and overwrite tests; themodulesform is missing the overwrite half. Cheapest follow-up to close the symmetry and guard the dev/server branch against regression. -
Possible double react-refresh injection in dev (from
8cb7054): the Babel plugin (enforce: "pre") injectsnext/dist/compiled/react-refresh/babelwhenisDev && !isServer(:215-218), then@vitejs/plugin-react(next in the array,index.ts:1198) runs its own OXC refresh pass over the Babel output. Next has a single transform so this can't arise there. All the new tests are production-only (build(...),isDevfalse), so neither the fast-refresh fix nor this interaction is exercised by CI — a manualvp devsmoke test of a fixture with.babelrc+ a client component (confirm HMR not full reload, no duplicate$RefreshReg$errors) remains the one path tests can't cover. -
Canonical/non-canonical path mix in the node_modules gate (
babel-config.ts:163-183):isProjectFileusescanonicalFilename, the node_modules exclusion usesnormalizedFilename(non-canonical),isPathInPackageuses rawfilename. Internally consistent (literal-path heuristics paired with therelativeWithinRoot(packageRoot, canonicalFilename)realpath fallback) — no correctness bug, a one-line comment would help future readers. -
process.browserstill isn't replaced via this Babel path (Next injectstransform-defineper file). Pre-existing; flagging only so it isn't assumed closed here.
Re-verified clean at this SHA
- Config-file ordering (
BABEL_CONFIG_FILES) matches Next'sgetBabelConfigFile;babelrc: false+ explicitconfigFilemirrors the loader. forceSwcTransformsshort-circuits the transform (:159); thetranspilePackagesopt-in uses raw+geist+optimizePackageImportsmatching Next'sfinalTranspilePackages, andincludeExternalDirscorrectly keys off rawtranspilePackages.serverTarget → "webworker"for Cloudflare matches Next's edge compiler target; client stays"web".resolvePackageRootviarequire.resolve.paths()handles symlinked/junctionednode_modulesand transpiled-only packages.tryRealpathSync/relativeWithinRoothardening, canonical watcher candidates, and the@babel/core→next/dist/compiled/babel/corefallback with the corrected error message are all in place.loadableGeneratedfingerprint correctly overwrites the genuinerequire.resolveWeak/" -> "Next forms and preserves user-authoredwebpack: () => [...]/prefix + "x"metadata.
Bottom line: the new commit resolves the last actionable finding. Item 1 (an overwrite test for the modules form) is the cheapest remaining follow-up; the dev double-refresh interaction is still the one path the prod-only tests can't cover. Nothing blocking.
|
Review posted to PR #2360. SummaryRe-reviewed at The prior pass's only actionable finding is now resolved:
Items flagged (all non-blocking, mostly carried over):
Re-verified correct against Next 16.2.7: config-file ordering, Nothing blocks the merge. |
Summary
transpilePackages,experimental.externalDir, andexperimental.forceSwcTransformsParity
Fixes the failure in Next.js v16.2.6
test/e2e/babel/index.test.tswhere Flow syntax configured through.babelrcwas rejected by vinext'sjsx-in-jstransform before Babel could strip it.Next.js references:
packages/next/src/build/webpack-config.tspackages/next/src/build/babel/loader/get-config.tstest/e2e/babel/index.test.tsValidation
vp test run tests/pages-router.test.ts -t "honors a project Babel config"vp check packages/vinext/src/plugins/babel-config.ts packages/vinext/src/config/next-config.ts packages/vinext/src/index.ts tests/pages-router.test.tsENOSPCbefore assertionsDocumentation
No documentation change is required: this restores compatibility with existing Next.js Babel configuration behavior and adds no vinext-specific public API.