Skip to content

Commit aac5693

Browse files
alan-agius4dgp1130
authored andcommitted
fix(@angular-devkit/build-angular): generate ES5 code in ES5 bundles for default browserslist configuration
(cherry picked from commit e414d9b)
1 parent f99cc6f commit aac5693

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

packages/angular_devkit/build_angular/src/utils/process-bundle.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,17 @@ export async function process(options: ProcessBundleOptions): Promise<ProcessBun
102102
let downlevelCode;
103103
let downlevelMap;
104104
if (downlevel) {
105+
const {supportedBrowsers: targets = []} = options;
106+
107+
// todo: revisit this in version 10, when we update our defaults browserslist
108+
// Without this workaround bundles will not be downlevelled because Babel doesn't know handle to 'op_mini all'
109+
// See: https://github.com/babel/babel/issues/11155
110+
if (Array.isArray(targets) && targets.includes('op_mini all')) {
111+
targets.push('ie_mob 11');
112+
} else if ('op_mini' in targets) {
113+
targets['ie_mob'] = '11';
114+
}
115+
105116
// Downlevel the bundle
106117
const transformResult = await transformAsync(sourceCode, {
107118
filename: options.filename,
@@ -113,7 +124,7 @@ export async function process(options: ProcessBundleOptions): Promise<ProcessBun
113124
require.resolve('@babel/preset-env'),
114125
{
115126
// browserslist-compatible query or object of minimum environment versions to support
116-
targets: options.supportedBrowsers,
127+
targets,
117128
// modules aren't needed since the bundles use webpack's custom module loading
118129
modules: false,
119130
// 'transform-typeof-symbol' generates slower code

0 commit comments

Comments
 (0)