diff --git a/packages/vitest/src/utils/graph.ts b/packages/vitest/src/utils/graph.ts index 90f2013f0..6e714ce88 100644 --- a/packages/vitest/src/utils/graph.ts +++ b/packages/vitest/src/utils/graph.ts @@ -123,8 +123,7 @@ function createModuleGraphCollector( return addExternal(id.slice('__vite-browser-external:'.length)) } if (isBuiltin(id)) { - externalized.add(id) - return id + return addExternal(id) } const external = project._resolver.wasExternalized(id) if (typeof external === 'string') { diff --git a/test/e2e/test/client-builtins.test.ts b/test/e2e/test/client-builtins.test.ts index bcb9dc215..dffbd380a 100644 --- a/test/e2e/test/client-builtins.test.ts +++ b/test/e2e/test/client-builtins.test.ts @@ -84,7 +84,10 @@ test('importActual', async () => { `) const graph = await getModuleGraph(ctx!, '', `${root}/basic.test.js`, 'client') - expect(graph.externalized.filter((id) => !id.includes('/'))).toMatchInlineSnapshot(` + const modules = Object.entries(graph.modules) + const externalized = modules.filter(([, m]) => m.external).map(([id]) => id) + const inlined = modules.filter(([, m]) => !m.external).map(([id]) => id) + expect(externalized.filter((id) => !id.includes('/'))).toMatchInlineSnapshot(` [ "node:crypto", "node:path", @@ -93,7 +96,7 @@ test('importActual', async () => { "path", ] `) - expect(graph.inlined.map((id) => id.replace(root, ''))).toMatchInlineSnapshot(` + expect(inlined.map((id) => id.replace(root, ''))).toMatchInlineSnapshot(` [ "/basic.test.js", ]