Skip to content

Commit e414d9b

Browse files
alan-agius4Keen Yee Liau
authored and
Keen Yee Liau
committed
fix(@angular-devkit/build-angular): generate ES5 code in ES5 bundles for default browserslist configuration
1 parent 21a25ee commit e414d9b

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
@@ -119,6 +119,17 @@ export async function process(options: ProcessBundleOptions): Promise<ProcessBun
119119
let downlevelCode;
120120
let downlevelMap;
121121
if (downlevel) {
122+
const {supportedBrowsers: targets = []} = options;
123+
124+
// todo: revisit this in version 10, when we update our defaults browserslist
125+
// Without this workaround bundles will not be downlevelled because Babel doesn't know handle to 'op_mini all'
126+
// See: https://github.com/babel/babel/issues/11155
127+
if (Array.isArray(targets) && targets.includes('op_mini all')) {
128+
targets.push('ie_mob 11');
129+
} else if ('op_mini' in targets) {
130+
targets['ie_mob'] = '11';
131+
}
132+
122133
// Downlevel the bundle
123134
const transformResult = await transformAsync(sourceCode, {
124135
filename,
@@ -132,7 +143,7 @@ export async function process(options: ProcessBundleOptions): Promise<ProcessBun
132143
require.resolve('@babel/preset-env'),
133144
{
134145
// browserslist-compatible query or object of minimum environment versions to support
135-
targets: options.supportedBrowsers,
146+
targets,
136147
// modules aren't needed since the bundles use webpack's custom module loading
137148
modules: false,
138149
// 'transform-typeof-symbol' generates slower code

0 commit comments

Comments
 (0)