Skip to content

Commit

Permalink
fix(@schematics/angular): only update removed v12 options in migration
Browse files Browse the repository at this point in the history
  • Loading branch information
clydin committed Feb 11, 2021
1 parent c5c80c4 commit 575b1a7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,38 +7,17 @@
*/

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

export default function (): Rule {
return updateWorkspace(workspace => {
const optionsToRemove: Record<string, undefined> = {
experimentalRollupPass: undefined,
};

for (const [, project] of workspace.projects) {
for (const [, target] of project.targets) {
// Only interested in Angular Devkit builders
if (!target?.builder.startsWith('@angular-devkit/build-angular')) {
continue;
}

// Check options
if (target.options) {
target.options = {
...optionsToRemove,
};
}

// Go through each configuration entry
if (!target.configurations) {
continue;
}
for (const [, target] of allWorkspaceTargets(workspace)) {
if (!target.builder.startsWith('@angular-devkit/build-angular')) {
continue;
}

for (const configurationName of Object.keys(target.configurations)) {
target.configurations[configurationName] = {
...optionsToRemove,
};
}
for (const [, options] of allTargetOptions(target)) {
delete options.experimentalRollupPass;
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ describe(`Migration to update 'angular.json'. ${schematicName}`, () => {
const { options, configurations } = getBuildTarget(newTree);

expect(options.experimentalRollupPass).toBeUndefined();
expect(options.sourceMaps).toBeTrue();
expect(configurations).toBeDefined();
expect(configurations?.one.experimentalRollupPass).toBeUndefined();
expect(configurations?.two.experimentalRollupPass).toBeUndefined();
Expand Down

0 comments on commit 575b1a7

Please sign in to comment.