mirror of
https://github.com/nuxt/nuxt.git
synced 2025-01-31 15:50:32 +00:00
fix(vite): remove /@fs
from external ids (#6529)
This commit is contained in:
parent
24a499d285
commit
aaf4bcd025
@ -51,13 +51,13 @@ async function transformRequest (opts: TransformOptions, id: string) {
|
|||||||
// On Windows, we prefix absolute paths with `/@fs/` to skip node resolution algorithm
|
// On Windows, we prefix absolute paths with `/@fs/` to skip node resolution algorithm
|
||||||
id = id.replace(/^\/?(?=\w:)/, '/@fs/')
|
id = id.replace(/^\/?(?=\w:)/, '/@fs/')
|
||||||
|
|
||||||
// Vite will add ?v=123 to bypass browser cache
|
// Remove query and @fs/ for external modules
|
||||||
// Remove for externals
|
const externalId = id.replace(/\?v=\w+$|^\/@fs/, '')
|
||||||
const withoutVersionQuery = id.replace(/\?v=\w+$/, '')
|
|
||||||
if (await opts.isExternal(withoutVersionQuery)) {
|
if (await opts.isExternal(externalId)) {
|
||||||
const path = builtinModules.includes(withoutVersionQuery.split('node:').pop())
|
const path = builtinModules.includes(externalId.split('node:').pop())
|
||||||
? withoutVersionQuery
|
? externalId
|
||||||
: isAbsolute(withoutVersionQuery) ? pathToFileURL(withoutVersionQuery).href : withoutVersionQuery
|
: isAbsolute(externalId) ? pathToFileURL(externalId).href : externalId
|
||||||
return {
|
return {
|
||||||
code: `(global, module, _, exports, importMeta, ssrImport, ssrDynamicImport, ssrExportAll) =>
|
code: `(global, module, _, exports, importMeta, ssrImport, ssrDynamicImport, ssrExportAll) =>
|
||||||
${genDynamicImport(path, { wrapper: false })}
|
${genDynamicImport(path, { wrapper: false })}
|
||||||
|
Loading…
Reference in New Issue
Block a user