Jack Hsu 811c50b92c feat(web): use babel-loader instead of ts-loader for web build builder
- removes the `differentialLoading` build option
- differential loading is always enabled for prod builds

BEFORE (without ESM):

Benchmark #1: nx build demo --prod
  Time (mean ± σ):     13.834 s ±  1.731 s    [User: 11.817 s, System: 1.352 s]
  Range (min … max):   11.947 s … 16.015 s    10 runs

AFTER (with ESM):

Benchmark #1: nx build demo --prod
  Time (mean ± σ):     18.711 s ±  1.310 s    [User: 12.172 s, System: 1.394 s]
  Range (min … max):   17.232 s … 20.770 s    10 runs
2019-09-05 15:34:01 -04:00

24 lines
534 B
TypeScript

import { Configuration } from 'webpack';
// Adds react preset for JSX support
function getBabelWebpackConfig(config: Configuration) {
const babelRuleOptions = config.module.rules.find(
r => r.loader === 'babel-loader'
).options as any;
const idx = babelRuleOptions.presets.findIndex(
p => Array.isArray(p) && p[0] === '@babel/preset-env'
);
babelRuleOptions.presets.splice(idx, 0, [
'@babel/preset-react',
{
useBuiltIns: true
}
]);
return config;
}
module.exports = getBabelWebpackConfig;