Skip to content

Commit 575b1a7

Browse files
committed
fix(@schematics/angular): only update removed v12 options in migration
1 parent c5c80c4 commit 575b1a7

File tree

2 files changed

+8
-28
lines changed

2 files changed

+8
-28
lines changed

packages/schematics/angular/migrations/update-12/update-angular-config.ts

+7-28
Original file line numberDiff line numberDiff line change
@@ -7,38 +7,17 @@
77
*/
88

99
import { Rule } from '@angular-devkit/schematics';
10-
import { updateWorkspace } from '../../utility/workspace';
10+
import { allTargetOptions, allWorkspaceTargets, updateWorkspace } from '../../utility/workspace';
1111

1212
export default function (): Rule {
1313
return updateWorkspace(workspace => {
14-
const optionsToRemove: Record<string, undefined> = {
15-
experimentalRollupPass: undefined,
16-
};
17-
18-
for (const [, project] of workspace.projects) {
19-
for (const [, target] of project.targets) {
20-
// Only interested in Angular Devkit builders
21-
if (!target?.builder.startsWith('@angular-devkit/build-angular')) {
22-
continue;
23-
}
24-
25-
// Check options
26-
if (target.options) {
27-
target.options = {
28-
...optionsToRemove,
29-
};
30-
}
31-
32-
// Go through each configuration entry
33-
if (!target.configurations) {
34-
continue;
35-
}
14+
for (const [, target] of allWorkspaceTargets(workspace)) {
15+
if (!target.builder.startsWith('@angular-devkit/build-angular')) {
16+
continue;
17+
}
3618

37-
for (const configurationName of Object.keys(target.configurations)) {
38-
target.configurations[configurationName] = {
39-
...optionsToRemove,
40-
};
41-
}
19+
for (const [, options] of allTargetOptions(target)) {
20+
delete options.experimentalRollupPass;
4221
}
4322
}
4423
});

packages/schematics/angular/migrations/update-12/update-angular-config_spec.ts

+1
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ describe(`Migration to update 'angular.json'. ${schematicName}`, () => {
8585
const { options, configurations } = getBuildTarget(newTree);
8686

8787
expect(options.experimentalRollupPass).toBeUndefined();
88+
expect(options.sourceMaps).toBeTrue();
8889
expect(configurations).toBeDefined();
8990
expect(configurations?.one.experimentalRollupPass).toBeUndefined();
9091
expect(configurations?.two.experimentalRollupPass).toBeUndefined();

0 commit comments

Comments
 (0)