diff --git a/.babelrc b/.babelrc deleted file mode 100644 index 141f9078..00000000 --- a/.babelrc +++ /dev/null @@ -1,40 +0,0 @@ -{ - "presets": [ - [ - "@babel/preset-env", - { - "loose": true, - "targets": { - "node": "8" - } - } - ], - "@babel/preset-react", - "@babel/preset-flow" - ], - "env": { - "test": { - "plugins": [ - "@babel/plugin-transform-react-jsx-source", - "istanbul" - ] - } - }, - "plugins": [ - "@babel/plugin-transform-flow-strip-types", - "@babel/plugin-syntax-dynamic-import", - "@babel/plugin-syntax-import-meta", - "@babel/plugin-proposal-class-properties", - "@babel/plugin-proposal-json-strings", - [ - "@babel/plugin-proposal-decorators", - { - "legacy": true - } - ], - "@babel/plugin-proposal-function-sent", - "@babel/plugin-proposal-export-namespace-from", - "@babel/plugin-proposal-numeric-separator", - "@babel/plugin-proposal-throw-expressions" - ] -} diff --git a/.babelrc.js b/.babelrc.js new file mode 100644 index 00000000..d77bc9d0 --- /dev/null +++ b/.babelrc.js @@ -0,0 +1,36 @@ +const { NODE_ENV } = process.env +const test = NODE_ENV === 'test' +const loose = true + +module.exports = { + presets: [ + [ + '@babel/preset-env', + { + loose, + ...(test ? { targets: { node: '8' } } : {}) + } + ], + '@babel/preset-react', + '@babel/preset-flow' + ], + plugins: [ + '@babel/plugin-transform-flow-strip-types', + '@babel/plugin-syntax-dynamic-import', + '@babel/plugin-syntax-import-meta', + ['@babel/plugin-proposal-class-properties', { loose }], + '@babel/plugin-proposal-json-strings', + [ + '@babel/plugin-proposal-decorators', + { + legacy: true + } + ], + '@babel/plugin-proposal-function-sent', + '@babel/plugin-proposal-export-namespace-from', + '@babel/plugin-proposal-numeric-separator', + '@babel/plugin-proposal-throw-expressions', + test && '@babel/plugin-transform-react-jsx-source', + test && 'istanbul' + ].filter(Boolean) +} diff --git a/rollup.config.js b/rollup.config.js index 1f39c0d5..acd6a018 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -68,38 +68,7 @@ export default { flow(), commonjs({ include: 'node_modules/**' }), babel({ - exclude: 'node_modules/**', - babelrc: false, - runtimeHelpers: true, - presets: [ - [ - '@babel/preset-env', - { - loose: true, - modules: false - } - ], - '@babel/preset-react', - '@babel/preset-flow' - ], - plugins: [ - ['@babel/plugin-transform-runtime', { useESModules: !cjs }], - '@babel/plugin-transform-flow-strip-types', - '@babel/plugin-syntax-dynamic-import', - '@babel/plugin-syntax-import-meta', - '@babel/plugin-proposal-class-properties', - '@babel/plugin-proposal-json-strings', - [ - '@babel/plugin-proposal-decorators', - { - legacy: true - } - ], - '@babel/plugin-proposal-function-sent', - '@babel/plugin-proposal-export-namespace-from', - '@babel/plugin-proposal-numeric-separator', - '@babel/plugin-proposal-throw-expressions' - ] + exclude: 'node_modules/**' }), umd ? replace({