fix(builders): Inline Next.js pseudo‑packages and strip server-only/client-only requires in workflow bundles#911
Conversation
🦋 Changeset detectedLatest commit: db87cf6 The changes in this PR will be included in the next version bump. This PR includes changesets to release 13 packages
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 |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📊 Benchmark Results
workflow with no steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Express workflow with 1 step💻 Local Development
▲ Production (Vercel)
🔍 Observability: Express workflow with 10 sequential steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Express Promise.all with 10 concurrent steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Express Promise.all with 25 concurrent steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Express Promise.race with 10 concurrent steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Express Promise.race with 25 concurrent steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Express Stream Benchmarks (includes TTFB metrics)workflow with stream💻 Local Development
▲ Production (Vercel)
🔍 Observability: Express SummaryFastest Framework by WorldWinner determined by most benchmark wins
Fastest World by FrameworkWinner determined by most benchmark wins
Column Definitions
Worlds:
|
🧪 E2E Test Results❌ Some tests failed Summary
❌ Failed Tests▲ Vercel Production (1 failed)example (1 failed):
🌍 Community Worlds (161 failed)mongodb (40 failed):
redis (40 failed):
starter (41 failed):
turso (40 failed):
Details by Category❌ ▲ Vercel Production
✅ 💻 Local Development
✅ 📦 Local Production
✅ 🐘 Local Postgres
✅ 🪟 Windows
❌ 🌍 Community Worlds
✅ 📋 Other
|
Description
This PR fixes the Turbopack build regression caused by dynamic
require()of Next.js marker packages (server-only/client-only) leaking into workflow/step bundles. In the workflow VM,require/import()isn’t available, so any externalized or dynamically required module breaks during page data collection.What changed
server-only/client-onlyas pseudo‑packages and replace them with empty modules during bundling.externalhandling for workflow bundles to avoid generatingrequire()calls in the VM.require('server-only'|'client-only')in the SWC/esbuild plugin input before transform.Why this is needed
Upgrading to newer workflow versions started passing
tsconfigto esbuild, which surfaced dynamicrequire('server-only')from aliased imports in large Next apps. Because workflow bundles run in a VM withoutrequire, any externalized or dynamic require caused a runtime crash during Next build.Trade‑off: filtering vs rewriting
I tried tsconfig path filtering to prevent aliases that resolve outside the app root from being bundled. That blocked the regression, but it broke valid local development setups (workbench + repo‑level aliasing) by removing legitimate aliases like
@repo/*.I chose rewriting instead:
tsconfig.pathssupport (no breakage for workbench or monorepo aliases).server-only/client-onlyshims) and removes the offendingrequire()calls.require()patterns; those will still fail (which is desirable and still surfaced by the build).Tests
packages/builders/src/pseudo-package-esbuild-plugin.test.ts