Skip to content

Commit

Permalink
fix(scanner): catch all external files for glob imports (#15286)
Browse files Browse the repository at this point in the history
XiSenao authored Dec 14, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent b1a6c84 commit 129d0d0
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions packages/vite/src/node/optimizer/scan.ts
Original file line number Diff line number Diff line change
@@ -550,7 +550,6 @@ function esbuildScanPlugin(
// should be faster than doing it in the catch-all via js
// they are done after the bare import resolve because a package name
// may end with these extensions

const setupExternalize = (
filter: RegExp,
doExternalize: (path: string) => boolean,
@@ -561,16 +560,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
@@ -647,6 +636,16 @@ 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' }, () => {
return {
loader: 'js',
contents: 'export default {}',
}
})
},
}
}

0 comments on commit 129d0d0

Please sign in to comment.