Skip to content

Commit 849ef9c

Browse files
authored
fix(error-codes): esm file should use .mjs ext (#3178)
1 parent 879ad87 commit 849ef9c

File tree

5 files changed

+42
-3
lines changed

5 files changed

+42
-3
lines changed

.changeset/config.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
"@module-federation/modern-js",
2323
"@module-federation/retry-plugin",
2424
"@module-federation/data-prefetch",
25-
"@module-federation/rsbuild-plugin"
25+
"@module-federation/rsbuild-plugin",
26+
"@module-federation/error-codes"
2627
]
2728
],
2829
"ignorePatterns": ["^alpha|^beta"],

.changeset/unlucky-cats-move.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@module-federation/error-codes': patch
3+
---
4+
5+
fix(error-codes): esm should use .mjs ext

packages/error-codes/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818
"access": "public"
1919
},
2020
"main": "./dist/index.cjs.js",
21-
"module": "./dist/index.esm.js",
21+
"module": "./dist/index.esm.mjs",
2222
"types": "./dist/index.cjs.d.ts",
2323
"exports": {
2424
".": {
25-
"import": "./dist/index.esm.js",
25+
"import": "./dist/index.esm.mjs",
2626
"require": "./dist/index.cjs.js"
2727
}
2828
},

packages/error-codes/project.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"outputPath": "packages/error-codes/dist",
1414
"main": "packages/error-codes/src/index.ts",
1515
"tsConfig": "packages/error-codes/tsconfig.lib.json",
16+
"rollupConfig": "packages/error-codes/rollup.config.js",
1617
"assets": [],
1718
"project": "packages/error-codes/package.json",
1819
"compiler": "swc",

packages/error-codes/rollup.config.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
module.exports = (rollupConfig, projectOptions) => {
2+
if (Array.isArray(rollupConfig.output)) {
3+
rollupConfig.output = rollupConfig.output.map((c) => ({
4+
...c,
5+
hoistTransitiveImports: false,
6+
entryFileNames:
7+
c.format === 'esm'
8+
? c.entryFileNames.replace('.js', '.mjs')
9+
: c.entryFileNames,
10+
chunkFileNames:
11+
c.format === 'esm'
12+
? c.chunkFileNames.replace('.js', '.mjs')
13+
: c.chunkFileNames,
14+
}));
15+
} else {
16+
rollupConfig.output = {
17+
...rollupConfig.output,
18+
19+
hoistTransitiveImports: false,
20+
entryFileNames:
21+
rollupConfig.output.format === 'esm'
22+
? rollupConfig.output.entryFileNames.replace('.js', '.mjs')
23+
: rollupConfig.output.entryFileNames,
24+
chunkFileNames:
25+
rollupConfig.output.format === 'esm'
26+
? rollupConfig.output.chunkFileNames.replace('.js', '.mjs')
27+
: rollupConfig.output.chunkFileNames,
28+
};
29+
}
30+
31+
return rollupConfig;
32+
};

0 commit comments

Comments
 (0)