You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Nitro: outputFileTracingIncludes / outputFileTracingExcludes are ignored, so externals ship incomplete #5131
Under Nitro, a server-external package that reads its own non-JS files at runtime ships incomplete in .output/server/node_modules, even when the app lists those files in outputFileTracingIncludes. vinext does not read outputFileTracingIncludes or outputFileTracingExcludes from next.config.
Repro
Next.js's test/e2e/twoslash fixture: serverExternalPackages: ["twoslash"] plus
outputFileTracingIncludes: {
"/": ["<path to node_modules/typescript/lib>/lib.*.d.ts", "./node_modules/@types/node/**"],
},
Build with vinext() + nitro({ preset: "bun" }) on 1.0.0-beta.12. .output/server/node_modules/typescript/lib contains only typescript.js while the app's copy has 100 files, and @types/node is not copied at all. The route returns {"error":{}} because @typescript/vfs cannot find lib.es2020.d.ts and the other lib files.
Expected
Files matched by outputFileTracingIncludes ship in the server output, and outputFileTracingExcludes removes traced files, as in Next.js.
Cause
Nitro traces externalized packages file by file, so it misses files only read with fs at runtime. Next.js covers that case with the two options; vinext never parsed them.
Thanks for the clear report. You're right: vinext doesn't read outputFileTracingIncludes or outputFileTracingExcludes from next.config at all. In a Nitro production build it only passes serverExternalPackages to Nitro's dependency tracing. Nitro copies each external package one module at a time, so files the package only reads with fs at runtime are left out, even when you list them in outputFileTracingIncludes. That's why typescript/lib arrives without its lib.*.d.ts files and @types/node is missing.
We saw the same thing with a small App Router app: a server-external package with an extra file listed in outputFileTracingIncludes, built with vinext() and nitro(). The file was missing from .output/server/node_modules, while next build records it in the route's trace. Excludes aren't applied either, for the same reason.
Until this is fixed, a workaround is to copy the files into .output/server/node_modules after the build, or to add them through Nitro's own options.
Details for maintainers
Cause: vinext never reads outputFileTracingIncludes or outputFileTracingExcludes from next.config. Its Nitro setup hook only adds serverExternalPackages to Nitro's traceDeps, and Nitro traces externals module by module, so files an external package only reads with fs at runtime are left out of .output/server/node_modules. A Nitro build of a checked-in fixture that includes node_modules/pathslash/README.md ships only dist and package.json. Not checked: the Turbopack probe failed because of the symlinked scratch setup (a webpack next build does record the included file in the route's .nft.json), and PR #3436 couldn't be read without GitHub access.
Where to look:
packages/vinext/src/config/next-config.ts:2304 config resolution reads serverExternalPackages but never parses outputFileTracingIncludes / outputFileTracingExcludes (route-keyed glob maps, resolved from the project dir) into the resolved config
packages/vinext/src/index.ts:9638 vinext:nitro-setup only adds serverExternalPackages to nitro.options.traceDeps; included files need to be copied into Nitro's output server dir (and excluded ones dropped), e.g. from a Nitro hook after externals are traced
packages/vinext/src/build/standalone.ts:249 vinext's own output: "standalone" copy also never applies these options; the same missing parse probably affects it, and it belongs in the same minimal fix
Reproduction:npx vp test run tests/nitro-output-file-tracing.repro.test.ts
The command exited with 1 on a clean checkout.
Expected: Files matched by outputFileTracingIncludes are copied into the Nitro server output (.output/server/node_modules/...), and files matched by outputFileTracingExcludes are removed, as in Next.js. Observed:.output/server/node_modules/pathslash contains only dist and package.json; the included README.md is missing, and the test fails with "expected [ 'dist', 'package.json' ] to include 'README.md'".
The test: tests/nitro-output-file-tracing.repro.test.ts
importfsfrom"node:fs";importpathfrom"node:path";import{createRequire}from"node:module";import{pathToFileURL}from"node:url";import{createBuilder,typePluginOption}from"vite";import{afterAll,beforeAll,describe,expect,it}from"vite-plus/test";importvinextfrom"../packages/vinext/src/index.js";import{createIsolatedFixture}from"./helpers.js";// Issue #5131: under Nitro, vinext ignores outputFileTracingIncludes, so a// server-external package that reads its own non-JS files at runtime ships// without them in .output/server/node_modules.constFIXTURE_DIR=path.resolve(import.meta.dirname,"fixtures/nitro-output-file-tracing/app-root",);// The workspace fixture that has Nitro installed.constNITRO_FIXTURE=path.resolve(import.meta.dirname,"fixtures/app-router-nitro-server");describe("Nitro build honours outputFileTracingIncludes",()=>{letroot: string;letserverModules: string;beforeAll(async()=>{root=awaitcreateIsolatedFixture(FIXTURE_DIR,"vinext-nitro-tracing-");constnitroVite=createRequire(path.join(NITRO_FIXTURE,"package.json")).resolve("nitro/vite");const{ nitro }=(awaitimport(pathToFileURL(nitroVite).href))as{nitro: (options?: Record<string,unknown>)=>PluginOption;};constbuilder=awaitcreateBuilder({
root,configFile: false,plugins: [vinext({appDir: root}),nitro({preset: "node-server",serveStatic: false,buildDir: path.join(root,".nitro")}),],logLevel: "error",});awaitbuilder.buildApp();serverModules=path.join(root,".output/server/node_modules");},300_000);afterAll(()=>{if(root)fs.rmSync(root,{recursive: true,force: true});});it("externalizes the server-external package into the Nitro output",()=>{expect(fs.existsSync(path.join(serverModules,"pathslash/package.json"))).toBe(true);});it("ships files matched by outputFileTracingIncludes",()=>{expect(fs.readdirSync(path.join(serverModules,"pathslash"))).toContain("README.md");});});
What it printed
RUN v5.1.0 /workspace/repo
❯ unit tests/nitro-output-file-tracing.repro.test.ts (2 tests | 1 failed) 4016ms
❯ Nitro build honours outputFileTracingIncludes (2)
✓ externalizes the server-external package into the Nitro output 2ms
× ships files matched by outputFileTracingIncludes 3ms
Test Files 1 failed (1)
Tests 1 failed | 1 passed (2)
Start at 09:41:47
Duration 5.46s (tests 76%, transform 13%, import 8%, setup 3%)
⎯⎯⎯⎯⎯⎯⎯ Failed Tests 1 ⎯⎯⎯⎯⎯⎯⎯
FAIL unit tests/nitro-output-file-tracing.repro.test.ts > Nitro build honours outputFileTracingIncludes > ships files matched by outputFileTracingIncludes
AssertionError: expected [ 'dist', 'package.json' ] to include 'README.md'
❯ tests/nitro-output-file-tracing.repro.test.ts:52:67
50|
51| it("ships files matched by outputFileTracingIncludes", () => {
52| expect(fs.readdirSync(path.join(serverModules, "pathslash"))).toCo…
| ^
53| });
54| });
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/1]⎯
A pull request fixes this, with the reproduction kept as a regression test. ask-bonk[bot] approved its head, and its checks pass: it is waiting for a maintainer.
Activity
alcora-dev commentedon Dec 5, 2026
Triage: reproduced
Thanks for the clear report. You're right: vinext doesn't read
outputFileTracingIncludesoroutputFileTracingExcludesfromnext.configat all. In a Nitro production build it only passesserverExternalPackagesto Nitro's dependency tracing. Nitro copies each external package one module at a time, so files the package only reads withfsat runtime are left out, even when you list them inoutputFileTracingIncludes. That's whytypescript/libarrives without itslib.*.d.tsfiles and@types/nodeis missing.We saw the same thing with a small App Router app: a server-external package with an extra file listed in
outputFileTracingIncludes, built withvinext()andnitro(). The file was missing from.output/server/node_modules, whilenext buildrecords it in the route's trace. Excludes aren't applied either, for the same reason.Until this is fixed, a workaround is to copy the files into
.output/server/node_modulesafter the build, or to add them through Nitro's own options.Details for maintainers
Cause: vinext never reads
outputFileTracingIncludesoroutputFileTracingExcludesfrom next.config. Its Nitro setup hook only addsserverExternalPackagesto Nitro'straceDeps, and Nitro traces externals module by module, so files an external package only reads withfsat runtime are left out of.output/server/node_modules. A Nitro build of a checked-in fixture that includesnode_modules/pathslash/README.mdships onlydistandpackage.json. Not checked: the Turbopack probe failed because of the symlinked scratch setup (a webpacknext builddoes record the included file in the route's .nft.json), and PR #3436 couldn't be read without GitHub access.Where to look:
packages/vinext/src/config/next-config.ts:2304config resolution reads serverExternalPackages but never parses outputFileTracingIncludes / outputFileTracingExcludes (route-keyed glob maps, resolved from the project dir) into the resolved configpackages/vinext/src/index.ts:9638vinext:nitro-setup only adds serverExternalPackages to nitro.options.traceDeps; included files need to be copied into Nitro's output server dir (and excluded ones dropped), e.g. from a Nitro hook after externals are tracedpackages/vinext/src/build/standalone.ts:249vinext's ownoutput: "standalone"copy also never applies these options; the same missing parse probably affects it, and it belongs in the same minimal fixReproduction:
npx vp test run tests/nitro-output-file-tracing.repro.test.tsThe command exited with 1 on a clean checkout.
Expected: Files matched by
outputFileTracingIncludesare copied into the Nitro server output (.output/server/node_modules/...), and files matched byoutputFileTracingExcludesare removed, as in Next.js.Observed:
.output/server/node_modules/pathslashcontains onlydistandpackage.json; the includedREADME.mdis missing, and the test fails with "expected [ 'dist', 'package.json' ] to include 'README.md'".The test: tests/nitro-output-file-tracing.repro.test.ts
What it printed
Triaged by an AI agent at 5974ee6; it may be wrong. Confidence: high. · Triage report · Run #135
alcora-dev commentedon Dec 5, 2026
A fix is ready for review: #5134
A pull request fixes this, with the reproduction kept as a regression test. ask-bonk[bot] approved its head, and its checks pass: it is waiting for a maintainer.
Fixed by an AI agent; it may be wrong. · Triage report · Run #1289