From aaf4bcd0254bc4a32a1749847337ab5632aff0cf Mon Sep 17 00:00:00 2001 From: pooya parsa Date: Thu, 11 Aug 2022 19:39:02 +0200 Subject: [PATCH] fix(vite): remove `/@fs` from external ids (#6529) --- packages/vite/src/dev-bundler.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/vite/src/dev-bundler.ts b/packages/vite/src/dev-bundler.ts index 475964c4ab..f9306649da 100644 --- a/packages/vite/src/dev-bundler.ts +++ b/packages/vite/src/dev-bundler.ts @@ -51,13 +51,13 @@ async function transformRequest (opts: TransformOptions, id: string) { // On Windows, we prefix absolute paths with `/@fs/` to skip node resolution algorithm id = id.replace(/^\/?(?=\w:)/, '/@fs/') - // Vite will add ?v=123 to bypass browser cache - // Remove for externals - const withoutVersionQuery = id.replace(/\?v=\w+$/, '') - if (await opts.isExternal(withoutVersionQuery)) { - const path = builtinModules.includes(withoutVersionQuery.split('node:').pop()) - ? withoutVersionQuery - : isAbsolute(withoutVersionQuery) ? pathToFileURL(withoutVersionQuery).href : withoutVersionQuery + // Remove query and @fs/ for external modules + const externalId = id.replace(/\?v=\w+$|^\/@fs/, '') + + if (await opts.isExternal(externalId)) { + const path = builtinModules.includes(externalId.split('node:').pop()) + ? externalId + : isAbsolute(externalId) ? pathToFileURL(externalId).href : externalId return { code: `(global, module, _, exports, importMeta, ssrImport, ssrDynamicImport, ssrExportAll) => ${genDynamicImport(path, { wrapper: false })}