Skip to content

Commit d05f035

Browse files
fix: correctly add file extensions for relative imports (#153)
1 parent 747151d commit d05f035

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

packages/config/src/vite/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ import dts from 'vite-plugin-dts'
1313
function ensureImportFileExtension({ content, extension }) {
1414
// replace e.g. `import { foo } from './foo'` with `import { foo } from './foo.js'`
1515
content = content.replace(
16-
/(im|ex)port\s[\w{}/*\s,]+from\s['"]\.\/[^.'"]+(?=['"];?)/gm,
16+
/(im|ex)port\s[\w{}/*\s,]+from\s['"]\.\.?\/[^.'"]+(?=['"];?)/gm,
1717
`$&.${extension}`,
1818
)
1919

2020
// replace e.g. `import('./foo')` with `import('./foo.js')`
2121
content = content.replace(
22-
/import\(['"]\.\/[^.'"]+(?=['"];?)/gm,
22+
/import\(['"]\.\.?\/[^.'"]+(?=['"];?)/gm,
2323
`$&.${extension}`,
2424
)
2525
return content

0 commit comments

Comments
 (0)