Skip to content

Commit

Permalink
Merge pull request #135 from Yoctol/build-cjs-and-esm
Browse files Browse the repository at this point in the history
build both cjs and esm
  • Loading branch information
chentsulin authored Sep 8, 2021
2 parents aac4609 + 3e459f2 commit 6362af7
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6,621 deletions.
8 changes: 7 additions & 1 deletion .babelrc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
module.exports = {
presets: [
'@babel/preset-env',
[
'@babel/preset-env',
{
targets: 'defaults',
modules: process.env.ESM === 'true' ? false : 'commonjs',
},
],
'@babel/preset-react',
'@babel/preset-typescript',
],
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
},
"main": "lib/index.js",
"scripts": {
"build": "npm run clean && tsc -p tsconfig.build.json",
"build": "npm run clean && npm run build:cjs && npm run build:esm",
"build:cjs": "babel src -d lib --extensions '.ts,.tsx' --ignore '**/__tests__/**' && tsc -p tsconfig.build.json -m commonjs --emitDeclarationOnly",
"build:esm": "cross-env ESM=true babel src -d lib/esm --extensions '.ts,.tsx' --ignore '**/__tests__/**' && tsc -p tsconfig.build.json -m esnext --emitDeclarationOnly --outDir lib/esm",
"check": "tsc --noEmit",
"clean": "rimraf lib",
"deploy": "gh-pages -d demo -b gh-pages -m 'Auto-generated commit [ci skip]'",
Expand Down Expand Up @@ -88,5 +90,9 @@
"d3",
"react",
"word-cloud"
]
],
"exports": {
"import": "./esm/index.js",
"require": "./index.js"
}
}
Loading

0 comments on commit 6362af7

Please sign in to comment.