Repository navigation
fix(vercel): resolve function runtime from package.json engines - #4768
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. |
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
commit: |
package.json engines
🔗 Linked issue
Resolves #4767
❓ Type of change
📚 Description
Building with
bun --bunwrotebun1.xto.vc-config.jsoneven whenpackage.jsonhadengines.node, because the Vercel preset never readpackage.json.The function runtime is now resolved in this order:
vercel.functions.runtimein the Nitro config.enginesinpackage.json.engines.nodepicks the newest supported Node.js major that intersects the range.engines.bunpicksbun1.4.xwhen the range requires Bun 1.4, otherwisebun1.x. When both are set, Bun is only used ifvercel.jsonalso setsbunVersion.bunVersioninvercel.json.Steps 2 and 3 match Vercel's
getNodeVersionandgetSupportedBunVersionin@vercel/build-utils(vercel/vercel#16685), including the warnings whenengines.nodewins over Bun. One difference: ifengines.nodematches no supported version, Nitro warns and falls back to step 4 instead of failing the build.semver(already a devDependency) is bundled and only loaded throughimport()when it's needed (17 kB).Behavior changes worth noting in the release notes:
nodejs22.x.enginesinpackage.jsonnow get the runtime Vercel would pick from it, instead of the one from the build runtime.engines.bunorbunVersion(e.g.2.x,latest) now fails the build with an error naming the source, as Vercel does. Previously anybunVersionvalue producedbun1.x.Docs (Vercel provider page) and the
runtimeJSDoc/type are updated. Unit tests intest/unit/vercel-runtime.test.tscover the resolver and thebuild:before→.vc-config.jsonpath, including thebunexport condition.📝 Checklist
🤖 Generated with AI assistant