Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(optimizer): ensure the js files in deps won't mark as external #2709

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 6 additions & 2 deletions packages/vite/src/node/optimizer/esbuildDepPlugin.ts
Expand Up @@ -66,14 +66,18 @@ export function esbuildDepPlugin(
return {
name: 'vite:dep-pre-bundle',
setup(build) {
const nonJsFileRE = new RegExp(
`\\.(` + externalTypes.join('|') + `)(\\?.*)?$`
)
// externalize assets and commonly known non-js file types
build.onResolve(
{
filter: new RegExp(`\\.(` + externalTypes.join('|') + `)(\\?.*)?$`)
filter: nonJsFileRE
antfu marked this conversation as resolved.
Show resolved Hide resolved
},
async ({ path: id, importer, kind }) => {
const resolved = await resolve(id, importer, kind)
if (resolved) {
// ensure the files finally resolved as js won't be marked to external
if (resolved && nonJsFileRE.test(resolved)) {
return {
path: resolved,
external: true
Expand Down