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
1 change: 1 addition & 0 deletions packages/vite/src/node/plugins/resolve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,7 @@ function resolveSubpathImports(
}
}

if (importsPath == null) return
return importsPath + postfix
}

Expand Down
4 changes: 4 additions & 0 deletions playground/resolve-tsconfig-paths/__tests__/resolve.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ test('import from .js', async () => {
await expect.poll(() => page.textContent('.js')).toMatch('[success]')
})

test('import using # prefixed path', async () => {
await expect.poll(() => page.textContent('.hash')).toMatch('[success]')
})

test('fallback works', async () => {
await expect.poll(() => page.textContent('.fallback')).toMatch('[success]')
})
Expand Down
6 changes: 6 additions & 0 deletions playground/resolve-tsconfig-paths/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ <h2>Import from .js</h2>
<h2>Fallback works</h2>
<p class="fallback"></p>

<h2>Import using # prefixed path</h2>
<p class="hash"></p>

<h2>Nested tsconfig.json & references / include works</h2>
<p class="nested-a"></p>
<p class="nested-b"></p>
Expand All @@ -27,6 +30,9 @@ <h2>Nested tsconfig.json & references / include works</h2>
import fallback from '@fallback/fallback'
text('.fallback', fallback)

import hash from './src/hash.ts'
text('.hash', hash)

import { valueA, valueB } from './src/nested/index.ts'
text('.nested-a', valueA)
text('.nested-b', valueB)
Expand Down
1 change: 1 addition & 0 deletions playground/resolve-tsconfig-paths/src/hash.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from '#/imported'
3 changes: 2 additions & 1 deletion playground/resolve-tsconfig-paths/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"noEmit": true,
"paths": {
"@/*": ["./src/*"],
"@fallback/*": ["./src/*", "./fallback/*"]
"@fallback/*": ["./src/*", "./fallback/*"],
"#/*": ["./src/*"]
}
},
"exclude": ["./__tests__"]
Expand Down
Loading