Skip to content

Commit

Permalink
fix(ssr): add normalizePath to require.resolve, fix #2393 (#4980)
Browse files Browse the repository at this point in the history
  • Loading branch information
untp committed Sep 19, 2021
1 parent 94867b6 commit 417208c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/vite/src/node/ssr/ssrExternal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
createDebugger,
isDefined,
lookupFile,
normalizePath,
resolveFrom,
unique
} from '../utils'
Expand Down Expand Up @@ -68,7 +69,9 @@ export function resolveSSRExternal(
undefined,
true
)?.id
requireEntry = require.resolve(id, { paths: [root] })
// normalizePath required for windows. tryNodeResolve uses normalizePath
// which returns with '/', require.resolve returns with '\\'
requireEntry = normalizePath(require.resolve(id, { paths: [root] }))
} catch (e) {
// resolve failed, assume include
debug(`Failed to resolve entries for package "${id}"\n`, e)
Expand Down

0 comments on commit 417208c

Please sign in to comment.