Skip to content

Commit

Permalink
fix(config): bundle files referenced with imports field (#18887)
Browse files Browse the repository at this point in the history
  • Loading branch information
sapphi-red authored Dec 5, 2024
1 parent 1b54e50 commit 2b5926a
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/vite/src/node/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1768,7 +1768,7 @@ async function bundleConfigFile(

// externalize bare imports
build.onResolve(
{ filter: /^[^.].*/ },
{ filter: /^[^.#].*/ },
async ({ path: id, importer, kind }) => {
if (
kind === 'entry-point' ||
Expand Down
1 change: 1 addition & 0 deletions playground/config/__tests__/config.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ it('loadConfigFromFile', async () => {
4,
],
],
"importsField": "imports-field",
"moduleCondition": "import condition",
}
`)
Expand Down
1 change: 1 addition & 0 deletions playground/config/packages/entry/imports-field.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default 'imports-field'
3 changes: 3 additions & 0 deletions playground/config/packages/entry/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@
"type": "module",
"dependencies": {
"@vite/test-config-plugin-module-condition": "link:../plugin-module-condition"
},
"imports": {
"#imports-field": "./imports-field.ts"
}
}
2 changes: 2 additions & 0 deletions playground/config/packages/entry/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import moduleCondition from '@vite/test-config-plugin-module-condition'
import { array } from '../siblings/foo'
import importsField from '#imports-field'

export default {
array,
moduleCondition,
importsField,
}

0 comments on commit 2b5926a

Please sign in to comment.