Skip to content

Commit

Permalink
fix: onResolve is not called for glob imports
Browse files Browse the repository at this point in the history
  • Loading branch information
XiSenao committed Dec 9, 2023
1 parent 3e42611 commit 66e16c1
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions packages/vite/src/node/optimizer/scan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -561,16 +561,6 @@ function esbuildScanPlugin(
external: doExternalize(path),
}
})
// onResolve is not called for glob imports.
// we need to add that here as well until esbuild calls onResolve for glob imports.
// https://github.com/evanw/esbuild/issues/3317
build.onLoad({ filter, namespace: 'file' }, () => {
const externalOnLoadResult: OnLoadResult = {
loader: 'js',
contents: 'export default {}',
}
return externalOnLoadResult
})
}

// css
Expand Down Expand Up @@ -647,6 +637,17 @@ function esbuildScanPlugin(
contents,
}
})

// onResolve is not called for glob imports.
// we need to add that here as well until esbuild calls onResolve for glob imports.
// https://github.com/evanw/esbuild/issues/3317
build.onLoad({ filter: /.*/, namespace: 'file' }, () => {
const externalOnLoadResult: OnLoadResult = {
loader: 'js',
contents: 'export default {}',
}
return externalOnLoadResult
})
},
}
}
Expand Down

0 comments on commit 66e16c1

Please sign in to comment.