Skip to content

Commit e5ba29c

Browse files
alan-agius4filipesilva
authored andcommitted
fix(@schematics/angular): display warning during migrations when using third-party builders
1 parent 8ad1539 commit e5ba29c

File tree

1 file changed

+31
-21
lines changed

1 file changed

+31
-21
lines changed

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

+31-21
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

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

@@ -30,29 +30,39 @@ const ServerBuilderOptions: BuilderOptionsType = [
3030
];
3131

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

39-
// Only interested in Angular Devkit browser and server builders
40-
switch (target.builder) {
41-
case '@angular-devkit/build-angular:server':
42-
updateOptions(target, ServerBuilderOptions);
43-
break;
44-
case '@angular-devkit/build-angular:browser':
45-
updateOptions(target, BrowserBuilderOptions);
46-
break;
47-
}
46+
continue;
47+
}
4848

49-
for (const [, options] of allTargetOptions(target)) {
50-
delete options.experimentalRollupPass;
51-
delete options.lazyModules;
52-
delete options.forkTypeChecker;
49+
// Only interested in Angular Devkit browser and server builders
50+
switch (target.builder) {
51+
case '@angular-devkit/build-angular:server':
52+
updateOptions(target, ServerBuilderOptions);
53+
break;
54+
case '@angular-devkit/build-angular:browser':
55+
updateOptions(target, BrowserBuilderOptions);
56+
break;
57+
}
58+
59+
for (const [, options] of allTargetOptions(target)) {
60+
delete options.experimentalRollupPass;
61+
delete options.lazyModules;
62+
delete options.forkTypeChecker;
63+
}
5364
}
54-
}
55-
});
65+
});
5666
}
5767

5868
function updateOptions(

0 commit comments

Comments
 (0)