[builders] Fix .ts extension rewrite regression for non-vitest frameworks#1560
[builders] Fix .ts extension rewrite regression for non-vitest frameworks#1560VaguelySerious merged 1 commit intomainfrom
Conversation
🦋 Changeset detectedLatest commit: 5684a31 The changes in this PR will be included in the next version bump. This PR includes changesets to release 16 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 |
📊 Benchmark Results
workflow with no steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Express | Nitro | Next.js (Turbopack) workflow with 1 step💻 Local Development
▲ Production (Vercel)
🔍 Observability: Nitro | Next.js (Turbopack) | Express workflow with 10 sequential steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Express | Nitro | Next.js (Turbopack) workflow with 25 sequential steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Express | Nitro | Next.js (Turbopack) workflow with 50 sequential steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Nitro | Express | Next.js (Turbopack) Promise.all with 10 concurrent steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Next.js (Turbopack) | Nitro | Express Promise.all with 25 concurrent steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Next.js (Turbopack) | Express | Nitro Promise.all with 50 concurrent steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Nitro | Next.js (Turbopack) | Express Promise.race with 10 concurrent steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Next.js (Turbopack) | Express | Nitro Promise.race with 25 concurrent steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Nitro | Next.js (Turbopack) | Express Promise.race with 50 concurrent steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Nitro | Express | Next.js (Turbopack) workflow with 10 sequential data payload steps (10KB)💻 Local Development
▲ Production (Vercel)
🔍 Observability: Nitro | Express | Next.js (Turbopack) workflow with 25 sequential data payload steps (10KB)💻 Local Development
▲ Production (Vercel)
🔍 Observability: Express | Next.js (Turbopack) | Nitro workflow with 50 sequential data payload steps (10KB)💻 Local Development
▲ Production (Vercel)
🔍 Observability: Express | Next.js (Turbopack) | Nitro workflow with 10 concurrent data payload steps (10KB)💻 Local Development
▲ Production (Vercel)
🔍 Observability: Next.js (Turbopack) | Nitro | Express workflow with 25 concurrent data payload steps (10KB)💻 Local Development
▲ Production (Vercel)
🔍 Observability: Nitro | Express | Next.js (Turbopack) workflow with 50 concurrent data payload steps (10KB)💻 Local Development
▲ Production (Vercel)
🔍 Observability: Express | Nitro | Next.js (Turbopack) Stream Benchmarks (includes TTFB metrics)workflow with stream💻 Local Development
▲ Production (Vercel)
🔍 Observability: Nitro | Next.js (Turbopack) | Express stream pipeline with 5 transform steps (1MB)💻 Local Development
▲ Production (Vercel)
🔍 Observability: Next.js (Turbopack) | Nitro | Express 10 parallel streams (1MB each)💻 Local Development
▲ Production (Vercel)
🔍 Observability: Nitro | Express | Next.js (Turbopack) fan-out fan-in 10 streams (1MB each)💻 Local Development
▲ Production (Vercel)
🔍 Observability: Next.js (Turbopack) | Express | Nitro 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🌍 Community Worlds (58 failed)mongodb (2 failed):
redis (2 failed):
turso (54 failed):
Details by Category✅ ▲ Vercel Production
✅ 💻 Local Development
✅ 📦 Local Production
✅ 🐘 Local Postgres
✅ 🪟 Windows
❌ 🌍 Community Worlds
✅ 📋 Other
|
The .ts→.js extension rewrite introduced in #1524 was applied unconditionally to all externalized step imports. This breaks Next.js and other framework builds where the downstream bundler (webpack, Vite) resolves .ts natively and the .js file doesn't exist on disk. Add `rewriteTsExtensions` option to SwcPluginOptions so each builder can opt in. Only the vitest builder enables it, since it loads bundles via Node's native ESM loader which requires .js. Fixes #1555 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Peter Wielander <mittgfu@gmail.com>
3b975fa to
5684a31
Compare
TooTallNate
left a comment
There was a problem hiding this comment.
Clean, well-scoped fix. The regression is real (unconditional .ts→.js rewrite broke downstream bundlers that resolve .ts natively), and the approach — making it opt-in via rewriteTsExtensions — is the right call.
What I verified:
- The regex chain (
.tsx?$→.js,.mts$→.mjs,.cts$→.cjs) is correct — the three patterns are mutually exclusive and properly$-anchored. - All 8
createStepsBundlecall sites across the codebase were checked: onlyVitestBuilderpassesrewriteTsExtensions: true, which is correct since it's the only builder whose output is consumed directly by Node's native ESM loader. - The
NextDeferredBuilderdoesn't callcreateStepsBundleat all (it has its ownbuildStepsFunction), so it's unaffected. - Test coverage is solid: parameterized tests for all four TS extensions (
.ts,.tsx,.mts,.cts) in both the rewrite-enabled and default-preserved paths. - All CI checks pass. The community world (Turso) failures in the E2E comment appear to be pre-existing/infra-related, not caused by this change.
- JSDoc on the new option is clear and explains the "why" well.
- Changeset is present and correctly scoped to
@workflow/buildersonly.
LGTM.
Summary
Closes #1555
.ts → .jsextension rewrite for externalized step imports (introduced in Support projects with Node.js step dependencies in vitest plugin #1524) was applied unconditionally to all framework builders.tsnatively — the rewritten.jsfile doesn't exist on diskrewriteTsExtensionsoption toSwcPluginOptions, only enabled in the vitest builder where Node's native ESM loader requires.jsextensionsTest plan
rewriteTsExtensions: truetests pass (vitest behavior preserved).tsextensions are preserved by default (Next.js behavior)🤖 Generated with Claude Code