Bring back babel for ES5 builds (#3797)

* Bring back babel for ES5 builds

* Remove ts from babel
This commit is contained in:
Bram Kragten
2019-09-23 22:15:12 +02:00
committed by Paulus Schoutsen
parent 993d390ea5
commit a1b9a092d0
7 changed files with 617 additions and 237 deletions

36
build-scripts/babel.js Normal file
View File

@@ -0,0 +1,36 @@
module.exports.babelLoaderConfig = ({ latestBuild }) => {
if (latestBuild === undefined) {
throw Error("latestBuild not defined for babel loader config");
}
return {
test: /\.m?js$/,
use: {
loader: "babel-loader",
options: {
presets: [
!latestBuild && [
require("@babel/preset-env").default,
{ modules: false },
],
].filter(Boolean),
plugins: [
// Part of ES2018. Converts {...a, b: 2} to Object.assign({}, a, {b: 2})
[
"@babel/plugin-proposal-object-rest-spread",
{ loose: true, useBuiltIns: true },
],
// Only support the syntax, Webpack will handle it.
"@babel/syntax-dynamic-import",
[
require("@babel/plugin-proposal-decorators").default,
{ decoratorsBeforeExport: true },
],
[
require("@babel/plugin-proposal-class-properties").default,
{ loose: true },
],
],
},
},
};
};