From 008e184cb2de8ad1ff0a7d2defafa6d1b88d9748 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Mon, 5 Oct 2026 20:16:12 +0900 Subject: [PATCH] fix: fix module graph builtin externals after #11421 (#11491) Co-authored-by: Hiroshi Ogawa <4232207+hi-ogawa@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 --- packages/vitest/src/utils/graph.ts | 3 +-- test/e2e/test/client-builtins.test.ts | 7 +++++-- 2 files changed, 6 insertions(+), 4 deletions(-) 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", ] -- 2.51.2