Skip to content

Commit ab33803

Browse files
fix: don't consider ids with npm: prefix as a built-in module (vitejs#20558)
1 parent f4438a1 commit ab33803

File tree

2 files changed

+1
-4
lines changed

2 files changed

+1
-4
lines changed

packages/vite/src/node/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1996,7 +1996,7 @@ async function bundleConfigFile(
19961996
// With the `isNodeBuiltin` check above, this check captures if the builtin is a
19971997
// non-node built-in, which esbuild doesn't know how to handle. In that case, we
19981998
// externalize it so the non-node runtime handles it instead.
1999-
if (isNodeLikeBuiltin(id)) {
1999+
if (isNodeLikeBuiltin(id) || id.startsWith('npm:')) {
20002000
return { external: true }
20012001
}
20022002

packages/vite/src/node/utils.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,6 @@ export const normalizeId = (id: string): string =>
9898

9999
// Supported by Node, Deno, Bun
100100
const NODE_BUILTIN_NAMESPACE = 'node:'
101-
// Supported by Deno
102-
const NPM_BUILTIN_NAMESPACE = 'npm:'
103101
// Supported by Bun
104102
const BUN_BUILTIN_NAMESPACE = 'bun:'
105103
// Some runtimes like Bun injects namespaced modules here, which is not a node builtin
@@ -136,7 +134,6 @@ export function createIsBuiltin(
136134
export const nodeLikeBuiltins = [
137135
...nodeBuiltins,
138136
new RegExp(`^${NODE_BUILTIN_NAMESPACE}`),
139-
new RegExp(`^${NPM_BUILTIN_NAMESPACE}`),
140137
new RegExp(`^${BUN_BUILTIN_NAMESPACE}`),
141138
]
142139

0 commit comments

Comments
 (0)