From 705a6d63599b8498df3f5d6752ba1ee64f40d670 Mon Sep 17 00:00:00 2001 From: Dmitry Lyzo Date: Fri, 4 Dec 2020 00:49:37 +0300 Subject: [PATCH] Extract Babel config --- babel.config.js | 20 ++++++++++++++++++++ package.json | 16 ---------------- webpack.common.js | 7 +------ 3 files changed, 21 insertions(+), 22 deletions(-) create mode 100644 babel.config.js diff --git a/babel.config.js b/babel.config.js new file mode 100644 index 0000000000..08e71d91f5 --- /dev/null +++ b/babel.config.js @@ -0,0 +1,20 @@ +module.exports = { + babelrcRoots: [ + // Keep the root as a root + '.' + ], + presets: [ + [ + '@babel/preset-env', + { + useBuiltIns: 'usage', + corejs: 3 + } + ] + ], + plugins: [ + '@babel/plugin-proposal-class-properties', + '@babel/plugin-proposal-private-methods', + 'babel-plugin-dynamic-import-polyfill' + ] +}; diff --git a/package.json b/package.json index 2cfbd724ea..ac4b8d508d 100644 --- a/package.json +++ b/package.json @@ -77,22 +77,6 @@ "workbox-core": "^5.1.4", "workbox-precaching": "^5.1.4" }, - "babel": { - "presets": [ - [ - "@babel/preset-env", - { - "useBuiltIns": "usage", - "corejs": 3 - } - ] - ], - "plugins": [ - "@babel/plugin-proposal-class-properties", - "@babel/plugin-proposal-private-methods", - "babel-plugin-dynamic-import-polyfill" - ] - }, "browserslist": [ "last 2 Firefox versions", "last 2 Chrome versions", diff --git a/webpack.common.js b/webpack.common.js index f0d7502d9e..09219a4757 100644 --- a/webpack.common.js +++ b/webpack.common.js @@ -1,7 +1,6 @@ const path = require('path'); const { CleanWebpackPlugin } = require('clean-webpack-plugin'); const CopyPlugin = require('copy-webpack-plugin'); -const packageConfig = require('./package.json'); const WorkboxPlugin = require('workbox-webpack-plugin'); const HtmlWebpackPlugin = require('html-webpack-plugin'); @@ -93,10 +92,7 @@ module.exports = { test: /\.js$/, exclude: /node_modules[\\/](?!@uupaa[\\/]dynamic-import-polyfill|date-fns|epubjs|flv.js|libarchive.js)/, use: [{ - loader: 'babel-loader', - options: { - presets: packageConfig.babel.presets - } + loader: 'babel-loader' }] }, /* modules that Babel breaks when transforming to ESM */ @@ -105,7 +101,6 @@ module.exports = { use: [{ loader: 'babel-loader', options: { - presets: packageConfig.babel.presets, plugins: [ '@babel/transform-modules-umd' ]