Skip to content

fix(dev): keep server-resolved packages out of every dep optimizer - #3235

Open
JamesbbBriz wants to merge 4 commits into
cloudflare:mainfrom
JamesbbBriz:fix/known-interop-optimizer-excludes
Open

JamesbbBriz wants to merge 4 commits into
cloudflare:mainfrom
JamesbbBriz:fix/known-interop-optimizer-excludes

Conversation

@JamesbbBriz

@JamesbbBriz JamesbbBriz commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Two gaps let Node-oriented packages break the dev server when reached through server code:

  • file-type uses conditional exports: its Node entry exposes APIs such as fileTypeFromFile, while its default core.js entry does not. When the dependency optimizer reaches it through packages such as Payload, Rolldown can select core.js and fail with MISSING_EXPORT. Runtime resolution selects the correct entry, so file-type is now excluded from pre-bundling.
  • Packages listed in serverExternalPackages are runtime-resolved, but were not excluded consistently from dependency optimization. App Router RSC/SSR/client optimizers and Pages Router client/SSR/Cloudflare Worker optimizers now all preserve that invariant.

Regression coverage checks both App and Pages Router optimizer configurations, including the Cloudflare Pages Router Worker environment. This follows Next.js's coverage of serverExternalPackages in both App and Pages Router applications.

Validation:

  • vp test run tests/build-optimization.test.ts — 170 passed, 2 skipped
  • vp check packages/vinext/src/index.ts packages/vinext/src/plugins/rsc-client-shim-excludes.ts tests/build-optimization.test.ts
  • vp run vinext#build

Fixes #3236

Two gaps let node-shaped packages break the dev server when they were
reached through server code:

- file-type ships a dual CJS/ESM package. When any optimizer pre-bundles
  it (Payload reaches it through payload/dist/uploads), Rolldown resolves
  the core entry and loses the named exports — MISSING_EXPORT on
  fileTypeFromFile and friends, and the dev server dies. The runtime
  resolvers load it fine, so it now joins the shared exclude list.
- server-external packages were excluded from the client optimizer but
  not from the rsc/ssr optimizers, even though the server environments
  already load them through the runtime resolver. Their node-only
  conditional exports resolve to the wrong entry inside the optimizer
  pipeline, so the rsc and ssr excludes now mirror the client one.

The app-router dev-server regression surface is covered by asserting all
three optimizers exclude both the server-external entries and file-type.
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@pkg-pr-new

pkg-pr-new Bot commented Sep 11, 2026

Copy link
Copy Markdown

Open in StackBlitz

@vinext/cloudflare

npm i https://pkg.pr.new/@vinext/cloudflare@3235

create-vinext-app

npm i https://pkg.pr.new/create-vinext-app@3235

@vinext/types

npm i https://pkg.pr.new/@vinext/types@3235

vinext

npm i https://pkg.pr.new/vinext@3235

@cloudflare/workers-response-store

npm i https://pkg.pr.new/@cloudflare/workers-response-store@3235

commit: 095b35a

@github-actions

github-actions Bot commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Performance benchmarks

Compared b40c901 against base 13e7d9c using alternating same-runner rounds. Next.js was unchanged and skipped.

0 improved · 0 regressed · 6 within ±1.5%

Scenario Framework Baseline Current Change
Client bundle size (gzip) vinext 142.4 KB 142.4 KB ⚫ +0.0%
Client entry size (gzip) vinext 129.7 KB 129.7 KB ⚫ +0.0%
Dev server cold start vinext 3.23 s 3.20 s ⚫ -0.8%
Production build time vinext 3.41 s 3.41 s ⚫ -0.0%
RSC entry closure size (gzip) vinext 125.4 KB 125.5 KB ⚫ +0.0%
Server bundle size (gzip) vinext 216.1 KB 216.1 KB ⚫ +0.0%

View detailed results and traces

🟢 improvement · 🔴 regression · ⚫ change below 1.5% · paired base/head

@james-elicx

Copy link
Copy Markdown
Member

/bigbonk review for issues

Time limit: 8 minutes. Complete the review and post all findings within that limit.

Comment thread packages/vinext/src/index.ts
@ask-bonk

ask-bonk Bot commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Posted 1 actionable inline review finding. Targeted tests pass.

github run

@james-elicx

Copy link
Copy Markdown
Member

/bigbonk review for issues

Time limit: 8 minutes. Complete the review and post all findings within that limit.

@ask-bonk

ask-bonk Bot commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

LGTM!

github run

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.

Dev server dies with MISSING_EXPORT when server code pulls in file-type; serverExternalPackages not honored by rsc/ssr dep optimizers

2 participants