From eecbe97c6faa0af44a76c2dbf761dc4c714ad3e1 Mon Sep 17 00:00:00 2001 From: Vladimir Sheremet Date: Tue, 4 Jul 2023 13:26:50 +0200 Subject: [PATCH] chore: cleanup --- packages/vite/src/node/ssr/runtimeClient.ts | 10 ++++++---- packages/vite/src/node/utils/shared.ts | 3 +++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/vite/src/node/ssr/runtimeClient.ts b/packages/vite/src/node/ssr/runtimeClient.ts index 5a3d26f0ad7edb..452abcaf23097b 100644 --- a/packages/vite/src/node/ssr/runtimeClient.ts +++ b/packages/vite/src/node/ssr/runtimeClient.ts @@ -268,7 +268,7 @@ export class ViteRuntimeClient { debugTimer = setTimeout( () => warn( - `[vite-node] module ${fsPath} takes over 2s to load.\n${getStack()}`, + `[vite-runtime-client] module ${fsPath} takes over 2s to load.\n${getStack()}`, ), 2000, ) @@ -367,12 +367,14 @@ export class ViteRuntimeClient { return exports } - if (transformed == null) + if (transformed == null) { + const importer = callstack[callstack.length - 2] throw new Error( - `[vite-runtime-client] Failed to load "${id}" imported from ${ - callstack[callstack.length - 2] + `[vite-runtime-client] Failed to load "${id}"${ + importer ? `imported from ${importer}` : '' }`, ) + } const modulePath = cleanUrl(moduleId) // disambiguate the `:/` on windows: see nodejs/node#31710 diff --git a/packages/vite/src/node/utils/shared.ts b/packages/vite/src/node/utils/shared.ts index 78508572351e4e..8e11a6fe31a348 100644 --- a/packages/vite/src/node/utils/shared.ts +++ b/packages/vite/src/node/utils/shared.ts @@ -180,7 +180,10 @@ const builtins = new Set([ 'wasi', ]) +const prefixedBuiltins = new Set(['node:test']) + export function isBuiltin(id: string): boolean { + if (prefixedBuiltins.has(id)) return true return builtins.has(id.replace(/^node:/, '')) }