Skip to content

Commit 07d0879

Browse files
alan-agius4dgp1130
authored andcommitted
refactor: remove safari nomodule polyfills as it's unsupported
(cherry picked from commit d0ede14)
1 parent 3939142 commit 07d0879

File tree

8 files changed

+6
-184
lines changed

8 files changed

+6
-184
lines changed

packages/angular_devkit/build_angular/src/angular-cli-files/models/safari-nomodule.js

Lines changed: 0 additions & 19 deletions
This file was deleted.

packages/angular_devkit/build_angular/src/angular-cli-files/models/webpack-configs/common.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -132,19 +132,6 @@ export function getCommonConfig(wco: WebpackConfigOptions): Configuration {
132132
buildOptions.es5BrowserSupport ||
133133
(buildOptions.es5BrowserSupport === undefined && buildBrowserFeatures.isEs5SupportNeeded())
134134
) {
135-
// The nomodule polyfill needs to be inject prior to any script and be
136-
// outside of webpack compilation because otherwise webpack will cause the
137-
// script to be wrapped in window["webpackJsonp"] which causes this to fail.
138-
if (buildBrowserFeatures.isNoModulePolyfillNeeded()) {
139-
const noModuleScript: ExtraEntryPoint = {
140-
bundleName: 'polyfills-nomodule-es5',
141-
input: path.join(__dirname, '..', 'safari-nomodule.js'),
142-
};
143-
buildOptions.scripts = buildOptions.scripts
144-
? [...buildOptions.scripts, noModuleScript]
145-
: [noModuleScript];
146-
}
147-
148135
const polyfillsChunkName = 'polyfills-es5';
149136
entryPoints[polyfillsChunkName] = [path.join(__dirname, '..', 'es5-polyfills.js')];
150137
if (differentialLoadingMode) {

packages/angular_devkit/build_angular/src/angular-cli-files/utilities/index-file/augment-index-html.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,17 +148,17 @@ export async function augmentIndexHtml(params: AugmentIndexHtmlOptions): Promise
148148
// such as runtime.js
149149
const scriptPredictor = ({ file }: FileInfo): boolean => file === script;
150150
if (!files.some(scriptPredictor)) {
151-
// in some cases for differential loading file with the same name is avialable in both
151+
// in some cases for differential loading file with the same name is available in both
152152
// nomodule and module such as scripts.js
153153
// we shall not add these attributes if that's the case
154154
const isNoModuleType = noModuleFiles.some(scriptPredictor);
155155
const isModuleType = moduleFiles.some(scriptPredictor);
156156

157157
if (isNoModuleType && !isModuleType) {
158-
attrs.push({ name: 'nomodule', value: null });
159-
if (!script.startsWith('polyfills-nomodule-es5')) {
160-
attrs.push({ name: 'defer', value: null });
161-
}
158+
attrs.push(
159+
{ name: 'nomodule', value: null },
160+
{ name: 'defer', value: null },
161+
);
162162
} else if (isModuleType && !isNoModuleType) {
163163
attrs.push({ name: 'type', value: 'module' });
164164
} else {

packages/angular_devkit/build_angular/src/angular-cli-files/utilities/package-chunk-sort.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ export function generateEntryPoints(appConfig: {
2626
};
2727

2828
const entryPoints = [
29-
'polyfills-nomodule-es5',
3029
'runtime',
3130
'polyfills-es5',
3231
'polyfills',

packages/angular_devkit/build_angular/src/browser/index.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -383,9 +383,7 @@ export function buildWebpackBrowser(
383383
}
384384

385385
// All files at this point except ES5 polyfills are module scripts
386-
const es5Polyfills =
387-
file.file.startsWith('polyfills-es5') ||
388-
file.file.startsWith('polyfills-nomodule-es5');
386+
const es5Polyfills = file.file.startsWith('polyfills-es5');
389387
if (!es5Polyfills) {
390388
moduleFiles.push(file);
391389
}

packages/angular_devkit/build_angular/src/utils/build-browser-features.ts

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -37,25 +37,6 @@ export class BuildBrowserFeatures {
3737
return !this.isFeatureSupported('es6-module');
3838
}
3939

40-
/**
41-
* Safari 10.1 and iOS Safari 10.3 supports modules,
42-
* but does not support the `nomodule` attribute.
43-
* While return `true`, when support for Safari 10.1 and iOS Safari 10.3
44-
* is required and in differential loading is enabled.
45-
*/
46-
isNoModulePolyfillNeeded(): boolean {
47-
if (!this.isDifferentialLoadingNeeded()) {
48-
return false;
49-
}
50-
51-
const safariBrowsers = [
52-
'safari 10.1',
53-
'ios_saf 10.3',
54-
];
55-
56-
return this.supportedBrowsers.some(browser => safariBrowsers.includes(browser));
57-
}
58-
5940
/**
6041
* True, when a browser feature is supported partially or fully.
6142
*/

packages/angular_devkit/build_angular/src/utils/build-browser-features_spec.ts

Lines changed: 0 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -127,69 +127,4 @@ describe('BuildBrowserFeatures', () => {
127127
expect(buildBrowserFeatures.isFeatureSupported('es6-module')).toBe(true);
128128
});
129129
});
130-
131-
describe('isNoModulePolyfillNeeded', () => {
132-
it('should be false for Safari 10.1 when target is ES5', () => {
133-
host.writeMultipleFiles({
134-
'browserslist': 'Safari 10.1',
135-
});
136-
137-
const buildBrowserFeatures = new BuildBrowserFeatures(
138-
workspaceRootSysPath,
139-
ScriptTarget.ES5,
140-
);
141-
expect(buildBrowserFeatures.isNoModulePolyfillNeeded()).toBe(false);
142-
});
143-
144-
it('should be false for Safari 10.1 when target is ES2015', () => {
145-
host.writeMultipleFiles({
146-
'browserslist': 'Safari 10.1',
147-
});
148-
149-
const buildBrowserFeatures = new BuildBrowserFeatures(
150-
workspaceRootSysPath,
151-
ScriptTarget.ES2015,
152-
);
153-
expect(buildBrowserFeatures.isNoModulePolyfillNeeded()).toBe(false);
154-
});
155-
156-
it('should be true for Safari 9+ when target is ES2015', () => {
157-
host.writeMultipleFiles({
158-
'browserslist': 'Safari >= 9',
159-
});
160-
161-
const buildBrowserFeatures = new BuildBrowserFeatures(
162-
workspaceRootSysPath,
163-
ScriptTarget.ES2015,
164-
);
165-
expect(buildBrowserFeatures.isNoModulePolyfillNeeded()).toBe(true);
166-
});
167-
168-
it('should be false for Safari 9+ when target is ES5', () => {
169-
host.writeMultipleFiles({
170-
'browserslist': 'Safari >= 9',
171-
});
172-
173-
const buildBrowserFeatures = new BuildBrowserFeatures(
174-
workspaceRootSysPath,
175-
ScriptTarget.ES5,
176-
);
177-
expect(buildBrowserFeatures.isNoModulePolyfillNeeded()).toBe(false);
178-
});
179-
180-
it('should be false when not supporting Safari 10.1 target is ES2015', () => {
181-
host.writeMultipleFiles({
182-
'browserslist': `
183-
Edge 18
184-
IE 9
185-
`,
186-
});
187-
188-
const buildBrowserFeatures = new BuildBrowserFeatures(
189-
workspaceRootSysPath,
190-
ScriptTarget.ES2015,
191-
);
192-
expect(buildBrowserFeatures.isNoModulePolyfillNeeded()).toBe(false);
193-
});
194-
});
195130
});

tests/legacy-cli/e2e/tests/misc/support-safari-10.1.ts

Lines changed: 0 additions & 59 deletions
This file was deleted.

0 commit comments

Comments
 (0)