feat(nitro): forward externals.external to workflow builder#1844
Conversation
Nitro users can declare packages as externals via
`externals: { external: ['fsevents'] }` in `nitro.config.ts`. Previously
the workflow SDK's step/workflow/webhook bundles were built in isolation
and ignored that config, forcing users to either patch the Nitro adapter
or ship a custom builder (as in the 250MB bundle-size workaround gist).
Forward string entries from `nitro.options.externals.external` to the
builder's esbuild `external` option. Only string entries are forwarded
— RegExp and function matchers aren't supported by esbuild's
`external` API, so those are skipped.
🦋 Changeset detectedLatest commit: e523cb4 The changes in this PR will be included in the next version bump. This PR includes changesets to release 17 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 |
🧪 E2E Test Results✅ All tests passed Summary
Details by Category✅ ▲ Vercel Production
✅ 💻 Local Development
✅ 📦 Local Production
✅ 🐘 Local Postgres
✅ 🪟 Windows
✅ 📋 Other
|
📊 Benchmark Results
workflow with no steps💻 Local Development
workflow with 1 step💻 Local Development
workflow with 10 sequential steps💻 Local Development
workflow with 25 sequential steps💻 Local Development
workflow with 50 sequential steps💻 Local Development
Promise.all with 10 concurrent steps💻 Local Development
Promise.all with 25 concurrent steps💻 Local Development
Promise.all with 50 concurrent steps💻 Local Development
Promise.race with 10 concurrent steps💻 Local Development
Promise.race with 25 concurrent steps💻 Local Development
Promise.race with 50 concurrent steps💻 Local Development
workflow with 10 sequential data payload steps (10KB)💻 Local Development
workflow with 25 sequential data payload steps (10KB)💻 Local Development
workflow with 50 sequential data payload steps (10KB)💻 Local Development
workflow with 10 concurrent data payload steps (10KB)💻 Local Development
workflow with 25 concurrent data payload steps (10KB)💻 Local Development
workflow with 50 concurrent data payload steps (10KB)💻 Local Development
Stream Benchmarks (includes TTFB metrics)workflow with stream💻 Local Development
stream pipeline with 5 transform steps (1MB)💻 Local Development
10 parallel streams (1MB each)💻 Local Development
fan-out fan-in 10 streams (1MB each)💻 Local Development
SummaryFastest Framework by WorldWinner determined by most benchmark wins
Fastest World by FrameworkWinner determined by most benchmark wins
Column Definitions
Worlds:
|
There was a problem hiding this comment.
Pull request overview
This PR updates the Nitro integration so that string entries from Nitro’s native nitro.options.externals.external configuration are forwarded into the Workflow builder configuration (externalPackages), allowing esbuild bundling to treat those packages as external (while ignoring RegExp/function entries that esbuild can’t represent).
Changes:
- Add a helper to extract only string externals from
nitro.options.externals.external. - Pass the extracted externals through
externalPackagesfor bothVercelBuilderandLocalBuilder. - Add builder-level tests covering empty/mixed/all-non-string externals behavior, plus a changeset for release notes.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/nitro/src/builders.ts | Extracts Nitro string externals and forwards them into builder config as externalPackages. |
| packages/nitro/src/index.test.ts | Adds tests validating forwarding/filtering behavior for both builders. |
| .changeset/nitro-forward-externals.md | Declares a minor version bump and documents the new externals forwarding behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
VaguelySerious
left a comment
There was a problem hiding this comment.
LGTM
Is this related to #1292? It doesn't say which framework he's using, but if nitro or nitro-derivate, this should cover their use, right?
Summary
nitro.options.externals.externalto the workflow builder's esbuildexternaloption.VercelBuilderandLocalBuilder.externalonly supports literal strings.Motivation
Nitro users can already mark packages as externals via the native
externals.externalconfig, but the Workflow SDK previously ignored that setting and bundled everything itself. This led to unnecessary bundling of packages (e.g. native-dep packages likefsevents) that users had already explicitly opted out of.Rather than introduce a workflow-specific
externalPackagesoption on the Nitro module, this PR reads Nitro's native externals config so the same declaration covers both Nitro's rollup build and our esbuild bundles.Tests
8 new tests in
packages/nitro/src/index.test.ts(4 per builder:VercelBuilderandLocalBuilder) covering empty externals, string-only forwarding, mixed string/RegExp/function filtering, and all-non-string rejection.