Skip to content

Commit

Permalink
fix(@angular-devkit/build-angular): generate ES5 code in ES5 bundles …
Browse files Browse the repository at this point in the history
…for default browserslist configuration

(cherry picked from commit e414d9b)
  • Loading branch information
alan-agius4 authored and dgp1130 committed Mar 24, 2020
1 parent f99cc6f commit aac5693
Showing 1 changed file with 12 additions and 1 deletion.
Expand Up @@ -102,6 +102,17 @@ export async function process(options: ProcessBundleOptions): Promise<ProcessBun
let downlevelCode;
let downlevelMap;
if (downlevel) {
const {supportedBrowsers: targets = []} = options;

// todo: revisit this in version 10, when we update our defaults browserslist
// Without this workaround bundles will not be downlevelled because Babel doesn't know handle to 'op_mini all'
// See: https://github.com/babel/babel/issues/11155
if (Array.isArray(targets) && targets.includes('op_mini all')) {
targets.push('ie_mob 11');
} else if ('op_mini' in targets) {
targets['ie_mob'] = '11';
}

// Downlevel the bundle
const transformResult = await transformAsync(sourceCode, {
filename: options.filename,
Expand All @@ -113,7 +124,7 @@ export async function process(options: ProcessBundleOptions): Promise<ProcessBun
require.resolve('@babel/preset-env'),
{
// browserslist-compatible query or object of minimum environment versions to support
targets: options.supportedBrowsers,
targets,
// modules aren't needed since the bundles use webpack's custom module loading
modules: false,
// 'transform-typeof-symbol' generates slower code
Expand Down

0 comments on commit aac5693

Please sign in to comment.