Skip to content

Commit

Permalink
Refactor babel config (bvaughn#1019)
Browse files Browse the repository at this point in the history
Refactor babel config
  • Loading branch information
TrySound authored Feb 28, 2018
1 parent 8b6b911 commit 0748c2a
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 359 deletions.
102 changes: 0 additions & 102 deletions .babelrc

This file was deleted.

47 changes: 47 additions & 0 deletions .babelrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
const env = process.env.NODE_ENV;

if (env === 'commonjs' || env === 'es') {
module.exports = {
ignore: [
'*.jest.js',
'*.e2e.js',
'*.ssr.js',
'*.example.js',
'source/demo',
'source/jest-*.js',
'source/TestUtils.js',
],
plugins: [
'transform-runtime',
['flow-react-proptypes', {deadCode: true}],
['transform-react-remove-prop-types', {mode: 'wrap'}],
],
presets: [['env', {modules: false}], 'react', 'flow', 'stage-2'],
};

if (env === 'commonjs') {
module.exports.plugins.push('transform-es2015-modules-commonjs');
}
}

if (env === 'development') {
module.exports = {
presets: ['react', 'flow', 'stage-2'],
};
}

if (env === 'production') {
module.exports = {
comments: false,
plugins: ['transform-runtime'],
presets: ['env', 'react', 'flow', 'stage-2'],
};
}

if (env === 'test') {
module.exports = {
comments: false,
plugins: ['transform-es2015-modules-commonjs'],
presets: ['react', 'flow', 'stage-2'],
};
}
21 changes: 10 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
"scripts": {
"build:types": "flow-copy-source --ignore \"**/*.{jest,e2e,ssr,example}.js\" source/WindowScroller dist/es/WindowScroller && flow-copy-source --ignore \"**/*.{jest,e2e,ssr,example}.js\" source/AutoSizer dist/es/AutoSizer ",
"build": "npm run build:commonjs && npm run build:css && npm run build:es && npm run build:demo && npm run build:umd",
"build:commonjs": "npm run clean:commonjs && cross-env NODE_ENV=production cross-env BABEL_ENV=commonjs babel source --out-dir dist/commonjs",
"build:commonjs": "npm run clean:commonjs && cross-env NODE_ENV=commonjs babel source --out-dir dist/commonjs",
"build:css": "postcss source/styles.css -o styles.css --use autoprefixer",
"build:demo": "npm run clean:demo && cross-env NODE_ENV=production webpack --config webpack.config.demo.js -p --bail",
"build:es": "npm run clean:es && npm run build:types && cross-env NODE_ENV=production cross-env BABEL_ENV=es babel source --out-dir dist/es",
"build:es": "npm run clean:es && npm run build:types && cross-env NODE_ENV=es babel source --out-dir dist/es",
"build:umd": "npm run clean:umd && cross-env NODE_ENV=production webpack --config webpack.config.umd.js --bail",
"check-all": "yarn prettier && yarn lint && yarn flow",
"ci-check": "yarn prettier:diff && yarn lint && yarn flow",
Expand All @@ -32,13 +32,18 @@
"prettier:diff": "prettier --list-different '{playground,source}/**/*.js'",
"postpublish": "npm run deploy",
"prepublish": "npm run build",
"start": "webpack-dev-server --hot --config webpack.config.dev.js",
"start": "cross-env NODE_ENV=development webpack-dev-server --hot --config webpack.config.dev.js",
"test": "npm run test:jest",
"test:jest": "jest --no-watchman --runInBand",
"test:ci": "jest --no-watchman --maxWorkers 2 --coverage && codecov",
"watch": "watch 'clear && npm run test -s' source",
"watch:jest": "jest --no-watchman --watch"
},
"babel": {
"presets": [
"./.babelrc.js"
]
},
"files": [
"dist",
"styles.css"
Expand Down Expand Up @@ -98,15 +103,14 @@
"babel-jest": "^22.0.4",
"babel-loader": "7.1.2",
"babel-plugin-flow-react-proptypes": "^13.0.0",
"babel-plugin-react-transform": "^3.0.0",
"babel-plugin-transform-es2015-modules-commonjs": "^6.26.0",
"babel-plugin-transform-react-remove-prop-types": "^0.4.12",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-polyfill": "^6.26.0",
"babel-preset-env": "^1.6.1",
"babel-preset-flow": "^6.23.0",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-1": "^6.24.1",
"bluebird": "^3.0.5",
"babel-preset-stage-2": "^6.24.1",
"codecov": "^2.2.0",
"codemirror": "^5.18.0",
"cross-env": "^5.0.1",
Expand All @@ -121,12 +125,10 @@
"eslint-plugin-prettier": "^2.4.0",
"eslint-plugin-react": "^7.5.1",
"eslint-plugin-relay": "^0.0.20",
"express": "^4.13.3",
"extract-text-webpack-plugin": "^3.0.2",
"file-loader": "^1.1.6",
"flow-bin": "^0.63.1",
"flow-copy-source": "^1.2.1",
"fs-extra": "^4.0.0",
"gh-pages": "^1.0.0",
"html-webpack-plugin": "^2.30.1",
"husky": "^0.14.3",
Expand All @@ -144,9 +146,6 @@
"react-dom": "^16.0.0",
"react-router": "^4.1.1",
"react-router-dom": "^4.1.1",
"react-transform-catch-errors": "^1.0.2",
"react-transform-hmr": "^1.0.2",
"redbox-react": "^1.4.3",
"rimraf": "^2.4.3",
"style-loader": "^0.19.1",
"watch": "^1.0.2",
Expand Down
Loading

0 comments on commit 0748c2a

Please sign in to comment.