Skip to content

Commit 367fce2

Browse files
clydinalan-agius4
authored andcommitted
fix(@angular-devkit/build-angular): improve Safari browserslist to esbuild target conversion
The browser targets provided by `browserslist` have several differences than what `esbuild` expects for the Safari browsers. The first is that the iOS Safari is named `ios_saf` within browserslist and `ios` by esbuild. The former is now converted to the later when generating the target list for esbuild. The second difference is that `browserslist` supports a `TP` (Technology Preview) version for Safari but esbuild expects a numeric value for all versions. Since a TP version of Safari is assumed to be the latest unreleased version and as a result supports all currently known features, a high version number (999) is used as a replacement when generating the target list for esbuild.
1 parent f621566 commit 367fce2

File tree

1 file changed

+15
-1
lines changed
  • packages/angular_devkit/build_angular/src/webpack/configs

1 file changed

+15
-1
lines changed

packages/angular_devkit/build_angular/src/webpack/configs/styles.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,11 +488,25 @@ function transformSupportedBrowsersToTargets(supportedBrowsers: string[]): strin
488488
const esBuildSupportedBrowsers = new Set(['safari', 'firefox', 'edge', 'chrome', 'ios']);
489489

490490
for (const browser of supportedBrowsers) {
491-
const [browserName, version] = browser.split(' ');
491+
let [browserName, version] = browser.split(' ');
492+
493+
// browserslist uses the name `ios_saf` for iOS Safari whereas esbuild uses `ios`
494+
if (browserName === 'ios_saf') {
495+
browserName = 'ios';
496+
// browserslist also uses ranges for iOS Safari versions but only the lowest is required
497+
// to perform minimum supported feature checks. esbuild also expects a single version.
498+
[version] = version.split('-');
499+
}
492500

493501
if (browserName === 'ie') {
494502
transformed.push('edge12');
495503
} else if (esBuildSupportedBrowsers.has(browserName)) {
504+
if (browserName === 'safari' && version === 'TP') {
505+
// esbuild only supports numeric versions so `TP` is converted to a high number (999) since
506+
// a Technology Preview (TP) of Safari is assumed to support all currently known features.
507+
version = '999';
508+
}
509+
496510
transformed.push(browserName + version);
497511
}
498512
}

0 commit comments

Comments
 (0)