Skip to content

Commit d084a8d

Browse files
committed
fix: Add file extensions to imports/exports in ESM type definitions
Closes #70
1 parent a322d2c commit d084a8d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

scripts/esm-post-process.mjs

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ async function buildEsm(filePath) {
3333
const file = await fs.readFile(path.join(process.cwd(), filePath));
3434
let content = file.toString();
3535

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

0 commit comments

Comments
 (0)