Skip to content

Commit

Permalink
fix: use file extensions on type imports so they work with `moduleRes…
Browse files Browse the repository at this point in the history
…olution: 'node16'` (#13947)
  • Loading branch information
Princesseuh authored Jul 25, 2023
1 parent a48bf88 commit aeef670
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/vite/scripts/postPatchTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ import { rewriteImports, walkDir } from './util'
const dir = dirname(fileURLToPath(import.meta.url))
const nodeDts = resolve(dir, '../dist/node/index.d.ts')

// rewrite `types/*` import to relative import
// rewrite `types/*` import to relative import with file extension
rewriteImports(nodeDts, (importPath) => {
if (importPath.startsWith('types/')) {
return '../../' + importPath
return (
'../../' + (importPath.endsWith('.js') ? importPath : importPath + '.js')
)
}
})

Expand Down

0 comments on commit aeef670

Please sign in to comment.