Describe the bug
Vitest 4 sets config.resolve.external by spreading node:module.builtinModules and then prefixing every entry with node::
|
config.resolve.external = [ |
|
...builtinModules, |
|
...builtinModules.map(m => `node:${m}`), |
|
] |
|
|
|
// by setting `noExternal` to `true`, we make sure that |
|
// Vite will never use its own externalization mechanism |
On newer Node versions, builtinModules includes some built-ins only in already-prefixed form, for example:
node:sea
node:sqlite
node:test
node:test/reporters
Related documentation: https://nodejs.org/api/modules.html#built-in-modules
This makes Vitest generate invalid double-prefixed entries:
node:node:sea
node:node:sqlite
node:node:test
node:node:test/reporters
This surfaced downstream with @cloudflare/vite-plugin@1.42.1, which still rejects Vitest startup because resolve.external contains these non-built-in node:node:* entries.
Reproduction
On Node v24.14.1:
import { builtinModules } from "node:module";
console.log(
builtinModules
.flatMap((m) => [m, `node:${m}`])
.filter((m) => m.includes("sea") || m.includes("sqlite") || m.includes("test")),
);
Output includes:
node:sea
node:sqlite
node:test
node:test/reporters
node:node:sea
node:node:sqlite
node:node:test
node:node:test/reporters
Expected behavior
Vitest should not add a second node: prefix when a built-in already starts with node:.
For example:
config.resolve.external = [
...builtinModules,
...builtinModules.map((m) => (m.startsWith("node:") ? m : `node:${m}`)),
];
System Info
- Vitest:
4.1.9
- Node:
v24.14.1
- OS: macOS arm64
- Package manager: Bun
Additional context
This appears related in spirit to #8925, but this report is specifically about Node’s own node:-only built-ins being double-prefixed.
Filed by GPT-5.5.
Describe the bug
Vitest 4 sets
config.resolve.externalby spreadingnode:module.builtinModulesand then prefixing every entry withnode::vitest/packages/vitest/src/node/plugins/runnerTransform.ts
Lines 100 to 106 in 29c364d
On newer Node versions,
builtinModulesincludes some built-ins only in already-prefixed form, for example:Related documentation: https://nodejs.org/api/modules.html#built-in-modules
This makes Vitest generate invalid double-prefixed entries:
This surfaced downstream with
@cloudflare/vite-plugin@1.42.1, which still rejects Vitest startup becauseresolve.externalcontains these non-built-innode:node:*entries.Reproduction
On Node
v24.14.1:Output includes:
Expected behavior
Vitest should not add a second
node:prefix when a built-in already starts withnode:.For example:
System Info
4.1.9v24.14.1Additional context
This appears related in spirit to #8925, but this report is specifically about Node’s own
node:-only built-ins being double-prefixed.Filed by GPT-5.5.