-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from KleeGroup/feature-updates-and-polyfill
Feature updates and polyfill
- Loading branch information
Showing
9 changed files
with
98 additions
and
156 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
node_modules | ||
dist | ||
.history |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,83 @@ | ||
var decoratorLegacyPlugin = require('babel-plugin-transform-decorators-legacy'); | ||
//see https://github.com/babel/babel/commit/b5b7e346a04c99da8793e2c65cc3b3c7c720253d | ||
let env = process.env.BABEL_ENV || process.env.NODE_ENV; | ||
if (env !== 'development' && env !== 'test' && env !== 'production') { | ||
throw new Error( | ||
'Using `focus-preset-babel` requires that you specify `NODE_ENV` or ' + | ||
'`BABEL_ENV` environment variables. Valid values are "development" ' + | ||
'"test", and "production". Instead, received: ' + | ||
JSON.stringify(env) + | ||
'.' | ||
); | ||
} | ||
let LEGACY_EXPORTS; | ||
if (process.env.LEGACY_EXPORTS) { | ||
LEGACY_EXPORTS = JSON.parse(process.env.LEGACY_EXPORTS) | ||
} else { | ||
LEGACY_EXPORTS = false; | ||
} | ||
|
||
let LEGACY_LODASH; | ||
if (process.env.LEGACY_LODASH) { | ||
LEGACY_LODASH = JSON.parse(process.env.LEGACY_LODASH) | ||
} else { | ||
LEGACY_LODASH = false; | ||
} | ||
|
||
|
||
let browsers = process.env.BROWSERS || ">1%|last 4 versions|Firefox ESR|not ie < 9"; | ||
|
||
const plugins = [ | ||
'babel-plugin-transform-decorators-legacy', | ||
'babel-plugin-transform-class-properties', | ||
['babel-plugin-transform-object-rest-spread', { useBuiltIns: true }], | ||
'babel-plugin-transform-function-bind', | ||
['babel-plugin-transform-react-jsx', { useBuiltIns: true }], | ||
['babel-plugin-transform-runtime', { helpers: false, polyfill: false, regenerator: true }], | ||
['babel-plugin-transform-regenerator', { async: false }], | ||
'babel-plugin-syntax-dynamic-import' | ||
// 'babel-plugin-transform-proto-to-assign', | ||
// ['babel-plugin-transform-es2015-classes', { loose: true }] | ||
]; | ||
|
||
if (!LEGACY_LODASH) { | ||
plugins.push('babel-plugin-lodash'); | ||
} | ||
|
||
if (LEGACY_EXPORTS) { | ||
plugins.push('babel-plugin-add-module-exports'); | ||
} | ||
|
||
module.exports = { | ||
presets: [ | ||
require('babel-preset-stage-0'), | ||
require('babel-preset-react'), | ||
require('babel-preset-es2015') | ||
], | ||
plugins: [ | ||
require('babel-plugin-transform-class-properties'), | ||
decoratorLegacyPlugin.__esModule ? decoratorLegacyPlugin.default: decoratorLegacyPlugin, | ||
require('babel-plugin-add-module-exports'), | ||
require('babel-plugin-transform-proto-to-assign'), | ||
[require('babel-plugin-transform-es2015-classes'), {loose: true}] | ||
], | ||
env: { | ||
development: { | ||
presets: [ | ||
require('babel-preset-react-hmre') | ||
] | ||
}, | ||
production: { | ||
plugins: ["transform-react-remove-prop-types"] | ||
presets: [ | ||
// Latest stable ECMAScript features | ||
[ | ||
'babel-preset-env', | ||
{ | ||
targets: { | ||
browsers: browsers.split('|'), | ||
}, | ||
// forceAllTransforms: !!process.env.HOT_RELOAD, | ||
uglify: !!process.env.HOT_RELOAD || LEGACY_EXPORTS, | ||
// Enable polyfill transforms | ||
useBuiltIns: true, | ||
// Do not transform modules to CJS | ||
modules: LEGACY_EXPORTS ? 'commonjs' : false | ||
}, | ||
], | ||
'babel-preset-react' | ||
], | ||
plugins, | ||
env: { | ||
development: { | ||
plugins: [ | ||
'babel-plugin-transform-react-jsx-source', | ||
'babel-plugin-transform-react-jsx-self', | ||
'react-hot-loader/babel' | ||
] | ||
}, | ||
production: { | ||
plugins: [ | ||
'transform-react-remove-prop-types' | ||
] | ||
} | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.