Skip to content

Commit 0a1cd58

Browse files
alan-agius4dgp1130
authored andcommitted
refactor(@angular-devkit/build-angular): remove deprecated showCircularDependencies browser and server builder option
BREAKING CHANGE: The deprecated `showCircularDependencies` browser and server builder option has been removed. The recommended method to detect circular dependencies in project code is to use either a lint rule or other external tools.
1 parent d23a168 commit 0a1cd58

File tree

13 files changed

+115
-113
lines changed

13 files changed

+115
-113
lines changed

goldens/public-api/angular_devkit/build_angular/src/index.md

-4
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,6 @@ export interface BrowserBuilderOptions {
6161
resourcesOutputPath?: string;
6262
scripts?: ScriptElement[];
6363
serviceWorker?: boolean;
64-
// @deprecated
65-
showCircularDependencies?: boolean;
6664
sourceMap?: SourceMapUnion;
6765
statsJson?: boolean;
6866
stylePreprocessorOptions?: StylePreprocessorOptions;
@@ -263,8 +261,6 @@ export interface ServerBuilderOptions {
263261
preserveSymlinks?: boolean;
264262
progress?: boolean;
265263
resourcesOutputPath?: string;
266-
// @deprecated
267-
showCircularDependencies?: boolean;
268264
sourceMap?: SourceMapUnion_3;
269265
statsJson?: boolean;
270266
stylePreprocessorOptions?: StylePreprocessorOptions_3;

package.json

-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@
128128
"browserslist": "^4.9.1",
129129
"cacache": "15.3.0",
130130
"chokidar": "^3.5.2",
131-
"circular-dependency-plugin": "5.2.2",
132131
"common-tags": "^1.8.0",
133132
"conventional-commits-parser": "^3.0.0",
134133
"copy-webpack-plugin": "10.2.1",

packages/angular_devkit/build_angular/BUILD.bazel

-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ ts_library(
130130
"@npm//babel-plugin-istanbul",
131131
"@npm//browserslist",
132132
"@npm//cacache",
133-
"@npm//circular-dependency-plugin",
134133
"@npm//copy-webpack-plugin",
135134
"@npm//core-js",
136135
"@npm//critters",

packages/angular_devkit/build_angular/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
"babel-plugin-istanbul": "6.1.1",
2727
"browserslist": "^4.9.1",
2828
"cacache": "15.3.0",
29-
"circular-dependency-plugin": "5.2.2",
3029
"copy-webpack-plugin": "10.2.1",
3130
"core-js": "3.20.3",
3231
"critters": "0.0.16",

packages/angular_devkit/build_angular/src/builders/browser/schema.json

-6
Original file line numberDiff line numberDiff line change
@@ -329,12 +329,6 @@
329329
"description": "Extract all licenses in a separate file.",
330330
"default": true
331331
},
332-
"showCircularDependencies": {
333-
"type": "boolean",
334-
"description": "Show circular dependency warnings on builds.",
335-
"default": false,
336-
"x-deprecated": "The recommended method to detect circular dependencies in project code is to use either a lint rule or other external tooling."
337-
},
338332
"buildOptimizer": {
339333
"type": "boolean",
340334
"description": "Enables advanced build optimizations when using the 'aot' option.",

packages/angular_devkit/build_angular/src/builders/browser/tests/options/show-circular-dependencies_spec.ts

-70
This file was deleted.

packages/angular_devkit/build_angular/src/builders/server/schema.json

-6
Original file line numberDiff line numberDiff line change
@@ -177,12 +177,6 @@
177177
"description": "Extract all licenses in a separate file, in the case of production builds only.",
178178
"default": true
179179
},
180-
"showCircularDependencies": {
181-
"type": "boolean",
182-
"description": "Show circular dependency warnings on builds.",
183-
"default": false,
184-
"x-deprecated": "The recommended method to detect circular dependencies in project code is to use either a lint rule or other external tooling."
185-
},
186180
"namedChunks": {
187181
"type": "boolean",
188182
"description": "Use file name for lazy loaded chunks.",

packages/angular_devkit/build_angular/src/utils/build-options.ts

-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ export interface BuildOptions {
4949
deleteOutputPath?: boolean;
5050
preserveSymlinks?: boolean;
5151
extractLicenses?: boolean;
52-
showCircularDependencies?: boolean;
5352
buildOptimizer?: boolean;
5453
namedChunks?: boolean;
5554
crossOrigin?: CrossOrigin;

packages/angular_devkit/build_angular/src/webpack/configs/common.ts

-9
Original file line numberDiff line numberDiff line change
@@ -173,15 +173,6 @@ export async function getCommonConfig(wco: WebpackConfigOptions): Promise<Config
173173
);
174174
}
175175

176-
if (buildOptions.showCircularDependencies) {
177-
const CircularDependencyPlugin = require('circular-dependency-plugin');
178-
extraPlugins.push(
179-
new CircularDependencyPlugin({
180-
exclude: /[\\/]node_modules[\\/]/,
181-
}),
182-
);
183-
}
184-
185176
if (buildOptions.extractLicenses) {
186177
const LicenseWebpackPlugin = require('license-webpack-plugin').LicenseWebpackPlugin;
187178
extraPlugins.push(

packages/schematics/angular/migrations/migration-collection.json

+5
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99
"version": "14.0.0",
1010
"factory": "./update-14/update-tsconfig-target",
1111
"description": "Update TypeScript compilation target to 'ES2020'."
12+
},
13+
"remove-show-circular-dependencies-option": {
14+
"version": "14.0.0",
15+
"factory": "./update-14/remove-show-circular-dependencies-option",
16+
"description": "Remove 'showCircularDependencies' option from browser and server builders."
1217
}
1318
}
1419
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/**
2+
* @license
3+
* Copyright Google LLC All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
9+
import { Rule } from '@angular-devkit/schematics';
10+
import { allTargetOptions, updateWorkspace } from '../../utility/workspace';
11+
12+
/** Migration to remove 'showCircularDependencies' option from browser and server builders. */
13+
export default function (): Rule {
14+
return updateWorkspace((workspace) => {
15+
for (const project of workspace.projects.values()) {
16+
for (const target of project.targets.values()) {
17+
if (
18+
target.builder === '@angular-devkit/build-angular:server' ||
19+
target.builder === '@angular-devkit/build-angular:browser'
20+
) {
21+
for (const [, options] of allTargetOptions(target)) {
22+
delete options.showCircularDependencies;
23+
}
24+
}
25+
}
26+
}
27+
});
28+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
/**
2+
* @license
3+
* Copyright Google LLC All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
9+
import { JsonObject } from '@angular-devkit/core';
10+
import { EmptyTree } from '@angular-devkit/schematics';
11+
import { SchematicTestRunner, UnitTestTree } from '@angular-devkit/schematics/testing';
12+
import {
13+
BuilderTarget,
14+
Builders,
15+
ProjectType,
16+
WorkspaceSchema,
17+
} from '../../utility/workspace-models';
18+
19+
function getBuildTarget(tree: UnitTestTree): BuilderTarget<Builders.Browser, JsonObject> {
20+
return JSON.parse(tree.readContent('/angular.json')).projects.app.architect.build;
21+
}
22+
23+
function createWorkSpaceConfig(tree: UnitTestTree) {
24+
const angularConfig: WorkspaceSchema = {
25+
version: 1,
26+
projects: {
27+
app: {
28+
root: '',
29+
sourceRoot: 'src',
30+
projectType: ProjectType.Application,
31+
prefix: 'app',
32+
architect: {
33+
build: {
34+
builder: Builders.Browser,
35+
options: {
36+
extractCss: false,
37+
showCircularDependencies: true,
38+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
39+
} as any,
40+
configurations: {
41+
one: {
42+
showCircularDependencies: false,
43+
aot: true,
44+
},
45+
two: {
46+
showCircularDependencies: false,
47+
aot: true,
48+
},
49+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
50+
} as any,
51+
},
52+
},
53+
},
54+
},
55+
};
56+
57+
tree.create('/angular.json', JSON.stringify(angularConfig, undefined, 2));
58+
}
59+
60+
describe(`Migration to remove 'showCircularDependencies' option.`, () => {
61+
const schematicName = 'remove-show-circular-dependencies-option';
62+
const schematicRunner = new SchematicTestRunner(
63+
'migrations',
64+
require.resolve('../migration-collection.json'),
65+
);
66+
67+
let tree: UnitTestTree;
68+
beforeEach(() => {
69+
tree = new UnitTestTree(new EmptyTree());
70+
createWorkSpaceConfig(tree);
71+
});
72+
73+
it(`should remove 'showCircularDependencies'`, async () => {
74+
const newTree = await schematicRunner.runSchematicAsync(schematicName, {}, tree).toPromise();
75+
const { options, configurations } = getBuildTarget(newTree);
76+
77+
expect(options.showCircularDependencies).toBeUndefined();
78+
expect(configurations).toBeDefined();
79+
expect(configurations?.one.showCircularDependencies).toBeUndefined();
80+
expect(configurations?.two.showCircularDependencies).toBeUndefined();
81+
});
82+
});

tests/legacy-cli/e2e/tests/misc/circular-dependency.ts

-14
This file was deleted.

0 commit comments

Comments
 (0)