Skip to content

Commit

Permalink
fix(build): fix ESM dist file extension to .mjs
Browse files Browse the repository at this point in the history
Lack of 'type' field in package.json, all .js files are treated as CJS.
To make ESM dist file treated as ESM, update dist file extension as .mjs.

Ref https://nodejs.org/api/packages.html#type

Fix #3123
  • Loading branch information
netil committed Mar 16, 2023
1 parent e617e02 commit 24fcc5b
Show file tree
Hide file tree
Showing 3 changed files with 6,337 additions and 10,338 deletions.
7 changes: 4 additions & 3 deletions config/rollup/esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ const plugins = [
}),
typescript(),
replace({
"__VERSION__": version
"__VERSION__": version,
preventAssignment: true
})
];
const external = id => /^d3-/.test(id);
Expand All @@ -37,7 +38,7 @@ const bbPlugins = fs.readdirSync(path.resolve(__dirname, "../../src/Plugin/"), {
.map(({name}) => ({
input: `src/Plugin/${name}/index.ts`,
output: {
file: `dist/plugin/billboardjs-plugin-${name}.esm.js`,
file: `dist/plugin/billboardjs-plugin-${name}.esm.mjs`,
format: "es",
banner: getBanner(true)
},
Expand All @@ -49,7 +50,7 @@ export default [
{
input: "src/index.esm.ts",
output: {
file: "dist/billboard.esm.js",
file: "dist/billboard.esm.mjs",
format: "es",
banner: getBanner()
},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "Re-usable easy interface JavaScript chart library, based on D3 v4+",
"homepage": "https://naver.github.io/billboard.js/",
"main": "dist/billboard.js",
"module": "dist/billboard.esm.js",
"module": "dist/billboard.esm.mjs",
"types": "types/index.d.ts",
"scripts": {
"start": "webpack-dev-server --open",
Expand Down
Loading

0 comments on commit 24fcc5b

Please sign in to comment.