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

Commit

Permalink
feat: use babel-preset-env (#255)
Browse files Browse the repository at this point in the history
  • Loading branch information
christophehurpeau authored Feb 27, 2017
1 parent 00ca4fa commit cfeb71a
Show file tree
Hide file tree
Showing 4 changed files with 148 additions and 118 deletions.
17 changes: 6 additions & 11 deletions config/build/babelrc.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { buildPreset as preset2015 } from 'babel-preset-es2015';
import presetLatest from 'babel-preset-latest';
import presetEnv from 'babel-preset-env';
import presetReact from 'babel-preset-react';
import preset2016 from 'babel-preset-es2016';
import preset2017 from 'babel-preset-es2017';
import presetStage1 from 'babel-preset-stage-1';
import pluginReactRequire from 'babel-plugin-react-require';
import pluginTransformRuntime from 'babel-plugin-transform-runtime';
import pluginTransformExportDefaultName from 'babel-plugin-transform-export-default-name-forked';
import pluginMinifyReplace from 'babel-plugin-minify-replace';
import pluginNodeEnvInline from 'babel-plugin-transform-node-env-inline';
Expand All @@ -16,20 +14,17 @@ import pluginReactJsxSelf from 'babel-plugin-transform-react-jsx-self';
import { vitaminResolve } from '../utils';

export default (env, dev) => ({
// order is: last to first
presets: [
env === 'client' && [preset2015, { modules: false }],
env === 'client' ? [presetLatest, { es2015: { modules: false } }]
: [presetEnv, { modules: false, targets: { node: 'current' }, useBuiltIns: true }],
presetReact,
preset2016,
preset2017,
presetStage1,
].filter(Boolean),
// order is: first to last
plugins: [
// Make optional the explicit import of React in JSX files
pluginReactRequire,
// Add Object.entries, Object.values and other ES2017 functionalities.
// In the client, we prefer solution like https://polyfill.io/v2/docs/, to keep the
// bundle size the smallest possible.
env === 'server' && pluginTransformRuntime,
// Adds component stack to warning messages
dev && pluginReactJsxSource,
// Adds __self attribute to JSX which React will use for some warnings
Expand Down
2 changes: 1 addition & 1 deletion config/utils/transpile.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Brings ES6 to vitamin CLI and build modules (not src modules)
require('babel-register')({
sourceRoot: process.env.VITAMIN_PATH,
presets: ['es2015-node6', 'stage-1'],
presets: [['env', { targets: { node: 'current' } }], 'stage-1'],
ignore: false,
only: /vitaminjs\/(bin|config)/,
});
7 changes: 2 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,8 @@
"babel-plugin-transform-node-env-inline": "^6.8.0",
"babel-plugin-transform-react-jsx-self": "^6.22.0",
"babel-plugin-transform-react-jsx-source": "^6.22.0",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-es2015": "^6.22.0",
"babel-preset-es2015-node6": "^0.4.0",
"babel-preset-es2016": "^6.22.0",
"babel-preset-es2017": "^6.22.0",
"babel-preset-env": "^1.1.9",
"babel-preset-latest": "^6.22.0",
"babel-preset-react": "^6.23.0",
"babel-preset-stage-1": "^6.22.0",
"babel-register": "^6.23.0",
Expand Down
Loading

0 comments on commit cfeb71a

Please sign in to comment.