Repository navigation
presets(vercel): resolve function runtime from package.json engines - #4768
everton-dgn wants to merge 3 commits into
Conversation
Check engines in package.json before bunVersion in vercel.json and the runtime running the build, with Vercel's precedence: engines.node or engines.bun first, and bun only with bunVersion when both are set. engines.node picks the newest supported Node.js version whose range intersects it, and a range with no match warns and falls back to the build's Node.js major. Drop Node 20, which Vercel discontinued, from the supported versions and the runtime type suggestions. Bun builds now honor engines.node unless both engines and bunVersion select Bun.
|
@everton-dgn is attempting to deploy a commit to the Nitro Team on Vercel. A member of the Team first needs to authorize it. |
|
Important Review skippedReview was skipped as selected files did not have any reviewable changes. ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
commit: |
🔗 Linked issue
Resolves #4767
❓ Type of change
📚 Description
Building with
bun --bunwrotebun1.xto.vc-config.jsoneven whenpackage.jsonhadengines.node, becauseresolveVercelRuntimenever readpackage.json. It now checksvercel.functions.runtime, thenenginesinpackage.json, thenbunVersioninvercel.json, then the runtime running the build. The two middle steps follow the precedence of Vercel'sgetNodeVersion(vercel/vercel#16685), including Bun only withbunVersionwhen both engines are set. Whenengines.nodeoverridesengines.bunorbunVersion, it warns, as Vercel does.engines.nodepicks the newest supported Node.js version whoseN.xintersects the range, with semverintersectslike Vercel, so>=24.20.0 <25and>=22.0.0givenodejs24.xand>=20 <24givesnodejs22.x.semverwas already a devDependency. It is loaded withimport()only whenengines.nodeis set (17 kB, 5 kB gzip).Where it differs from Vercel: a range with no supported match (
20.x,18.x,>=26,lts/*) logs a warning and uses the build's Node.js major instead of failing the build. That holds when building with Bun too, sinceengines.nodeasks for Node.Node 20 is dropped from
SUPPORTED_NODE_VERSIONS, like #3572 did for 18, and theruntimetype now suggestsnodejs22.xandnodejs24.x. Vercel discontinued 20 on 2026-10-01 and the page linked above the list only shows 22.x and 24.x. Keeping it would makeengines.node: "20.x"emitnodejs20.x. A build running on Node 20 now maps tonodejs22.x. I can move this to its own PR if you prefer.Output changes only for projects that declare
engines, build with Bun, or build on Node 20; #4767 lists each case. I left "Breaking change" unticked for that reason, but I'm fine with either label.The provider docs and the
runtimeJSDoc now describe this order.Tested with:
test/unit/vercel-runtime.test.ts(new): 20 cases, 13 of them fail onmain. Besides the resolver, it runs the preset'sbuild:beforehook throughcreateNitroand checks the runtime written to.vc-config.jsonand thebunexport condition.engines.node: ">=24.20.0 <25"built withbun --bun:bun1.xwith 3.0.260903-beta,nodejs24.xwith this branch.pnpm lint,pnpm typecheck,pnpm test:rollupandpnpm test:rolldown, plus the CI variant of the rollup job withscripts/vite7.ts. I ran the tests withTZ=UTCand aTMPDIRoutside/var, because on my macOS machinefmtDateand twodev-error-stacktests fail onmaintoo (local timezone and the/varsymlink).📝 Checklist