Skip to content

Commit

Permalink
fix: updates imports that are more than one parent high (#201)
Browse files Browse the repository at this point in the history
  • Loading branch information
crutchcorn authored Jan 26, 2025
1 parent 1cc45a3 commit 82cf701
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/config/src/vite/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ import dts from 'vite-plugin-dts'
function ensureImportFileExtension({ content, extension }) {
// replace e.g. `import { foo } from './foo'` with `import { foo } from './foo.js'`
content = content.replace(
/(im|ex)port\s[\w{}/*\s,]+from\s['"]\.\.?\/[^.'"]+(?=['"];?)/gm,
/(im|ex)port\s[\w{}/*\s,]+from\s['"](?:\.\.?\/)+?[^.'"]+(?=['"];?)/gm,
`$&.${extension}`,
)

// replace e.g. `import('./foo')` with `import('./foo.js')`
content = content.replace(
/import\(['"]\.\.?\/[^.'"]+(?=['"];?)/gm,
/import\(['"](?:\.\.?\/)+?[^.'"]+(?=['"];?)/gm,
`$&.${extension}`,
)
return content
Expand Down

0 comments on commit 82cf701

Please sign in to comment.