mirror of
https://github.com/vitejs/vite.git
synced 2024-11-21 14:48:41 +00:00
fix(optimizer): fix optimizeDeps.include
glob syntax for ./*
exports (#16230)
This commit is contained in:
parent
9800c738b5
commit
f184c8032b
@ -95,6 +95,16 @@ export function expandGlobIds(id: string, config: ResolvedConfig): string[] {
|
||||
ignore: ['node_modules'],
|
||||
})
|
||||
.map((filePath) => {
|
||||
// ensure "./" prefix for inconsistent fast-glob result
|
||||
// glob.sync("./some-dir/**/*") -> "./some-dir/some-file"
|
||||
// glob.sync("./**/*") -> "some-dir/some-file"
|
||||
if (
|
||||
exportsValue.startsWith('./') &&
|
||||
!filePath.startsWith('./')
|
||||
) {
|
||||
filePath = './' + filePath
|
||||
}
|
||||
|
||||
// "./glob/*": "./dist/glob/*-browser/*.js"
|
||||
// `filePath`: "./dist/glob/foo-browser/foo.js"
|
||||
// we need to revert the file path back to the export key by
|
||||
|
@ -304,6 +304,10 @@ describe.runIf(isServe)('optimizeDeps config', () => {
|
||||
'@vitejs/test-dep-optimize-exports-with-glob/glob-dir/foo',
|
||||
'@vitejs/test-dep-optimize-exports-with-glob/glob-dir/bar',
|
||||
'@vitejs/test-dep-optimize-exports-with-glob/glob-dir/nested/baz',
|
||||
'@vitejs/test-dep-optimize-exports-with-root-glob',
|
||||
'@vitejs/test-dep-optimize-exports-with-root-glob/file1.js',
|
||||
'@vitejs/test-dep-optimize-exports-with-root-glob/index.js',
|
||||
'@vitejs/test-dep-optimize-exports-with-root-glob/dir/file2.js',
|
||||
'@vitejs/test-dep-optimize-with-glob',
|
||||
'@vitejs/test-dep-optimize-with-glob/index.js',
|
||||
'@vitejs/test-dep-optimize-with-glob/named.js',
|
||||
|
@ -0,0 +1,10 @@
|
||||
{
|
||||
"name": "@vitejs/test-dep-optimize-exports-with-root-glob",
|
||||
"private": true,
|
||||
"version": "1.0.0",
|
||||
"type": "module",
|
||||
"exports": {
|
||||
".": "./index.js",
|
||||
"./*": "./*"
|
||||
}
|
||||
}
|
@ -26,6 +26,7 @@
|
||||
"@vitejs/test-dep-node-env": "file:./dep-node-env",
|
||||
"@vitejs/test-dep-not-js": "file:./dep-not-js",
|
||||
"@vitejs/test-dep-optimize-exports-with-glob": "file:./dep-optimize-exports-with-glob",
|
||||
"@vitejs/test-dep-optimize-exports-with-root-glob": "file:./dep-optimize-exports-with-root-glob",
|
||||
"@vitejs/test-dep-optimize-with-glob": "file:./dep-optimize-with-glob",
|
||||
"@vitejs/test-dep-relative-to-main": "file:./dep-relative-to-main",
|
||||
"@vitejs/test-dep-with-builtin-module-cjs": "file:./dep-with-builtin-module-cjs",
|
||||
|
@ -20,6 +20,7 @@ export default defineConfig({
|
||||
// will throw if optimized (should log warning instead)
|
||||
'@vitejs/test-non-optimizable-include',
|
||||
'@vitejs/test-dep-optimize-exports-with-glob/**/*',
|
||||
'@vitejs/test-dep-optimize-exports-with-root-glob/**/*.js',
|
||||
'@vitejs/test-dep-optimize-with-glob/**/*.js',
|
||||
],
|
||||
exclude: ['@vitejs/test-nested-exclude', '@vitejs/test-dep-non-optimized'],
|
||||
|
@ -936,6 +936,9 @@ importers:
|
||||
'@vitejs/test-dep-optimize-exports-with-glob':
|
||||
specifier: file:./dep-optimize-exports-with-glob
|
||||
version: file:playground/optimize-deps/dep-optimize-exports-with-glob
|
||||
'@vitejs/test-dep-optimize-exports-with-root-glob':
|
||||
specifier: file:./dep-optimize-exports-with-root-glob
|
||||
version: file:playground/optimize-deps/dep-optimize-exports-with-root-glob
|
||||
'@vitejs/test-dep-optimize-with-glob':
|
||||
specifier: file:./dep-optimize-with-glob
|
||||
version: file:playground/optimize-deps/dep-optimize-with-glob
|
||||
@ -1053,6 +1056,8 @@ importers:
|
||||
|
||||
playground/optimize-deps/dep-optimize-exports-with-glob: {}
|
||||
|
||||
playground/optimize-deps/dep-optimize-exports-with-root-glob: {}
|
||||
|
||||
playground/optimize-deps/dep-optimize-with-glob: {}
|
||||
|
||||
playground/optimize-deps/dep-relative-to-main: {}
|
||||
@ -10586,6 +10591,11 @@ packages:
|
||||
name: '@vitejs/test-dep-optimize-exports-with-glob'
|
||||
dev: false
|
||||
|
||||
file:playground/optimize-deps/dep-optimize-exports-with-root-glob:
|
||||
resolution: {directory: playground/optimize-deps/dep-optimize-exports-with-root-glob, type: directory}
|
||||
name: '@vitejs/test-dep-optimize-exports-with-root-glob'
|
||||
dev: false
|
||||
|
||||
file:playground/optimize-deps/dep-optimize-with-glob:
|
||||
resolution: {directory: playground/optimize-deps/dep-optimize-with-glob, type: directory}
|
||||
name: '@vitejs/test-dep-optimize-with-glob'
|
||||
|
Loading…
Reference in New Issue
Block a user