Skip to content

Commit

Permalink
fix(@schematics/angular): display warning during migrations when usin…
Browse files Browse the repository at this point in the history
…g third-party builders
  • Loading branch information
alan-agius4 authored and filipesilva committed Jun 21, 2021
1 parent 8ad1539 commit e5ba29c
Showing 1 changed file with 31 additions and 21 deletions.
Expand Up @@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/

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

Expand All @@ -30,29 +30,39 @@ const ServerBuilderOptions: BuilderOptionsType = [
];

export default function (): Rule {
return updateWorkspace((workspace) => {
for (const [, target] of allWorkspaceTargets(workspace)) {
if (!target?.builder.startsWith('@angular-devkit/build-angular')) {
continue;
}
return (_tree, context) =>
updateWorkspace((workspace) => {
for (const [targetName, target, projectName] of allWorkspaceTargets(workspace)) {
if (
!target.builder.startsWith('@angular-devkit/') &&
!target.builder.startsWith('@nguniversal/')
) {
context.logger.warn(tags.stripIndent`
"${targetName}" target in "${projectName}" project is using a third-party builder.
You may need to adjust the options to retain the existing behavior.
For more information, see the breaking changes section within the release notes: https://github.com/angular/angular-cli/releases/tag/v12.0.0
`);

// Only interested in Angular Devkit browser and server builders
switch (target.builder) {
case '@angular-devkit/build-angular:server':
updateOptions(target, ServerBuilderOptions);
break;
case '@angular-devkit/build-angular:browser':
updateOptions(target, BrowserBuilderOptions);
break;
}
continue;
}

for (const [, options] of allTargetOptions(target)) {
delete options.experimentalRollupPass;
delete options.lazyModules;
delete options.forkTypeChecker;
// Only interested in Angular Devkit browser and server builders
switch (target.builder) {
case '@angular-devkit/build-angular:server':
updateOptions(target, ServerBuilderOptions);
break;
case '@angular-devkit/build-angular:browser':
updateOptions(target, BrowserBuilderOptions);
break;
}

for (const [, options] of allTargetOptions(target)) {
delete options.experimentalRollupPass;
delete options.lazyModules;
delete options.forkTypeChecker;
}
}
}
});
});
}

function updateOptions(
Expand Down

0 comments on commit e5ba29c

Please sign in to comment.