Skip to content

Commit decb1d1

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 48340ab commit decb1d1

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

packages/angular_devkit/build_angular/src/webpack/plugins/css-optimizer-plugin.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,23 @@ export class CssOptimizerPlugin {
129129
const esBuildSupportedBrowsers = new Set(['safari', 'firefox', 'edge', 'chrome', 'ios']);
130130

131131
for (const browser of supportedBrowsers) {
132-
const [browserName, version] = browser.split(' ');
132+
let [browserName, version] = browser.split(' ');
133+
134+
// browserslist uses the name `ios_saf` for iOS Safari whereas esbuild uses `ios`
135+
if (browserName === 'ios_saf') {
136+
browserName = 'ios';
137+
// browserslist also uses ranges for iOS Safari versions but only the lowest is required
138+
// to perform minimum supported feature checks. esbuild also expects a single version.
139+
[version] = version.split('-');
140+
}
141+
133142
if (esBuildSupportedBrowsers.has(browserName)) {
143+
if (browserName === 'safari' && version === 'TP') {
144+
// esbuild only supports numeric versions so `TP` is converted to a high number (999) since
145+
// a Technology Preview (TP) of Safari is assumed to support all currently known features.
146+
version = '999';
147+
}
148+
134149
transformed.push(browserName + version);
135150
}
136151
}

0 commit comments

Comments
 (0)