Skip to content

Commit 502f985

Browse files
clydinmgechev
authored andcommitted
fix(@angular-devkit/build-angular): avoid defer attribute for Safari nomodule polyfill (#15276)
The polyfill will not function properly if the defer attribute is present.
1 parent 2af1deb commit 502f985

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,10 @@ export async function augmentIndexHtml(params: AugmentIndexHtmlOptions): Promise
150150
const isModuleType = moduleFiles.some(scriptPredictor);
151151

152152
if (isNoModuleType && !isModuleType) {
153-
attrs.push({ name: 'nomodule', value: null }, { name: 'defer', value: null });
153+
attrs.push({ name: 'nomodule', value: null });
154+
if (!script.startsWith('polyfills-nomodule-es5')) {
155+
attrs.push({ name: 'defer', value: null });
156+
}
154157
} else if (isModuleType && !isNoModuleType) {
155158
attrs.push({ name: 'type', value: 'module' });
156159
} else {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export default async function () {
2727
await ng('build');
2828
await expectFileToExist('dist/test-project/polyfills-nomodule-es5.js');
2929
await expectFileToMatch('dist/test-project/index.html', oneLineTrim`
30-
<script src="polyfills-nomodule-es5.js" nomodule defer></script>
30+
<script src="polyfills-nomodule-es5.js" nomodule></script>
3131
<script src="runtime-es2015.js" type="module"></script>
3232
<script src="polyfills-es2015.js" type="module"></script>
3333
<script src="runtime-es5.js" nomodule defer></script>

0 commit comments

Comments
 (0)