diff --git a/.gitignore b/.gitignore index 9d0492548fe113..580f146ab631e6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -!**/glob-import/dir/node_modules +!**/glob-import/root/dir/node_modules .DS_Store .idea .pnpm-store diff --git a/docs/guide/index.md b/docs/guide/index.md index a502bfab972247..64a3909cb16cfd 100644 --- a/docs/guide/index.md +++ b/docs/guide/index.md @@ -268,7 +268,7 @@ Then go to your Vite based project and run `pnpm link vite` (or the package mana To learn more about how and when Vite does releases, check out the [Releases](../releases.md) documentation. ::: tip Dependencies using Vite -To replace the Vite version used by dependencies transitively, you should use [npm overrides](https://docs.npmjs.com/cli/v11/configuring-npm/package-json#overrides) or [pnpm overrides](https://pnpm.io/9.x/package_json#pnpmoverrides). +To replace the Vite version used by dependencies transitively, you should use [npm overrides](https://docs.npmjs.com/cli/v11/configuring-npm/package-json#overrides) or [pnpm overrides](https://pnpm.io/settings#overrides). ::: ## Community diff --git a/docs/package.json b/docs/package.json index 85e2d7d7c1fb5a..4e6114177eef37 100644 --- a/docs/package.json +++ b/docs/package.json @@ -14,7 +14,7 @@ "@voidzero-dev/vitepress-theme": "^4.8.4", "feed": "^5.2.1", "markdown-it-image-size": "^15.0.1", - "oxc-minify": "^0.130.0", + "oxc-minify": "^0.131.0", "vitepress": "^2.0.0-alpha.17", "vitepress-plugin-graphviz": "^0.1.0", "vitepress-plugin-group-icons": "^1.7.5", diff --git a/packages/vite/package.json b/packages/vite/package.json index 617f5bca6c9cda..4f206322af459d 100644 --- a/packages/vite/package.json +++ b/packages/vite/package.json @@ -127,7 +127,7 @@ "postcss-modules": "^6.0.1", "premove": "^4.0.0", "resolve.exports": "^2.0.3", - "rolldown-plugin-dts": "^0.25.0", + "rolldown-plugin-dts": "^0.25.1", "rollup": "^4.59.0", "rollup-plugin-license": "^3.7.1", "sass": "^1.99.0", diff --git a/packages/vite/src/node/__tests__/plugins/importGlob/__snapshots__/fixture.spec.ts.snap b/packages/vite/src/node/__tests__/plugins/importGlob/__snapshots__/fixture.spec.ts.snap index a28e45055d25a0..bbf6c9cc8d852b 100644 --- a/packages/vite/src/node/__tests__/plugins/importGlob/__snapshots__/fixture.spec.ts.snap +++ b/packages/vite/src/node/__tests__/plugins/importGlob/__snapshots__/fixture.spec.ts.snap @@ -94,10 +94,10 @@ export const cleverCwd2 = /* #__PURE__ */ Object.assign({"./modules/a.ts": () => }); export const customBase = /* #__PURE__ */ Object.assign({"./modules/a.ts": () => import("./modules/a.ts"),"./modules/b.ts": () => import("./modules/b.ts"),"./modules/index.ts": () => import("./modules/index.ts"),"./sibling.ts": () => import("./sibling.ts")}); -export const customRootBase = /* #__PURE__ */ Object.assign({"./a.ts": () => import("/fixture-b/a.ts"),"./b.ts": () => import("/fixture-b/b.ts"),"./index.ts": () => import("/fixture-b/index.ts") +export const customRootBase = /* #__PURE__ */ Object.assign({"./a.ts": () => import("../fixture-b/a.ts"),"./b.ts": () => import("../fixture-b/b.ts"),"./index.ts": () => import("../fixture-b/index.ts") }); -export const customBaseParent = /* #__PURE__ */ Object.assign({"../fixture-b/a.ts": () => import("/fixture-b/a.ts"),"../fixture-b/b.ts": () => import("/fixture-b/b.ts"),"../fixture-b/index.ts": () => import("/fixture-b/index.ts") +export const customBaseParent = /* #__PURE__ */ Object.assign({"../fixture-b/a.ts": () => import("../fixture-b/a.ts"),"../fixture-b/b.ts": () => import("../fixture-b/b.ts"),"../fixture-b/index.ts": () => import("../fixture-b/index.ts") }); export const dotFolder = /* #__PURE__ */ Object.assign({"./.foo/test.ts": __vite_glob_28_0}); @@ -198,10 +198,10 @@ export const cleverCwd2 = /* #__PURE__ */ Object.assign({"./modules/a.ts": () => }); export const customBase = /* #__PURE__ */ Object.assign({"./modules/a.ts": () => import("./modules/a.ts"),"./modules/b.ts": () => import("./modules/b.ts"),"./modules/index.ts": () => import("./modules/index.ts"),"./sibling.ts": () => import("./sibling.ts")}); -export const customRootBase = /* #__PURE__ */ Object.assign({"./a.ts": () => import("/fixture-b/a.ts"),"./b.ts": () => import("/fixture-b/b.ts"),"./index.ts": () => import("/fixture-b/index.ts") +export const customRootBase = /* #__PURE__ */ Object.assign({"./a.ts": () => import("../fixture-b/a.ts"),"./b.ts": () => import("../fixture-b/b.ts"),"./index.ts": () => import("../fixture-b/index.ts") }); -export const customBaseParent = /* #__PURE__ */ Object.assign({"../fixture-b/a.ts": () => import("/fixture-b/a.ts"),"../fixture-b/b.ts": () => import("/fixture-b/b.ts"),"../fixture-b/index.ts": () => import("/fixture-b/index.ts") +export const customBaseParent = /* #__PURE__ */ Object.assign({"../fixture-b/a.ts": () => import("../fixture-b/a.ts"),"../fixture-b/b.ts": () => import("../fixture-b/b.ts"),"../fixture-b/index.ts": () => import("../fixture-b/index.ts") }); export const dotFolder = /* #__PURE__ */ Object.assign({"./.foo/test.ts": __vite_glob_28_0}); diff --git a/packages/vite/src/node/plugins/importMetaGlob.ts b/packages/vite/src/node/plugins/importMetaGlob.ts index 516359e8bad8e7..616abbb1a4f15b 100644 --- a/packages/vite/src/node/plugins/importMetaGlob.ts +++ b/packages/vite/src/node/plugins/importMetaGlob.ts @@ -502,9 +502,6 @@ export async function transformGlobImport( if (!filePath.startsWith('./') && !filePath.startsWith('../')) { filePath = `./${filePath}` } - if (options.base[0] === '/') { - importPath = `/${relative(root, file)}` - } } else if (isRelative) { filePath = importPath } else { diff --git a/playground/glob-import/__tests__/glob-import.spec.ts b/playground/glob-import/__tests__/glob-import.spec.ts index 80039016494236..d54d8364fc7c10 100644 --- a/playground/glob-import/__tests__/glob-import.spec.ts +++ b/playground/glob-import/__tests__/glob-import.spec.ts @@ -135,7 +135,7 @@ if (!isBuild) { test('hmr for adding/removing files', async () => { const resultElement = page.locator('.result') - addFile('dir/a.js', '') + addFile('root/dir/a.js', '') await expect .poll(async () => { const actualAdd = await resultElement.textContent() @@ -154,7 +154,7 @@ if (!isBuild) { }) // edit the added file - editFile('dir/a.js', () => 'export const msg ="a"') + editFile('root/dir/a.js', () => 'export const msg ="a"') await expect .poll(async () => { const actualEdit = await resultElement.textContent() @@ -176,7 +176,7 @@ if (!isBuild) { }, }) - removeFile('dir/a.js') + removeFile('root/dir/a.js') await expect .poll(async () => { const actualRemove = await resultElement.textContent() @@ -187,12 +187,12 @@ if (!isBuild) { test('no hmr for adding/removing files', async () => { let request = page.waitForResponse(/dir\/index\.js$/, { timeout: 200 }) - addFile('nohmr.js', '') + addFile('root/nohmr.js', '') let response = await request.catch(() => ({ status: () => -1 })) expect(response.status()).toBe(-1) request = page.waitForResponse(/dir\/index\.js$/, { timeout: 200 }) - removeFile('nohmr.js') + removeFile('root/nohmr.js') response = await request.catch(() => ({ status: () => -1 })) expect(response.status()).toBe(-1) }) @@ -200,12 +200,12 @@ if (!isBuild) { test('hmr for adding/removing files in package', async () => { const resultElement = page.locator('.in-package') - addFile('pkg-pages/bar.js', '// empty') + addFile('root/pkg-pages/bar.js', '// empty') await expect .poll(async () => JSON.parse(await resultElement.textContent())) .toStrictEqual(['/pkg-pages/foo.js', '/pkg-pages/bar.js'].sort()) - removeFile('pkg-pages/bar.js') + removeFile('root/pkg-pages/bar.js') await expect .poll(async () => JSON.parse(await resultElement.textContent())) .toStrictEqual(['/pkg-pages/foo.js']) @@ -219,7 +219,7 @@ if (!isBuild) { './array-test-dir/included.js': 'included', }) - addFile('array-test-dir/new-file.js', 'export default "new"') + addFile('root/array-test-dir/new-file.js', 'export default "new"') await expect .poll(async () => JSON.parse(await resultElement.textContent())) .toStrictEqual({ @@ -227,7 +227,7 @@ if (!isBuild) { './array-test-dir/new-file.js': 'new', }) - removeFile('array-test-dir/new-file.js') + removeFile('root/array-test-dir/new-file.js') await expect .poll(async () => JSON.parse(await resultElement.textContent())) .toStrictEqual({ @@ -290,7 +290,7 @@ test('tree-shake eager css', async () => { ) if (isBuild) { - const content = findAssetFile(/index-[-\w]+\.js/) + const content = findAssetFile(/index-[-\w]+\.js/, '../root/dist') expect(content).not.toMatch('.tree-shake-eager-css') } }) @@ -302,9 +302,12 @@ test('escapes special chars in globs without mangling user supplied glob suffix' // index.html has a script that loads all these glob.js files and prints the globs that returned the expected result // this test finally compares the printed output of index.js with the list of directories with special chars, // expecting that they all work - const files = await readdir(path.join(import.meta.dirname, '..', 'escape'), { - withFileTypes: true, - }) + const files = await readdir( + path.join(import.meta.dirname, '..', 'root', 'escape'), + { + withFileTypes: true, + }, + ) const expectedNames = files .filter((f) => f.isDirectory()) .map((f) => `/escape/${f.name}/glob.js`) diff --git a/playground/glob-import/package.json b/playground/glob-import/package.json index d71d01109270f1..aa4cbcb53d3f33 100644 --- a/playground/glob-import/package.json +++ b/playground/glob-import/package.json @@ -4,15 +4,15 @@ "version": "0.0.0", "type": "module", "imports": { - "#imports/*": "./imports-path/*" + "#imports/*": "./root/imports-path/*" }, "scripts": { - "dev": "vite", - "build": "vite build", + "dev": "vite root", + "build": "vite build root", "debug": "node --inspect-brk ../../packages/vite/bin/vite", - "preview": "vite preview" + "preview": "vite preview root" }, "dependencies": { - "@vitejs/test-import-meta-glob-pkg": "file:./import-meta-glob-pkg" + "@vitejs/test-import-meta-glob-pkg": "file:./root/import-meta-glob-pkg" } } diff --git a/playground/glob-import/array-common-base/pattern1/a.js b/playground/glob-import/root/array-common-base/pattern1/a.js similarity index 100% rename from playground/glob-import/array-common-base/pattern1/a.js rename to playground/glob-import/root/array-common-base/pattern1/a.js diff --git a/playground/glob-import/array-common-base/pattern2/b.js b/playground/glob-import/root/array-common-base/pattern2/b.js similarity index 100% rename from playground/glob-import/array-common-base/pattern2/b.js rename to playground/glob-import/root/array-common-base/pattern2/b.js diff --git a/playground/glob-import/array-test-dir/excluded.js b/playground/glob-import/root/array-test-dir/excluded.js similarity index 100% rename from playground/glob-import/array-test-dir/excluded.js rename to playground/glob-import/root/array-test-dir/excluded.js diff --git a/playground/glob-import/array-test-dir/included.js b/playground/glob-import/root/array-test-dir/included.js similarity index 100% rename from playground/glob-import/array-test-dir/included.js rename to playground/glob-import/root/array-test-dir/included.js diff --git a/playground/glob-import/dir/alias.js b/playground/glob-import/root/dir/alias.js similarity index 100% rename from playground/glob-import/dir/alias.js rename to playground/glob-import/root/dir/alias.js diff --git a/playground/glob-import/dir/baz.json b/playground/glob-import/root/dir/baz.json similarity index 100% rename from playground/glob-import/dir/baz.json rename to playground/glob-import/root/dir/baz.json diff --git a/playground/glob-import/dir/foo.css b/playground/glob-import/root/dir/foo.css similarity index 100% rename from playground/glob-import/dir/foo.css rename to playground/glob-import/root/dir/foo.css diff --git a/playground/glob-import/dir/foo.js b/playground/glob-import/root/dir/foo.js similarity index 100% rename from playground/glob-import/dir/foo.js rename to playground/glob-import/root/dir/foo.js diff --git a/playground/glob-import/dir/index.js b/playground/glob-import/root/dir/index.js similarity index 100% rename from playground/glob-import/dir/index.js rename to playground/glob-import/root/dir/index.js diff --git a/playground/glob-import/dir/nested/bar.js b/playground/glob-import/root/dir/nested/bar.js similarity index 100% rename from playground/glob-import/dir/nested/bar.js rename to playground/glob-import/root/dir/nested/bar.js diff --git a/playground/glob-import/dir/node_modules/hoge.js b/playground/glob-import/root/dir/node_modules/hoge.js similarity index 100% rename from playground/glob-import/dir/node_modules/hoge.js rename to playground/glob-import/root/dir/node_modules/hoge.js diff --git a/playground/glob-import/dir/quote'.js b/playground/glob-import/root/dir/quote'.js similarity index 100% rename from playground/glob-import/dir/quote'.js rename to playground/glob-import/root/dir/quote'.js diff --git a/playground/glob-import/escape/(parenthesis)/glob.js b/playground/glob-import/root/escape/(parenthesis)/glob.js similarity index 100% rename from playground/glob-import/escape/(parenthesis)/glob.js rename to playground/glob-import/root/escape/(parenthesis)/glob.js diff --git a/playground/glob-import/escape/(parenthesis)/mod/index.js b/playground/glob-import/root/escape/(parenthesis)/mod/index.js similarity index 100% rename from playground/glob-import/escape/(parenthesis)/mod/index.js rename to playground/glob-import/root/escape/(parenthesis)/mod/index.js diff --git a/playground/glob-import/escape/[brackets]/glob.js b/playground/glob-import/root/escape/[brackets]/glob.js similarity index 100% rename from playground/glob-import/escape/[brackets]/glob.js rename to playground/glob-import/root/escape/[brackets]/glob.js diff --git a/playground/glob-import/escape/[brackets]/mod/index.js b/playground/glob-import/root/escape/[brackets]/mod/index.js similarity index 100% rename from playground/glob-import/escape/[brackets]/mod/index.js rename to playground/glob-import/root/escape/[brackets]/mod/index.js diff --git a/playground/glob-import/escape/{curlies}/glob.js b/playground/glob-import/root/escape/{curlies}/glob.js similarity index 100% rename from playground/glob-import/escape/{curlies}/glob.js rename to playground/glob-import/root/escape/{curlies}/glob.js diff --git a/playground/glob-import/escape/{curlies}/mod/index.js b/playground/glob-import/root/escape/{curlies}/mod/index.js similarity index 100% rename from playground/glob-import/escape/{curlies}/mod/index.js rename to playground/glob-import/root/escape/{curlies}/mod/index.js diff --git a/playground/glob-import/follow-symlinks/linked/.gitkeep b/playground/glob-import/root/follow-symlinks/linked/.gitkeep similarity index 100% rename from playground/glob-import/follow-symlinks/linked/.gitkeep rename to playground/glob-import/root/follow-symlinks/linked/.gitkeep diff --git a/playground/glob-import/follow-symlinks/packages/my-lib/components/a.js b/playground/glob-import/root/follow-symlinks/packages/my-lib/components/a.js similarity index 100% rename from playground/glob-import/follow-symlinks/packages/my-lib/components/a.js rename to playground/glob-import/root/follow-symlinks/packages/my-lib/components/a.js diff --git a/playground/glob-import/follow-symlinks/packages/my-lib/components/b.js b/playground/glob-import/root/follow-symlinks/packages/my-lib/components/b.js similarity index 100% rename from playground/glob-import/follow-symlinks/packages/my-lib/components/b.js rename to playground/glob-import/root/follow-symlinks/packages/my-lib/components/b.js diff --git a/playground/glob-import/import-meta-glob-pkg/index.js b/playground/glob-import/root/import-meta-glob-pkg/index.js similarity index 100% rename from playground/glob-import/import-meta-glob-pkg/index.js rename to playground/glob-import/root/import-meta-glob-pkg/index.js diff --git a/playground/glob-import/import-meta-glob-pkg/package.json b/playground/glob-import/root/import-meta-glob-pkg/package.json similarity index 100% rename from playground/glob-import/import-meta-glob-pkg/package.json rename to playground/glob-import/root/import-meta-glob-pkg/package.json diff --git a/playground/glob-import/imports-path/bar.js b/playground/glob-import/root/imports-path/bar.js similarity index 100% rename from playground/glob-import/imports-path/bar.js rename to playground/glob-import/root/imports-path/bar.js diff --git a/playground/glob-import/imports-path/foo.js b/playground/glob-import/root/imports-path/foo.js similarity index 100% rename from playground/glob-import/imports-path/foo.js rename to playground/glob-import/root/imports-path/foo.js diff --git a/playground/glob-import/index.html b/playground/glob-import/root/index.html similarity index 99% rename from playground/glob-import/index.html rename to playground/glob-import/root/index.html index 69de99c9486a31..52efd42debf111 100644 --- a/playground/glob-import/index.html +++ b/playground/glob-import/root/index.html @@ -101,7 +101,7 @@

Base