Skip to content

Commit

Permalink
Path the pathname rather than fileURL
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewp committed Oct 15, 2021
1 parent 9c6ab45 commit bc6cafc
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/vite/src/node/ssr/ssrModuleLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ async function nodeImport(
} else {
url = pathToFileURL(
resolve(id, importer, config.root, !!config.resolve.preserveSymlinks)
).toString()
).pathname
}
const mod = await dynamicImport(url)
return proxyESM(id, mod)
Expand All @@ -203,6 +203,9 @@ function proxyESM(id: string, mod: any) {
if (isObject(mod.default) && prop in mod.default) {
return mod.default[prop]
}
if (prop === 'then') {
return undefined;
}
// throw an error like ESM import does
throw new SyntaxError(
`The requested module '${id}' does not provide an export named '${prop.toString()}'`
Expand Down

0 comments on commit bc6cafc

Please sign in to comment.