diff --git a/packages/schematics/angular/migrations/update-12/update-angular-config.ts b/packages/schematics/angular/migrations/update-12/update-angular-config.ts index b15ac2196d2b..7a4da5035685 100644 --- a/packages/schematics/angular/migrations/update-12/update-angular-config.ts +++ b/packages/schematics/angular/migrations/update-12/update-angular-config.ts @@ -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 = { - 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; } } }); diff --git a/packages/schematics/angular/migrations/update-12/update-angular-config_spec.ts b/packages/schematics/angular/migrations/update-12/update-angular-config_spec.ts index 96101c521936..b3cc6f6c3374 100644 --- a/packages/schematics/angular/migrations/update-12/update-angular-config_spec.ts +++ b/packages/schematics/angular/migrations/update-12/update-angular-config_spec.ts @@ -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();