Skip to content

Commit 82cf701

Browse files
authored
fix: updates imports that are more than one parent high (#201)
1 parent 1cc45a3 commit 82cf701

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

packages/config/src/vite/index.js

Lines changed: 2 additions & 2 deletions
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)