From 1afe47f19e4710a5591986e94085ab209176c83a Mon Sep 17 00:00:00 2001 From: Chunpeng Huo Date: Sun, 29 Jul 2018 19:23:53 +1000 Subject: [PATCH] feat: upgrade to babel-preset-env Unify babelrc for webpack and cli bundler. Cleaned up webpack babelrc to use same plugins as other setup. Add IE10/11 support back to webpack setup as that is what Aurelia claimed to support. closes #754, #909 --- .../new/buildsystems/cli/transpilers/babel.js | 5 ++--- .../buildsystems/webpack/transpilers/babel.js | 6 ++---- lib/dependencies.json | 4 ---- lib/resources/content/babelrc | 16 ++-------------- .../content/{babelrc.webpack.js => babelrc.js} | 17 +++++++---------- lib/resources/content/babelrc.webpack | 5 ----- lib/resources/src/main-webpack.js | 1 - 7 files changed, 13 insertions(+), 41 deletions(-) rename lib/resources/content/{babelrc.webpack.js => babelrc.js} (65%) delete mode 100644 lib/resources/content/babelrc.webpack diff --git a/lib/commands/new/buildsystems/cli/transpilers/babel.js b/lib/commands/new/buildsystems/cli/transpilers/babel.js index 9c2baad44..a147ac2c1 100644 --- a/lib/commands/new/buildsystems/cli/transpilers/babel.js +++ b/lib/commands/new/buildsystems/cli/transpilers/babel.js @@ -10,6 +10,7 @@ module.exports = function(project) { project.addToContent( ProjectItem.resource('.eslintrc.json', 'content/eslintrc.json'), + ProjectItem.resource('.babelrc.js', 'content/babelrc.js'), ProjectItem.resource('.babelrc', 'content/babelrc') ).addToTasks( ProjectItem.resource('transpile.js', 'tasks/transpile.js'), @@ -18,10 +19,8 @@ module.exports = function(project) { 'babel-eslint', 'babel-plugin-syntax-flow', 'babel-plugin-transform-decorators-legacy', - 'babel-plugin-transform-es2015-modules-amd', - 'babel-plugin-transform-es2015-modules-commonjs', 'babel-plugin-transform-flow-strip-types', - 'babel-preset-es2015', + 'babel-preset-env', 'babel-preset-stage-1', 'babel-polyfill', 'babel-register', diff --git a/lib/commands/new/buildsystems/webpack/transpilers/babel.js b/lib/commands/new/buildsystems/webpack/transpilers/babel.js index 5391ba430..5a8e02f76 100644 --- a/lib/commands/new/buildsystems/webpack/transpilers/babel.js +++ b/lib/commands/new/buildsystems/webpack/transpilers/babel.js @@ -10,20 +10,18 @@ module.exports = function(project) { project.addToContent( ProjectItem.resource('.eslintrc.json', 'content/eslintrc.json'), - ProjectItem.resource('.babelrc.js', 'content/babelrc.webpack.js'), - ProjectItem.resource('.babelrc', 'content/babelrc.webpack') + ProjectItem.resource('.babelrc.js', 'content/babelrc.js'), + ProjectItem.resource('.babelrc', 'content/babelrc') ).addToDevDependencies( 'babel-eslint@7.2.3', 'eslint@3.19.0', 'babel-loader', 'babel-core', 'babel-plugin-syntax-flow', - 'babel-plugin-transform-class-properties', 'babel-plugin-transform-decorators-legacy', 'babel-plugin-transform-flow-strip-types', 'babel-polyfill', 'babel-preset-env', - 'babel-preset-es2015', 'babel-preset-stage-1', 'babel-register', 'babel-plugin-istanbul' diff --git a/lib/dependencies.json b/lib/dependencies.json index ddf0378bd..66d499615 100644 --- a/lib/dependencies.json +++ b/lib/dependencies.json @@ -22,14 +22,10 @@ "babel-loader": "^7.1.4", "babel-plugin-istanbul": "^4.1.5", "babel-plugin-syntax-flow": "^6.18.0", - "babel-plugin-transform-class-properties": "^6.24.1", "babel-plugin-transform-decorators-legacy": "^1.3.4", - "babel-plugin-transform-es2015-modules-amd": "^6.24.1", - "babel-plugin-transform-es2015-modules-commonjs": "^6.26.0", "babel-plugin-transform-flow-strip-types": "^6.22.0", "babel-polyfill": "^6.26.0", "babel-preset-env": "^1.6.1", - "babel-preset-es2015": "^6.24.1", "babel-preset-stage-1": "^6.24.1", "babel-register": "^6.26.0", "bluebird": "^3.5.1", diff --git a/lib/resources/content/babelrc b/lib/resources/content/babelrc index 2b0041b33..87316ba3a 100644 --- a/lib/resources/content/babelrc +++ b/lib/resources/content/babelrc @@ -1,17 +1,5 @@ { - "sourceMap": true, - "sourceRoot": "src", - "moduleIds": false, - "comments": false, - "compact": false, - "code": true, "presets": [ - ["es2015", {"loose": true}], - "stage-1" - ], - "plugins": [ - "syntax-flow", - "transform-decorators-legacy", - "transform-flow-strip-types" + "./.babelrc.js" ] -} +} \ No newline at end of file diff --git a/lib/resources/content/babelrc.webpack.js b/lib/resources/content/babelrc.js similarity index 65% rename from lib/resources/content/babelrc.webpack.js rename to lib/resources/content/babelrc.js index 4d2bde999..5f96dd630 100644 --- a/lib/resources/content/babelrc.webpack.js +++ b/lib/resources/content/babelrc.js @@ -2,8 +2,9 @@ module.exports = () => { return { "plugins": [ + "syntax-flow", "transform-decorators-legacy", - "transform-class-properties" + "transform-flow-strip-types" ], "presets": [ [ @@ -11,17 +12,13 @@ module.exports = () => { "targets": process.env.BABEL_TARGET === 'node' ? { "node": process.env.IN_PROTRACTOR ? '6' : 'current' } : { - "browsers": [ - "last 2 versions", - "not ie <= 11" - ], - "uglify": process.env.NODE_ENV === 'production', + "browsers": [ "last 2 versions" ] }, "loose": true, - "modules": process.env.BABEL_TARGET === 'node' ? 'commonjs' : false, - "useBuiltIns": true + "modules": process.env.BABEL_TARGET === 'node' ? 'commonjs' : false } - ] + ], + "stage-1" ] } -} \ No newline at end of file +} diff --git a/lib/resources/content/babelrc.webpack b/lib/resources/content/babelrc.webpack deleted file mode 100644 index 87316ba3a..000000000 --- a/lib/resources/content/babelrc.webpack +++ /dev/null @@ -1,5 +0,0 @@ -{ - "presets": [ - "./.babelrc.js" - ] -} \ No newline at end of file diff --git a/lib/resources/src/main-webpack.js b/lib/resources/src/main-webpack.js index c78344924..fd3c8401a 100644 --- a/lib/resources/src/main-webpack.js +++ b/lib/resources/src/main-webpack.js @@ -1,6 +1,5 @@ import environment from './environment'; import {PLATFORM} from 'aurelia-pal'; -import 'babel-polyfill'; import * as Bluebird from 'bluebird'; // remove out if you don't want a Promise polyfill (remove also from webpack.config.js)