mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-15 01:54:04 +08:00
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.
This commit is contained in:
parent
d23a168b8d
commit
0a1cd584d8
@ -61,8 +61,6 @@ export interface BrowserBuilderOptions {
|
||||
resourcesOutputPath?: string;
|
||||
scripts?: ScriptElement[];
|
||||
serviceWorker?: boolean;
|
||||
// @deprecated
|
||||
showCircularDependencies?: boolean;
|
||||
sourceMap?: SourceMapUnion;
|
||||
statsJson?: boolean;
|
||||
stylePreprocessorOptions?: StylePreprocessorOptions;
|
||||
@ -263,8 +261,6 @@ export interface ServerBuilderOptions {
|
||||
preserveSymlinks?: boolean;
|
||||
progress?: boolean;
|
||||
resourcesOutputPath?: string;
|
||||
// @deprecated
|
||||
showCircularDependencies?: boolean;
|
||||
sourceMap?: SourceMapUnion_3;
|
||||
statsJson?: boolean;
|
||||
stylePreprocessorOptions?: StylePreprocessorOptions_3;
|
||||
|
@ -128,7 +128,6 @@
|
||||
"browserslist": "^4.9.1",
|
||||
"cacache": "15.3.0",
|
||||
"chokidar": "^3.5.2",
|
||||
"circular-dependency-plugin": "5.2.2",
|
||||
"common-tags": "^1.8.0",
|
||||
"conventional-commits-parser": "^3.0.0",
|
||||
"copy-webpack-plugin": "10.2.1",
|
||||
|
@ -130,7 +130,6 @@ ts_library(
|
||||
"@npm//babel-plugin-istanbul",
|
||||
"@npm//browserslist",
|
||||
"@npm//cacache",
|
||||
"@npm//circular-dependency-plugin",
|
||||
"@npm//copy-webpack-plugin",
|
||||
"@npm//core-js",
|
||||
"@npm//critters",
|
||||
|
@ -26,7 +26,6 @@
|
||||
"babel-plugin-istanbul": "6.1.1",
|
||||
"browserslist": "^4.9.1",
|
||||
"cacache": "15.3.0",
|
||||
"circular-dependency-plugin": "5.2.2",
|
||||
"copy-webpack-plugin": "10.2.1",
|
||||
"core-js": "3.20.3",
|
||||
"critters": "0.0.16",
|
||||
|
@ -329,12 +329,6 @@
|
||||
"description": "Extract all licenses in a separate file.",
|
||||
"default": true
|
||||
},
|
||||
"showCircularDependencies": {
|
||||
"type": "boolean",
|
||||
"description": "Show circular dependency warnings on builds.",
|
||||
"default": false,
|
||||
"x-deprecated": "The recommended method to detect circular dependencies in project code is to use either a lint rule or other external tooling."
|
||||
},
|
||||
"buildOptimizer": {
|
||||
"type": "boolean",
|
||||
"description": "Enables advanced build optimizations when using the 'aot' option.",
|
||||
|
@ -1,70 +0,0 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright Google LLC All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import { logging } from '@angular-devkit/core';
|
||||
import { buildWebpackBrowser } from '../../index';
|
||||
import { BASE_OPTIONS, BROWSER_BUILDER_INFO, describeBuilder } from '../setup';
|
||||
|
||||
describeBuilder(buildWebpackBrowser, BROWSER_BUILDER_INFO, (harness) => {
|
||||
describe('Option: "showCircularDependencies"', () => {
|
||||
beforeEach(async () => {
|
||||
// Add circular dependency
|
||||
await harness.appendToFile(
|
||||
'src/app/app.component.ts',
|
||||
`import { AppModule } from './app.module'; console.log(AppModule);`,
|
||||
);
|
||||
});
|
||||
|
||||
it('should show cyclic dependency warning when option is set to true', async () => {
|
||||
harness.useTarget('build', {
|
||||
...BASE_OPTIONS,
|
||||
showCircularDependencies: true,
|
||||
});
|
||||
|
||||
const { result, logs } = await harness.executeOnce();
|
||||
|
||||
expect(result?.success).toBe(true);
|
||||
expect(logs).toContain(
|
||||
jasmine.objectContaining<logging.LogEntry>({
|
||||
message: jasmine.stringMatching(/Circular dependency detected/),
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it('should not show cyclic dependency warning when option is set to false', async () => {
|
||||
harness.useTarget('build', {
|
||||
...BASE_OPTIONS,
|
||||
showCircularDependencies: false,
|
||||
});
|
||||
|
||||
const { result, logs } = await harness.executeOnce();
|
||||
|
||||
expect(result?.success).toBe(true);
|
||||
expect(logs).not.toContain(
|
||||
jasmine.objectContaining<logging.LogEntry>({
|
||||
message: jasmine.stringMatching(/Circular dependency detected/),
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it('should not show cyclic dependency warning when option is not present', async () => {
|
||||
harness.useTarget('build', {
|
||||
...BASE_OPTIONS,
|
||||
});
|
||||
|
||||
const { result, logs } = await harness.executeOnce();
|
||||
|
||||
expect(result?.success).toBe(true);
|
||||
expect(logs).not.toContain(
|
||||
jasmine.objectContaining<logging.LogEntry>({
|
||||
message: jasmine.stringMatching(/Circular dependency detected/),
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
@ -177,12 +177,6 @@
|
||||
"description": "Extract all licenses in a separate file, in the case of production builds only.",
|
||||
"default": true
|
||||
},
|
||||
"showCircularDependencies": {
|
||||
"type": "boolean",
|
||||
"description": "Show circular dependency warnings on builds.",
|
||||
"default": false,
|
||||
"x-deprecated": "The recommended method to detect circular dependencies in project code is to use either a lint rule or other external tooling."
|
||||
},
|
||||
"namedChunks": {
|
||||
"type": "boolean",
|
||||
"description": "Use file name for lazy loaded chunks.",
|
||||
|
@ -49,7 +49,6 @@ export interface BuildOptions {
|
||||
deleteOutputPath?: boolean;
|
||||
preserveSymlinks?: boolean;
|
||||
extractLicenses?: boolean;
|
||||
showCircularDependencies?: boolean;
|
||||
buildOptimizer?: boolean;
|
||||
namedChunks?: boolean;
|
||||
crossOrigin?: CrossOrigin;
|
||||
|
@ -173,15 +173,6 @@ export async function getCommonConfig(wco: WebpackConfigOptions): Promise<Config
|
||||
);
|
||||
}
|
||||
|
||||
if (buildOptions.showCircularDependencies) {
|
||||
const CircularDependencyPlugin = require('circular-dependency-plugin');
|
||||
extraPlugins.push(
|
||||
new CircularDependencyPlugin({
|
||||
exclude: /[\\/]node_modules[\\/]/,
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
if (buildOptions.extractLicenses) {
|
||||
const LicenseWebpackPlugin = require('license-webpack-plugin').LicenseWebpackPlugin;
|
||||
extraPlugins.push(
|
||||
|
@ -9,6 +9,11 @@
|
||||
"version": "14.0.0",
|
||||
"factory": "./update-14/update-tsconfig-target",
|
||||
"description": "Update TypeScript compilation target to 'ES2020'."
|
||||
},
|
||||
"remove-show-circular-dependencies-option": {
|
||||
"version": "14.0.0",
|
||||
"factory": "./update-14/remove-show-circular-dependencies-option",
|
||||
"description": "Remove 'showCircularDependencies' option from browser and server builders."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,28 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright Google LLC All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import { Rule } from '@angular-devkit/schematics';
|
||||
import { allTargetOptions, updateWorkspace } from '../../utility/workspace';
|
||||
|
||||
/** Migration to remove 'showCircularDependencies' option from browser and server builders. */
|
||||
export default function (): Rule {
|
||||
return updateWorkspace((workspace) => {
|
||||
for (const project of workspace.projects.values()) {
|
||||
for (const target of project.targets.values()) {
|
||||
if (
|
||||
target.builder === '@angular-devkit/build-angular:server' ||
|
||||
target.builder === '@angular-devkit/build-angular:browser'
|
||||
) {
|
||||
for (const [, options] of allTargetOptions(target)) {
|
||||
delete options.showCircularDependencies;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
@ -0,0 +1,82 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright Google LLC All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import { JsonObject } from '@angular-devkit/core';
|
||||
import { EmptyTree } from '@angular-devkit/schematics';
|
||||
import { SchematicTestRunner, UnitTestTree } from '@angular-devkit/schematics/testing';
|
||||
import {
|
||||
BuilderTarget,
|
||||
Builders,
|
||||
ProjectType,
|
||||
WorkspaceSchema,
|
||||
} from '../../utility/workspace-models';
|
||||
|
||||
function getBuildTarget(tree: UnitTestTree): BuilderTarget<Builders.Browser, JsonObject> {
|
||||
return JSON.parse(tree.readContent('/angular.json')).projects.app.architect.build;
|
||||
}
|
||||
|
||||
function createWorkSpaceConfig(tree: UnitTestTree) {
|
||||
const angularConfig: WorkspaceSchema = {
|
||||
version: 1,
|
||||
projects: {
|
||||
app: {
|
||||
root: '',
|
||||
sourceRoot: 'src',
|
||||
projectType: ProjectType.Application,
|
||||
prefix: 'app',
|
||||
architect: {
|
||||
build: {
|
||||
builder: Builders.Browser,
|
||||
options: {
|
||||
extractCss: false,
|
||||
showCircularDependencies: true,
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
} as any,
|
||||
configurations: {
|
||||
one: {
|
||||
showCircularDependencies: false,
|
||||
aot: true,
|
||||
},
|
||||
two: {
|
||||
showCircularDependencies: false,
|
||||
aot: true,
|
||||
},
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
} as any,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
tree.create('/angular.json', JSON.stringify(angularConfig, undefined, 2));
|
||||
}
|
||||
|
||||
describe(`Migration to remove 'showCircularDependencies' option.`, () => {
|
||||
const schematicName = 'remove-show-circular-dependencies-option';
|
||||
const schematicRunner = new SchematicTestRunner(
|
||||
'migrations',
|
||||
require.resolve('../migration-collection.json'),
|
||||
);
|
||||
|
||||
let tree: UnitTestTree;
|
||||
beforeEach(() => {
|
||||
tree = new UnitTestTree(new EmptyTree());
|
||||
createWorkSpaceConfig(tree);
|
||||
});
|
||||
|
||||
it(`should remove 'showCircularDependencies'`, async () => {
|
||||
const newTree = await schematicRunner.runSchematicAsync(schematicName, {}, tree).toPromise();
|
||||
const { options, configurations } = getBuildTarget(newTree);
|
||||
|
||||
expect(options.showCircularDependencies).toBeUndefined();
|
||||
expect(configurations).toBeDefined();
|
||||
expect(configurations?.one.showCircularDependencies).toBeUndefined();
|
||||
expect(configurations?.two.showCircularDependencies).toBeUndefined();
|
||||
});
|
||||
});
|
@ -1,14 +0,0 @@
|
||||
import { prependToFile } from '../../utils/fs';
|
||||
import { ng } from '../../utils/process';
|
||||
|
||||
|
||||
export default async function () {
|
||||
// TODO(architect): Delete this test. It is now in devkit/build-angular.
|
||||
|
||||
await prependToFile('src/app/app.component.ts',
|
||||
`import { AppModule } from './app.module'; console.log(AppModule);`);
|
||||
const { stderr } = await ng('build', '--show-circular-dependencies', '--configuration=development');
|
||||
if (!stderr.match(/Warning: Circular dependency detected/)) {
|
||||
throw new Error('Expected to have circular dependency warning in output.');
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user