Skip to content

Commit 74f81d7

Browse files
alan-agius4Keen Yee Liau
authored andcommitted
fix(@angular-devkit/build-angular): generate ES5 code in ES5 bundles for default browserslist configuration
1 parent d74e69c commit 74f81d7

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

0 commit comments

Comments
 (0)