From bbf23b175412d7bf91c7dd9ad0fb290e53916f1d Mon Sep 17 00:00:00 2001 From: enisdenjo Date: Fri, 31 Mar 2023 14:22:04 +0200 Subject: [PATCH] fix: Add file extensions to imports/exports in ESM type definitions --- scripts/esm-post-process.mjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/esm-post-process.mjs b/scripts/esm-post-process.mjs index acdf36e..d996a1c 100644 --- a/scripts/esm-post-process.mjs +++ b/scripts/esm-post-process.mjs @@ -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(