Skip to content

Commit

Permalink
fix(ssr): check esm file with normal file path (#15307)
Browse files Browse the repository at this point in the history
  • Loading branch information
bluwy authored Dec 11, 2023
1 parent 103820f commit 1597170
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions packages/vite/src/node/ssr/ssrModuleLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,8 @@ async function nodeImport(
metadata?: SSRImportMetadata,
) {
let url: string
const isRuntimeHandled = id.startsWith('data:') || isBuiltin(id)
if (isRuntimeHandled) {
let filePath: string | undefined
if (id.startsWith('data:') || isBuiltin(id)) {
url = id
} else {
const resolved = tryNodeResolve(
Expand All @@ -310,24 +310,25 @@ async function nodeImport(
err.code = 'ERR_MODULE_NOT_FOUND'
throw err
}
filePath = resolved.id
url = pathToFileURL(resolved.id).toString()
}

const mod = await import(url)

if (resolveOptions.legacyProxySsrExternalModules) {
return proxyESM(mod)
} else if (isRuntimeHandled) {
return mod
} else {
} else if (filePath) {
analyzeImportedModDifference(
mod,
url,
filePath,
id,
metadata,
resolveOptions.packageCache,
)
return proxyGuardOnlyEsm(mod, id)
} else {
return mod
}
}

Expand Down

0 comments on commit 1597170

Please sign in to comment.