Skip to content

Commit 2a52671

Browse files
authored
fix(rsbuild-plugin): correct ESM output extension (#3870)
1 parent 1485fcf commit 2a52671

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

packages/rsbuild-plugin/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,22 @@
1515
"exports": {
1616
".": {
1717
"types": "./dist/index.cjs.d.ts",
18-
"import": "./dist/index.esm.js",
18+
"import": "./dist/index.esm.mjs",
1919
"require": "./dist/index.cjs.js"
2020
},
2121
"./utils": {
2222
"types": "./dist/utils.cjs.d.ts",
23-
"import": "./dist/utils.esm.js",
23+
"import": "./dist/utils.esm.mjs",
2424
"require": "./dist/utils.cjs.js"
2525
},
2626
"./constant": {
2727
"types": "./dist/constant.cjs.d.ts",
28-
"import": "./dist/constant.esm.js",
28+
"import": "./dist/constant.esm.mjs",
2929
"require": "./dist/constant.cjs.js"
3030
}
3131
},
3232
"main": "./dist/index.cjs.js",
33-
"module": "./dist/index.esm.js",
33+
"module": "./dist/index.esm.mjs",
3434
"typesVersions": {
3535
"*": {
3636
".": [

packages/rsbuild-plugin/rollup.config.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,13 @@ module.exports = (rollupConfig, _projectOptions) => {
1616
utils: 'packages/rsbuild-plugin/src/utils/index.ts',
1717
constant: 'packages/rsbuild-plugin/src/constant.ts',
1818
};
19+
20+
rollupConfig.output.forEach((output) => {
21+
output.entryFileNames = `[name].${output.format === 'esm' ? 'esm' : 'cjs'}.${
22+
output.format === 'esm' ? 'mjs' : 'js'
23+
}`;
24+
});
25+
26+
// rollupConfig
1927
return rollupConfig;
2028
};

0 commit comments

Comments
 (0)