Skip to content

Commit 3afdab2

Browse files
alan-agius4alexeagle
authored andcommitted
fix(@schematics/angular): add migration to update web-animations-js polyfill
Previous versions rely on `this` which breaks differential loading since it's `undefined` when using script tags with type module. Fixes angular#14518
1 parent 757d8df commit 3afdab2

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

packages/schematics/angular/migrations/update-8/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { updatePackageJson, updateTsLintConfig } from './codelyzer-5';
1212
import { updateES5Projects } from './differential-loading';
1313
import { dropES2015Polyfills } from './drop-es6-polyfills';
1414
import { removeAngularHttp } from './remove-angular-http';
15-
import { updateBuilders } from './update-builders';
15+
import { updateDependencies } from './update-dependencies';
1616

1717
export { updateLazyModulePaths } from './update-lazy-module-paths';
1818

@@ -23,7 +23,7 @@ export default function(): Rule {
2323
updatePackageJson(),
2424
dropES2015Polyfills(),
2525
updateES5Projects(),
26-
updateBuilders(),
26+
updateDependencies(),
2727
removeAngularHttp(),
2828
(tree, context) => {
2929
const packageChanges = tree.actions.some(a => a.path.endsWith('/package.json'));

packages/schematics/angular/migrations/update-8/update-builders.ts renamed to packages/schematics/angular/migrations/update-8/update-dependencies.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { Tree } from '@angular-devkit/schematics';
99
import { addPackageJsonDependency, getPackageJsonDependency } from '../../utility/dependencies';
1010
import { latestVersions } from '../../utility/latest-versions';
1111

12-
export function updateBuilders() {
12+
export function updateDependencies() {
1313
return (host: Tree) => {
1414
let current = getPackageJsonDependency(host, '@angular-devkit/build-angular');
1515
if (current && current.version !== latestVersions.DevkitBuildAngular) {
@@ -49,5 +49,20 @@ export function updateBuilders() {
4949
},
5050
);
5151
}
52+
53+
// FIXME: change to ^2.3.2 as soon as it's released with the pr208 fix
54+
const webAnimationsJsVersion = 'github:angular/web-animations-js#release_pr208';
55+
current = getPackageJsonDependency(host, 'web-animations-js');
56+
if (current && current.version !== webAnimationsJsVersion) {
57+
addPackageJsonDependency(
58+
host,
59+
{
60+
type: current.type,
61+
name: 'web-animations-js',
62+
version: webAnimationsJsVersion,
63+
overwrite: true,
64+
},
65+
);
66+
}
5267
};
5368
}

0 commit comments

Comments
 (0)