Skip to content

Commit aeef670

Browse files
authored
fix: use file extensions on type imports so they work with moduleResolution: 'node16' (#13947)
1 parent a48bf88 commit aeef670

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

packages/vite/scripts/postPatchTypes.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@ import { rewriteImports, walkDir } from './util'
77
const dir = dirname(fileURLToPath(import.meta.url))
88
const nodeDts = resolve(dir, '../dist/node/index.d.ts')
99

10-
// rewrite `types/*` import to relative import
10+
// rewrite `types/*` import to relative import with file extension
1111
rewriteImports(nodeDts, (importPath) => {
1212
if (importPath.startsWith('types/')) {
13-
return '../../' + importPath
13+
return (
14+
'../../' + (importPath.endsWith('.js') ? importPath : importPath + '.js')
15+
)
1416
}
1517
})
1618

0 commit comments

Comments
 (0)