[vitest] Fix local imports failing to load in test step bundles#2351
[vitest] Fix local imports failing to load in test step bundles#2351VaguelySerious wants to merge 1 commit into
Conversation
🦋 Changeset detectedLatest commit: 5b3b22d The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
📊 Benchmark Results
workflow with no steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Nitro | Next.js (Turbopack) workflow with 1 step💻 Local Development
▲ Production (Vercel)
🔍 Observability: Next.js (Turbopack) | Nitro workflow with 10 sequential steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Nitro | Next.js (Turbopack) workflow with 25 sequential steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Next.js (Turbopack) | Nitro workflow with 50 sequential steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Nitro | Next.js (Turbopack) Promise.all with 10 concurrent steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Nitro | Next.js (Turbopack) Promise.all with 25 concurrent steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Nitro | Next.js (Turbopack) Promise.all with 50 concurrent steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Nitro | Next.js (Turbopack) Promise.race with 10 concurrent steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Next.js (Turbopack) | Nitro Promise.race with 25 concurrent steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Next.js (Turbopack) | Nitro Promise.race with 50 concurrent steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Next.js (Turbopack) | Nitro workflow with 10 sequential data payload steps (10KB)💻 Local Development
▲ Production (Vercel)
🔍 Observability: Nitro | Next.js (Turbopack) workflow with 25 sequential data payload steps (10KB)💻 Local Development
▲ Production (Vercel)
🔍 Observability: Nitro | Next.js (Turbopack) workflow with 50 sequential data payload steps (10KB)💻 Local Development
▲ Production (Vercel)
🔍 Observability: Nitro | Next.js (Turbopack) workflow with 10 concurrent data payload steps (10KB)💻 Local Development
▲ Production (Vercel)
🔍 Observability: Nitro | Next.js (Turbopack) workflow with 25 concurrent data payload steps (10KB)💻 Local Development
▲ Production (Vercel)
🔍 Observability: Nitro | Next.js (Turbopack) workflow with 50 concurrent data payload steps (10KB)💻 Local Development
▲ Production (Vercel)
🔍 Observability: Nitro | Next.js (Turbopack) Stream Benchmarks (includes TTFB metrics)workflow with stream💻 Local Development
▲ Production (Vercel)
🔍 Observability: Nitro | Next.js (Turbopack) stream pipeline with 5 transform steps (1MB)💻 Local Development
▲ Production (Vercel)
🔍 Observability: Nitro | Next.js (Turbopack) 10 parallel streams (1MB each)💻 Local Development
▲ Production (Vercel)
🔍 Observability: Nitro | Next.js (Turbopack) fan-out fan-in 10 streams (1MB each)💻 Local Development
▲ Production (Vercel)
🔍 Observability: Next.js (Turbopack) | Nitro SummaryFastest Framework by WorldWinner determined by most benchmark wins
Fastest World by FrameworkWinner determined by most benchmark wins
Column Definitions
Worlds:
❌ Some benchmark jobs failed:
Check the workflow run for details. |
🧪 E2E Test Results✅ All tests passed Summary
Details by Category✅ ▲ Vercel Production
✅ 💻 Local Development
✅ 📦 Local Production
✅ 🐘 Local Postgres
✅ 🪟 Windows
✅ 📋 Other
|
The vitest builder's generated bundles are imported directly by Node in the test worker, with no downstream bundler. Externalized project-local imports therefore surface as raw .ts specifiers that Node's native ESM loader cannot reliably load (only erasable syntax via type stripping, and not at all for extensionless transitive imports). Enable bundleTransitiveLocalStepDependencies (added for the same direct-loading situation in Nitro dev, #1965) so local helpers are inlined into the step bundle. Fixes #2289 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
6ad3402 to
5b3b22d
Compare
Closes #2289
Problem
The vitest builder's generated bundles (
combined.mjs/__step_registrations.mjs) are imported directly by Node's native ESM loader in the test worker — there is no downstream bundler. Project-local imports of step files were externalized, so the bundle referenced raw.tssources on disk. Node can only load those via type stripping (erasable syntax only, recent Node versions), and transitive extensionless imports inside such files fail outright:enumfails withERR_UNSUPPORTED_TYPESCRIPT_SYNTAXERR_MODULE_NOT_FOUND.ts→.jsrewrite makes every externalized local import fail withERR_MODULE_NOT_FOUND(or load a stale compiled.jsneighbor)Fix
Enable
bundleTransitiveLocalStepDependenciesin the vitest builder, the option introduced for the identical direct-runtime-loading situation in Nitro dev (#1965). Project-local files imported by step entries are now inlined into the step bundle; npm packages stay external, sovi.mock()of third-party packages keeps working (covered by existingworkbench/vitestmock tests).Tests
workbench/vitest: newlocal-deps.test.tsruns a workflow whose body and step use a local.tshelper with an enum, and asserts the helper is inlined into the generated step bundle rather than externalized. The bundle-content assertion is the regression guard: in the workbench the bundles happen to load through vitest's module runner (workspace symlinks), which masks the runtime failure that real app installs hit.packages/vitest: unit test asserts the builder passes the flag.🤖 Generated with Claude Code