Skip to content

Commit 28e4114

Browse files
filipesilvahansl
authored andcommitted
feat(@angular/cli): followup changes to circular dependency detection
Flag is now positive instead of negative and shorter, and can now be set on commands as well (`--show-circular-dependencies`). Dependency was also added to eject as per #6813 (comment).
1 parent ba5be21 commit 28e4114

File tree

9 files changed

+27
-8
lines changed

9 files changed

+27
-8
lines changed

docs/documentation/angular-cli.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
- *testTsconfig* (`string`): The name of the TypeScript configuration file for unit tests.
2424
- *prefix* (`string`): The prefix to apply to generated selectors.
2525
- *serviceWorker* (`boolean`): Experimental support for a service worker from @angular/service-worker. Default is `false`.
26-
- *hideCircularDependencyWarnings* (`boolean`): Hide circular dependency warnings on builds. Default is `false`.
26+
- *showCircularDependencies* (`boolean`): Show circular dependency warnings on builds. Default is `true`.
2727
- *styles* (`string|array`): Global styles to be included in the build.
2828
- *stylePreprocessorOptions* : Options to pass to style preprocessors.
2929
- *includePaths* (`array`): Paths to include. Paths will be resolved to project root.

docs/documentation/build.md

+10
Original file line numberDiff line numberDiff line change
@@ -312,3 +312,13 @@ Note: service worker support is experimental and subject to change.
312312
Run build when files change.
313313
</p>
314314
</details>
315+
316+
<details>
317+
<summary>show-circular-dependencies</summary>
318+
<p>
319+
<code>--show-circular-dependencies</code> (aliases: <code>-scd</code>)
320+
</p>
321+
<p>
322+
Show circular dependency warnings on builds.
323+
</p>
324+
</details>

packages/@angular/cli/commands/build.ts

+6
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,12 @@ export const baseBuildCommandOptions: any = [
138138
type: Boolean,
139139
default: true,
140140
description: 'Extract all licenses in a separate file, in the case of production builds only.'
141+
},
142+
{
143+
name: 'show-circular-dependencies',
144+
type: Boolean,
145+
aliases: ['scd'],
146+
description: 'Show circular dependency warnings on builds.'
141147
}
142148
];
143149

packages/@angular/cli/lib/config/schema.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,10 @@
118118
"type": "boolean",
119119
"default": false
120120
},
121-
"hideCircularDependencyWarnings": {
122-
"description": "Hide circular dependency warnings on builds.",
121+
"showCircularDependencies": {
122+
"description": "Show circular dependency warnings on builds.",
123123
"type": "boolean",
124-
"default": false
124+
"default": true
125125
},
126126
"styles": {
127127
"description": "Global styles to be included in the build.",

packages/@angular/cli/models/build-options.ts

+1
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,5 @@ export interface BuildOptions {
2020
deleteOutputPath?: boolean;
2121
preserveSymlinks?: boolean;
2222
extractLicenses?: boolean;
23+
showCircularDependencies?: boolean;
2324
}

packages/@angular/cli/models/webpack-config.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ export class NgCliWebpackConfig {
9898
const mergeableOptions = {
9999
outputPath: appConfig.outDir,
100100
deployUrl: appConfig.deployUrl,
101-
baseHref: appConfig.baseHref
101+
baseHref: appConfig.baseHref,
102+
showCircularDependencies: appConfig.showCircularDependencies
102103
};
103104

104105
return Object.assign({}, mergeableOptions, buildOptions);

packages/@angular/cli/models/webpack-configs/common.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export function getCommonConfig(wco: WebpackConfigOptions) {
7373
}));
7474
}
7575

76-
if (!appConfig.hideCircularDependencyWarnings) {
76+
if (buildOptions.showCircularDependencies) {
7777
extraPlugins.push(new CircularDependencyPlugin({
7878
exclude: /(\\|\/)node_modules(\\|\/)/
7979
}));

packages/@angular/cli/tasks/eject.ts

+1
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,7 @@ export default Task.extend({
513513
'style-loader',
514514
'stylus-loader',
515515
'url-loader',
516+
'circular-dependency-plugin',
516517
].forEach((packageName: string) => {
517518
packageJson['devDependencies'][packageName] = ourPackageJson['dependencies'][packageName];
518519
});

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ import { ng } from '../../utils/process';
55
export default async function () {
66
await prependToFile('src/app/app.component.ts',
77
`import { AppModule } from './app.module'; console.log(AppModule);`);
8-
let output = await ng('build');
8+
let output = await ng('build', '--show-circular-dependencies');
99
if (!output.stdout.match(/WARNING in Circular dependency detected/)) {
1010
throw new Error('Expected to have circular dependency warning in output.');
1111
}
1212

13-
await ng('set', 'apps.0.hideCircularDependencyWarnings=true');
13+
await ng('set', 'apps.0.showCircularDependencies=false');
1414
output = await ng('build');
1515
if (output.stdout.match(/WARNING in Circular dependency detected/)) {
1616
throw new Error('Expected to not have circular dependency warning in output.');

0 commit comments

Comments
 (0)