Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
!**/glob-import/dir/node_modules
!**/glob-import/root/dir/node_modules
.DS_Store
.idea
.pnpm-store
Expand Down
2 changes: 1 addition & 1 deletion docs/guide/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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});
Expand Down Expand Up @@ -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});
Expand Down
3 changes: 0 additions & 3 deletions packages/vite/src/node/plugins/importMetaGlob.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
29 changes: 16 additions & 13 deletions playground/glob-import/__tests__/glob-import.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
Expand All @@ -176,7 +176,7 @@ if (!isBuild) {
},
})

removeFile('dir/a.js')
removeFile('root/dir/a.js')
await expect
.poll(async () => {
const actualRemove = await resultElement.textContent()
Expand All @@ -187,25 +187,25 @@ 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)
})

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'])
Expand All @@ -219,15 +219,15 @@ 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({
'./array-test-dir/included.js': 'included',
'./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({
Expand Down Expand Up @@ -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')
}
})
Expand All @@ -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`)
Expand Down
10 changes: 5 additions & 5 deletions playground/glob-import/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ <h2>Base</h2>
</script>

<script type="module">
const relativeRawModules = import.meta.glob('../glob-import/dir/*.json', {
const relativeRawModules = import.meta.glob('../root/dir/*.json', {
query: '?raw',
eager: true,
import: 'default',
Expand Down
Loading
Loading