Skip to content

Commit

Permalink
fix: defaultRequestToFile should handle uncached node_modules request (
Browse files Browse the repository at this point in the history
  • Loading branch information
csr632 authored May 22, 2020
1 parent 33c6bc2 commit 7a3e822
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/node/resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,15 @@ export interface InternalResolver {

const defaultRequestToFile = (publicPath: string, root: string): string => {
if (moduleRE.test(publicPath)) {
const moduleFilePath = idToFileMap.get(publicPath.replace(moduleRE, ''))
if (moduleFilePath) {
return moduleFilePath
const id = publicPath.replace(moduleRE, '')
const cachedModuleFilePath = idToFileMap.get(id)
if (cachedModuleFilePath) {
return cachedModuleFilePath
}
const resolved = resolveNodeModuleFile(root, id)
if (resolved) {
idToFileMap.set(id, resolved)
return resolved
}
}
return path.join(root, publicPath.slice(1))
Expand Down

0 comments on commit 7a3e822

Please sign in to comment.