Skip to content

Commit

Permalink
feat(@angular/cli): followup changes to circular dependency detection
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
filipesilva committed Jun 29, 2017
1 parent 8bad46e commit c69b4d4
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 7 deletions.
2 changes: 1 addition & 1 deletion docs/documentation/angular-cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
- *testTsconfig* (`string`): The name of the TypeScript configuration file for unit tests.
- *prefix* (`string`): The prefix to apply to generated selectors.
- *serviceWorker* (`boolean`): Experimental support for a service worker from @angular/service-worker. Default is `false`.
- *hideCircularDependencyWarnings* (`boolean`): Hide circular dependency warnings on builds. Default is `false`.
- *showCircularDependencies* (`boolean`): Show circular dependency warnings on builds. Default is `true`.
- *styles* (`string|array`): Global styles to be included in the build.
- *stylePreprocessorOptions* : Options to pass to style preprocessors.
- *includePaths* (`array`): Paths to include. Paths will be resolved to project root.
Expand Down
10 changes: 10 additions & 0 deletions docs/documentation/build.md
Original file line number Diff line number Diff line change
Expand Up @@ -312,3 +312,13 @@ Note: service worker support is experimental and subject to change.
Run build when files change.
</p>
</details>

<details>
<summary>show-circular-dependencies</summary>
<p>
<code>--show-circular-dependencies</code> (aliases: <code>-scd</code>)
</p>
<p>
Show circular dependency warnings on builds.
</p>
</details>
7 changes: 7 additions & 0 deletions packages/@angular/cli/commands/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,13 @@ export const baseBuildCommandOptions: any = [
type: Boolean,
default: true,
description: 'Extract all licenses in a separate file, in the case of production builds only.'
},
{
name: 'show-circular-dependencies',
type: Boolean,
default: true,
aliases: ['scd'],
description: 'Show circular dependency warnings on builds.'
}
];

Expand Down
6 changes: 3 additions & 3 deletions packages/@angular/cli/lib/config/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,10 @@
"type": "boolean",
"default": false
},
"hideCircularDependencyWarnings": {
"description": "Hide circular dependency warnings on builds.",
"showCircularDependencies": {
"description": "Show circular dependency warnings on builds.",
"type": "boolean",
"default": false
"default": true
},
"styles": {
"description": "Global styles to be included in the build.",
Expand Down
1 change: 1 addition & 0 deletions packages/@angular/cli/models/build-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ export interface BuildOptions {
deleteOutputPath?: boolean;
preserveSymlinks?: boolean;
extractLicenses?: boolean;
showCircularDependencies?: boolean;
}
2 changes: 1 addition & 1 deletion packages/@angular/cli/models/webpack-configs/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export function getCommonConfig(wco: WebpackConfigOptions) {
}));
}

if (!appConfig.hideCircularDependencyWarnings) {
if (buildOptions.showCircularDependencies) {
extraPlugins.push(new CircularDependencyPlugin({
exclude: /(\\|\/)node_modules(\\|\/)/
}));
Expand Down
1 change: 1 addition & 0 deletions packages/@angular/cli/tasks/eject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,7 @@ export default Task.extend({
'style-loader',
'stylus-loader',
'url-loader',
'circular-dependency-plugin',
].forEach((packageName: string) => {
packageJson['devDependencies'][packageName] = ourPackageJson['dependencies'][packageName];
});
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/tests/misc/circular-dependency.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import { ng } from '../../utils/process';
export default async function () {
await prependToFile('src/app/app.component.ts',
`import { AppModule } from './app.module'; console.log(AppModule);`);
let output = await ng('build');
let output = await ng('build', '--show-circular-dependencies');
if (!output.stdout.match(/WARNING in Circular dependency detected/)) {
throw new Error('Expected to have circular dependency warning in output.');
}

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

0 comments on commit c69b4d4

Please sign in to comment.