Skip to content
This repository has been archived by the owner on Sep 10, 2022. It is now read-only.

Commit

Permalink
Reduce babel config (#349)
Browse files Browse the repository at this point in the history
* Reduce babel config

* Transpile es to cjs per file
  • Loading branch information
TrySound authored and istarkov committed Apr 11, 2017
1 parent 04c372a commit cf2910c
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 59 deletions.
61 changes: 36 additions & 25 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,30 +1,41 @@
{
"plugins": [
"babel-plugin-transform-function-bind",
"babel-plugin-transform-class-constructor-call",
["babel-plugin-transform-class-properties", { "loose": true }],
"babel-plugin-transform-export-extensions",
"babel-plugin-syntax-trailing-function-commas",
"babel-plugin-transform-object-rest-spread",
"babel-plugin-transform-async-to-generator",
"transform-function-bind",
"transform-class-constructor-call",
["transform-class-properties", { "loose": true }],
"transform-export-extensions",
"syntax-trailing-function-commas",
"transform-object-rest-spread",
"transform-async-to-generator",

"babel-plugin-transform-react-jsx",
"babel-plugin-syntax-jsx",
"babel-plugin-transform-react-display-name",
"transform-react-jsx",
"syntax-jsx",
"transform-react-display-name",

["babel-plugin-transform-es2015-template-literals", { "loose": true }],
"babel-plugin-transform-es2015-literals",
"babel-plugin-transform-es2015-function-name",
"babel-plugin-transform-es2015-arrow-functions",
"babel-plugin-transform-es2015-block-scoped-functions",
["babel-plugin-transform-es2015-classes", { "loose": true }],
"babel-plugin-transform-es2015-shorthand-properties",
["babel-plugin-transform-es2015-computed-properties", { "loose": true }],
["babel-plugin-transform-es2015-spread", { "loose": true }],
"babel-plugin-transform-es2015-parameters",
["babel-plugin-transform-es2015-destructuring", { "loose": true }],
"babel-plugin-transform-es2015-block-scoping",
["babel-plugin-transform-es2015-modules-commonjs", { "loose": true }],
"babel-plugin-transform-regenerator"
]
["transform-es2015-template-literals", { "loose": true }],
"transform-es2015-literals",
"transform-es2015-function-name",
"transform-es2015-arrow-functions",
"transform-es2015-block-scoped-functions",
["transform-es2015-classes", { "loose": true }],
"transform-es2015-shorthand-properties",
["transform-es2015-computed-properties", { "loose": true }],
["transform-es2015-spread", { "loose": true }],
"transform-es2015-parameters",
["transform-es2015-destructuring", { "loose": true }],
"transform-es2015-block-scoping",
"transform-regenerator"
],
"env": {
"cjs": {
"plugins": [
["transform-es2015-modules-commonjs", { "loose": true }]
]
},
"rollup": {
"plugins": [
"external-helpers"
]
}
}
}
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"license": "MIT",
"scripts": {
"lint": "eslint scripts src",
"test": "ava --concurrency=5",
"test:watch": "npm run test -- --watch",
"test": "cross-env BABEL_ENV=cjs ava --concurrency=5",
"test:watch": "npm test -- --watch",
"release": "babel-node scripts/release.js",
"postinstall": "babel-node scripts/installNestedPackageDeps.js"
},
Expand Down Expand Up @@ -53,6 +53,7 @@
"change-case": "^2.3.1",
"codecov": "^1.0.1",
"create-react-class": "^15.5.0",
"cross-env": "^4.0.0",
"enzyme": "^2.2.0",
"eslint": "^2.10.2",
"eslint-config-airbnb": "9.0.1",
Expand Down
6 changes: 4 additions & 2 deletions scripts/release.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ const run = async () => {
}).map(to => path.relative(sourceDir, to))

exec(
`cd ${sourceDir} && ${path.resolve(BIN)}/babel ${sourceFiles.join(' ')} ` +
`cd ${sourceDir} && ` +
'cross-env BABEL_ENV=cjs ' +
`${path.resolve(BIN)}/babel ${sourceFiles.join(' ')} ` +
`--out-dir ${path.resolve(outDir)}`
)

Expand Down Expand Up @@ -121,7 +123,7 @@ const run = async () => {

log(`Building ${packageName}...`)
const runRollup = build =>
'rollup --config scripts/rollup.config.js ' +
'cross-env BABEL_ENV=rollup rollup --config scripts/rollup.config.js ' +
`--environment BUILD:${build},PACKAGE_NAME:${packageName}`
if (exec([
runRollup('es'),
Expand Down
31 changes: 1 addition & 30 deletions scripts/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,36 +24,7 @@ const config = {
moduleName: libraryName,
plugins: [
babel({
exclude: 'node_modules/**',
babelrc: false,
plugins: [
'babel-plugin-transform-function-bind',
'babel-plugin-transform-class-constructor-call',
['babel-plugin-transform-class-properties', { loose: true }],
'babel-plugin-transform-export-extensions',
'babel-plugin-syntax-trailing-function-commas',
'babel-plugin-transform-object-rest-spread',
'babel-plugin-transform-async-to-generator',

'babel-plugin-transform-react-jsx',
'babel-plugin-syntax-jsx',
'babel-plugin-transform-react-display-name',

['babel-plugin-transform-es2015-template-literals', { loose: true }],
'babel-plugin-transform-es2015-literals',
'babel-plugin-transform-es2015-function-name',
'babel-plugin-transform-es2015-arrow-functions',
'babel-plugin-transform-es2015-block-scoped-functions',
['babel-plugin-transform-es2015-classes', { loose: true }],
'babel-plugin-transform-es2015-shorthand-properties',
['babel-plugin-transform-es2015-computed-properties', { loose: true }],
['babel-plugin-transform-es2015-spread', { loose: true }],
'babel-plugin-transform-es2015-parameters',
['babel-plugin-transform-es2015-destructuring', { loose: true }],
'babel-plugin-transform-es2015-block-scoping',
'babel-plugin-transform-regenerator',
'babel-plugin-external-helpers'
]
exclude: '**/node_modules/**'
})
]
}
Expand Down

0 comments on commit cf2910c

Please sign in to comment.