Skip to content

Commit

Permalink
build(package.json, rollup.config.js): fix esm build to meet Node.js …
Browse files Browse the repository at this point in the history
…standard

To meet Node.js standard, 2 things should be fixed:

* ESM file should use `.mjs` extention
instead of `.esm.js`.
* `module` field in `package.json` is not standard way of Node.js. Use
`exports` field instead.

fix styled-components#649
  • Loading branch information
tkamenoko committed Mar 20, 2024
1 parent d3b760f commit 51db107
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion package.json
Expand Up @@ -27,8 +27,15 @@
"colour"
],
"main": "dist/polished.cjs.js",
"module": "dist/polished.esm.js",
"module": "dist/polished.mjs",
"types": "lib/index.d.ts",
"exports": {
".": {
"types": "./lib/index.d.ts",
"import": "./dist/polished.mjs",
"default": "./dist/polished.cjs.js"
}
},
"sideEffects": false,
"scripts": {
"build": "yarn build:lib && yarn build:dist && yarn build:flow && yarn build:docs && yarn build:typescript",
Expand Down
2 changes: 1 addition & 1 deletion rollup.config.js
Expand Up @@ -44,7 +44,7 @@ const getBabelOptions = ({ useESModules }, targets) => ({
export default [
{
input,
output: { file: `dist/${name}.esm.js`, format: 'esm' },
output: { file: `dist/${name}.mjs`, format: 'esm' },
external,
plugins: [sourceMaps(), resolve(), babel(getBabelOptions({ useESModules: true }))],
},
Expand Down

0 comments on commit 51db107

Please sign in to comment.