Skip to content

Commit b893a6a

Browse files
committed
refactor: remove workarounds for Safari 14 and 15
Both of these versions are no longer supported by Angular and thus these workers are no longer required.
1 parent ebc6aa6 commit b893a6a

File tree

3 files changed

+1
-141
lines changed

3 files changed

+1
-141
lines changed

packages/angular/build/src/tools/esbuild/utils.ts

+1-30
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ export function getFeatureSupport(
195195
target: string[],
196196
nativeAsyncAwait: boolean,
197197
): BuildOptions['supported'] {
198-
const supported: Record<string, boolean> = {
198+
return {
199199
// Native async/await is not supported with Zone.js. Disabling support here will cause
200200
// esbuild to downlevel async/await, async generators, and for await...of to a Zone.js supported form.
201201
'async-await': nativeAsyncAwait,
@@ -205,35 +205,6 @@ export function getFeatureSupport(
205205
// For more details: https://bugs.chromium.org/p/v8/issues/detail?id=11536
206206
'object-rest-spread': false,
207207
};
208-
209-
// Detect Safari browser versions that have a class field behavior bug
210-
// See: https://github.com/angular/angular-cli/issues/24355#issuecomment-1333477033
211-
// See: https://github.com/WebKit/WebKit/commit/e8788a34b3d5f5b4edd7ff6450b80936bff396f2
212-
let safariClassFieldScopeBug = false;
213-
for (const browser of target) {
214-
let majorVersion;
215-
if (browser.startsWith('ios')) {
216-
majorVersion = Number(browser.slice(3, 5));
217-
} else if (browser.startsWith('safari')) {
218-
majorVersion = Number(browser.slice(6, 8));
219-
} else {
220-
continue;
221-
}
222-
// Technically, 14.0 is not broken but rather does not have support. However, the behavior
223-
// is identical since it would be set to false by esbuild if present as a target.
224-
if (majorVersion === 14 || majorVersion === 15) {
225-
safariClassFieldScopeBug = true;
226-
break;
227-
}
228-
}
229-
// If class field support cannot be used set to false; otherwise leave undefined to allow
230-
// esbuild to use `target` to determine support.
231-
if (safariClassFieldScopeBug) {
232-
supported['class-field'] = false;
233-
supported['class-static-field'] = false;
234-
}
235-
236-
return supported;
237208
}
238209

239210
const MAX_CONCURRENT_WRITES = 64;

packages/angular_devkit/build_angular/src/tools/babel/presets/application.ts

-34
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,6 @@ import { loadEsmModule } from '../../../utils/load-esm';
2323
*/
2424
let needsLinking: typeof import('@angular/compiler-cli/linker').needsLinking | undefined;
2525

26-
/**
27-
* List of browsers which are affected by a WebKit bug where class field
28-
* initializers might have incorrect variable scopes.
29-
*
30-
* See: https://github.com/angular/angular-cli/issues/24355#issuecomment-1333477033
31-
* See: https://github.com/WebKit/WebKit/commit/e8788a34b3d5f5b4edd7ff6450b80936bff396f2
32-
*/
33-
let safariClassFieldScopeBugBrowsers: ReadonlySet<string>;
34-
3526
export type DiagnosticReporter = (type: 'error' | 'warning' | 'info', message: string) => void;
3627

3728
/**
@@ -188,37 +179,12 @@ export default function (api: unknown, options: ApplicationPresetOptions) {
188179
// However, this doesn't effect libraries and hence we use preset-env to downlevel ES features
189180
// based on the supported browsers in browserslist.
190181
if (options.supportedBrowsers) {
191-
const includePlugins: string[] = [];
192-
193-
if (safariClassFieldScopeBugBrowsers === undefined) {
194-
const browserslist = require('browserslist') as typeof import('browserslist');
195-
safariClassFieldScopeBugBrowsers = new Set(
196-
browserslist([
197-
// Safari <15 is technically not supported via https://angular.dev/reference/versions#browser-support
198-
// but we apply the workaround if forcibly selected.
199-
'Safari <=15',
200-
'iOS <=15',
201-
]),
202-
);
203-
}
204-
205-
// If a Safari browser affected by the class field scope bug is selected, we
206-
// downlevel class properties by ensuring the class properties Babel plugin
207-
// is always included- regardless of the preset-env targets.
208-
if (options.supportedBrowsers.some((b) => safariClassFieldScopeBugBrowsers.has(b))) {
209-
includePlugins.push(
210-
'@babel/plugin-proposal-class-properties',
211-
'@babel/plugin-proposal-private-methods',
212-
);
213-
}
214-
215182
presets.push([
216183
require('@babel/preset-env').default,
217184
{
218185
bugfixes: true,
219186
modules: false,
220187
targets: options.supportedBrowsers,
221-
include: includePlugins,
222188
exclude: ['transform-typeof-symbol'],
223189
},
224190
]);

tests/legacy-cli/e2e/tests/misc/safari-15-class-properties.ts

-77
This file was deleted.

0 commit comments

Comments
 (0)