Skip to content

Commit

Permalink
feat(build): ✨ babel es & cjs build
Browse files Browse the repository at this point in the history
  • Loading branch information
navin-moorthy committed Sep 30, 2020
1 parent 7c6442a commit d22e80a
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
37 changes: 37 additions & 0 deletions .babelrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
const { NODE_ENV, BABEL_ENV } = process.env;
const cjs = NODE_ENV === "test" || BABEL_ENV === "commonjs";
const loose = true;

module.exports = {
presets: [
[
"@babel/env",
{
loose,
modules: false,
exclude: ["@babel/plugin-transform-regenerator"],
},
],
"@babel/preset-typescript",
"@babel/react",
],
plugins: [
[
"const-enum",
{
transform: "constObject",
},
],
"babel-plugin-transform-async-to-promises",
cjs && ["@babel/transform-modules-commonjs", { loose }],
[
"@babel/transform-runtime",
{
useESModules: !cjs,
version: require("./package.json").dependencies[
"@babel/runtime"
].replace(/^[^0-9]*/, ""),
},
],
].filter(Boolean),
};
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,7 @@ lerna-debug.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

#build
/es
/lib
10 changes: 10 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
"author": "Timeless <[email protected]>",
"scripts": {
"build-storybook": "build-storybook",
"build:commonjs": "rm -rf ./lib && BABEL_ENV=commonjs babel --extensions .ts,.tsx --ignore ./src/**/*.test.tsx ./src --out-dir lib",
"build:es": "rm -rf ./es && babel --extensions .ts,.tsx --ignore ./src/**/*.test.tsx ./src --out-dir es",
"commit": "gacp",
"format": "prettier --write \"./**/*.{js,ts,css,less,json,md,html,yml,yaml,pcss,jsx,tsx}\"",
"keys": "node scripts/build/keys",
Expand All @@ -26,6 +28,7 @@
"test": "jest"
},
"dependencies": {
"@babel/runtime": "^7.5.5",
"@chakra-ui/counter": "1.0.0-rc.3",
"@chakra-ui/hooks": "1.0.0-rc.3",
"@chakra-ui/utils": "1.0.0-rc.3",
Expand All @@ -45,7 +48,12 @@
"uuid": "8.3.0"
},
"devDependencies": {
"@babel/cli": "^7.11.6",
"@babel/core": "7.11.6",
"@babel/plugin-transform-runtime": "^7.11.5",
"@babel/preset-env": "^7.11.5",
"@babel/preset-react": "^7.10.4",
"@babel/preset-typescript": "^7.10.4",
"@commitlint/cli": "11.0.0",
"@commitlint/config-conventional": "11.0.0",
"@storybook/addon-a11y": "6.0.21",
Expand All @@ -69,6 +77,8 @@
"@typescript-eslint/parser": "4.1.1",
"babel-eslint": "10.1.0",
"babel-loader": "8.1.0",
"babel-plugin-const-enum": "^1.0.1",
"babel-plugin-transform-async-to-promises": "^0.8.15",
"chalk": "4.1.0",
"emotion": "10.0.27",
"eslint": "7.9.0",
Expand Down

0 comments on commit d22e80a

Please sign in to comment.