Skip to content

Commit 2b5926a

Browse files
authored
fix(config): bundle files referenced with imports field (#18887)
1 parent 1b54e50 commit 2b5926a

File tree

5 files changed

+8
-1
lines changed

5 files changed

+8
-1
lines changed

packages/vite/src/node/config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1768,7 +1768,7 @@ async function bundleConfigFile(
17681768

17691769
// externalize bare imports
17701770
build.onResolve(
1771-
{ filter: /^[^.].*/ },
1771+
{ filter: /^[^.#].*/ },
17721772
async ({ path: id, importer, kind }) => {
17731773
if (
17741774
kind === 'entry-point' ||

playground/config/__tests__/config.spec.ts

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ it('loadConfigFromFile', async () => {
2727
4,
2828
],
2929
],
30+
"importsField": "imports-field",
3031
"moduleCondition": "import condition",
3132
}
3233
`)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export default 'imports-field'

playground/config/packages/entry/package.json

+3
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,8 @@
33
"type": "module",
44
"dependencies": {
55
"@vite/test-config-plugin-module-condition": "link:../plugin-module-condition"
6+
},
7+
"imports": {
8+
"#imports-field": "./imports-field.ts"
69
}
710
}
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import moduleCondition from '@vite/test-config-plugin-module-condition'
22
import { array } from '../siblings/foo'
3+
import importsField from '#imports-field'
34

45
export default {
56
array,
67
moduleCondition,
8+
importsField,
79
}

0 commit comments

Comments
 (0)