Skip to content

fix: preserve Next package boundary in node functions#63

Open
privatenumber wants to merge 1 commit into
nextjs:mainfrom
privatenumber:hiroki/fix-next-package-boundary
Open

fix: preserve Next package boundary in node functions#63
privatenumber wants to merge 1 commit into
nextjs:mainfrom
privatenumber:hiroki/fix-next-package-boundary

Conversation

@privatenumber

@privatenumber privatenumber commented May 5, 2026

Copy link
Copy Markdown

Problem

Next 16.2 emits Node route files under .next/server as CommonJS and writes .next/package.json with type commonjs. The adapter records that file in filePathMap, but the generated function directory does not physically contain it, so Node can fall through to an app/root package.json with type module and fail when ___next_launcher.cjs requires the route file.

Fixes vercel/next.js#91661.

Changes

  • Copy generated .next/package.json into each Node function when present.
  • Add a handleNodeOutputs regression test.
  • Add the missing Vitest dependency and use vitest run.

@vercel

vercel Bot commented May 5, 2026

Copy link
Copy Markdown

@privatenumber is attempting to deploy a commit to the vtest314-next-adapter-e2e-tests Team on Vercel.

A member of the Team first needs to authorize it.

@changeset-bot

changeset-bot Bot commented May 5, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 63d7965

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@next-community/adapter-vercel Patch

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

@privatenumber

Copy link
Copy Markdown
Author

Context for reviewers: this seems related to the Next 16.2 adapter rollout in vercel/next.js#88247 and #6. cc @ijjk in case you have useful context on the intended packaging invariant here. The important bit for this PR is that the generated .next/package.json package boundary is referenced in filePathMap but also needs to be present on disk for Node module type resolution.

@privatenumber privatenumber force-pushed the hiroki/fix-next-package-boundary branch 3 times, most recently from 0315dfc to 43fb5a2 Compare May 5, 2026 16:32
@privatenumber privatenumber marked this pull request as ready for review May 5, 2026 17:15
@privatenumber privatenumber force-pushed the hiroki/fix-next-package-boundary branch 2 times, most recently from dffd51b to 8fd97fb Compare May 5, 2026 17:19
@privatenumber privatenumber force-pushed the hiroki/fix-next-package-boundary branch from 8fd97fb to 63d7965 Compare May 5, 2026 18:57
@timneutkens

Copy link
Copy Markdown
Collaborator

This needs to be fixed in Next.js instead. Opened the PR here: vercel/next.js#93612

@timneutkens

Copy link
Copy Markdown
Collaborator

Merged vercel/next.js#93612

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ERR_REQUIRE_ESM on Vercel runtime with "type": "module" monorepo — build succeeds, fails at runtime

2 participants