Skip to content

Commit

Permalink
fix: Add file extensions to imports/exports in ESM type definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
enisdenjo committed Mar 31, 2023
1 parent fbb763a commit 48775be
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions scripts/esm-post-process.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ async function buildEsm(filePath) {
const file = await fs.readFile(path.join(process.cwd(), filePath));
let content = file.toString();

if (fileExt === 'js') {
// add .mjs to all import/export statements, but only on files (keep directory imports as is)
if (fileExt === 'js' || fileExt === 'ts') {
// add .mjs to all import/export statements, also in the type definitions
for (const match of content.matchAll(/from '(\.?\.\/[^']*)'/g)) {
const [statement, relImportPath] = match;
const absImportPath = path.resolve(
Expand Down

0 comments on commit 48775be

Please sign in to comment.