Skip to content

Commit

Permalink
fix(common): CHECKOUT-4789 Apply polyfills to external dependencies f…
Browse files Browse the repository at this point in the history
…or targeted environments
  • Loading branch information
davidchin committed Apr 1, 2020
1 parent cf9fc28 commit 864fd31
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 24 deletions.
57 changes: 38 additions & 19 deletions webpack-common.config.js
Expand Up @@ -49,29 +49,48 @@ async function getBaseConfig() {
};
};

const babelLoaderRule = {
test: /\.[tj]s$/,
include: srcPath,
loader: 'babel-loader',
options: {
presets: [
[
'@babel/preset-env',
{
corejs: 3,
targets: [
'defaults',
'ie 11',
],
useBuiltIns: 'usage',
},
]
const babelEnvPreset = [
'@babel/preset-env',
{
corejs: 3,
targets: [
'defaults',
'ie 11',
],
useBuiltIns: 'usage',
},
};
];

const babelLoaderRules = [
{
test: /\.[tj]s$/,
loader: 'babel-loader',
include: srcPath,
options: {
presets: [
babelEnvPreset,
],
},
},
{
test: /\.js$/,
loader: 'babel-loader',
include: path.join(__dirname, 'node_modules'),
exclude: [
/\/node_modules\/core-js\//,
/\/node_modules\/webpack\//,
],
options: {
presets: [
babelEnvPreset,
],
sourceType: 'unambiguous',
}
},
];

module.exports = {
babelLoaderRule,
babelLoaderRules,
getBaseConfig,
libraryEntries,
libraryName,
Expand Down
6 changes: 3 additions & 3 deletions webpack-server.config.js
Expand Up @@ -5,7 +5,7 @@ const { DefinePlugin } = require('webpack');
const WebpackAssetsManifest = require('webpack-assets-manifest');

const { getNextVersion, transformManifest } = require('./scripts/webpack');
const { babelLoaderRule, getBaseConfig, libraryEntries, libraryName, srcPath } = require('./webpack-common.config');
const { babelLoaderRules, getBaseConfig, libraryEntries, libraryName, srcPath } = require('./webpack-common.config');

const baseOutputPath = path.join(__dirname, 'dist-server');

Expand All @@ -27,7 +27,7 @@ async function getServerConfig(options, argv) {
},
module: {
rules: [
babelLoaderRule,
...babelLoaderRules,
...baseConfig.module.rules,
],
},
Expand Down Expand Up @@ -62,7 +62,7 @@ async function getServerLoaderConfig(options, argv) {
},
module: {
rules: [
babelLoaderRule,
...babelLoaderRules,
...baseConfig.module.rules,
],
},
Expand Down
4 changes: 2 additions & 2 deletions webpack.config.js
Expand Up @@ -2,7 +2,7 @@ const path = require('path');
const { DefinePlugin } = require('webpack');
const nodeExternals = require('webpack-node-externals');

const { babelLoaderRule, getBaseConfig, libraryEntries, libraryName } = require('./webpack-common.config');
const { babelLoaderRules, getBaseConfig, libraryEntries, libraryName } = require('./webpack-common.config');

const outputPath = path.join(__dirname, 'dist');

Expand All @@ -21,7 +21,7 @@ async function getUmdConfig(options, argv) {
},
module: {
rules: [
babelLoaderRule,
...babelLoaderRules,
...baseConfig.module.rules,
],
},
Expand Down

0 comments on commit 864fd31

Please sign in to comment.