Skip to content

Commit 9e22d7a

Browse files
alan-agius4filipesilva
authored andcommitted
refactor(@angular-devkit/build-angular): remove NG_BUILD_PROFILING and DEVKIT_PROFILING logic
Generating a CPU profile using Node.JS `--cpu-prof` or Chrome insector is preferred. Closes #20336
1 parent d55fc62 commit 9e22d7a

File tree

4 files changed

+1
-62
lines changed

4 files changed

+1
-62
lines changed

lib/bootstrap-local.js

-36
Original file line numberDiff line numberDiff line change
@@ -31,42 +31,6 @@ const compilerOptions = ts.getParsedCommandLineOfConfigFile(
3131
ts.sys,
3232
).options;
3333

34-
// Check if we need to profile this CLI run.
35-
let profiler = null;
36-
if (process.env['DEVKIT_PROFILING']) {
37-
debugLocal('setup profiling');
38-
try {
39-
profiler = require('v8-profiler-node8');
40-
} catch (err) {
41-
throw new Error(
42-
`Could not require 'v8-profiler-node8'. You must install it separetely with` +
43-
`'npm install v8-profiler-node8 --no-save.\n\nOriginal error:\n\n${err}`,
44-
);
45-
}
46-
47-
profiler.startProfiling();
48-
49-
function exitHandler(options, _err) {
50-
if (options.cleanup) {
51-
const cpuProfile = profiler.stopProfiling();
52-
const profileData = JSON.stringify(cpuProfile);
53-
const filePath = path.resolve(process.cwd(), process.env.DEVKIT_PROFILING) + '.cpuprofile';
54-
55-
debugLocal('saving profiling data');
56-
console.log(`Profiling data saved in "${filePath}": ${profileData.length} bytes`);
57-
fs.writeFileSync(filePath, profileData);
58-
}
59-
60-
if (options.exit) {
61-
process.exit();
62-
}
63-
}
64-
65-
process.on('exit', exitHandler.bind(null, { cleanup: true }));
66-
process.on('SIGINT', exitHandler.bind(null, { exit: true }));
67-
process.on('uncaughtException', exitHandler.bind(null, { exit: true }));
68-
}
69-
7034
if (process.env['DEVKIT_LONG_STACK_TRACE']) {
7135
debugLocal('setup long stack trace');
7236
Error.stackTraceLimit = Infinity;

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

-4
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,6 @@ export const allowMangle = isPresent(mangleVariable)
6666
export const shouldBeautify = debugOptimize.beautify;
6767
export const allowMinify = debugOptimize.minify;
6868

69-
// Build profiling
70-
const profilingVariable = process.env['NG_BUILD_PROFILING'];
71-
export const profilingEnabled = isPresent(profilingVariable) && isEnabled(profilingVariable);
72-
7369
/**
7470
* Some environments, like CircleCI which use Docker report a number of CPUs by the host and not the count of available.
7571
* This cause `Error: Call retries were exceeded` errors when trying to use them.

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

+1-10
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,11 @@ import {
1616
ContextReplacementPlugin,
1717
RuleSetRule,
1818
SourceMapDevToolPlugin,
19-
debug,
2019
} from 'webpack';
2120
import { SubresourceIntegrityPlugin } from 'webpack-subresource-integrity';
2221
import { AngularBabelLoaderOptions } from '../../babel/webpack-loader';
2322
import { WebpackConfigOptions } from '../../utils/build-options';
24-
import { allowMangle, profilingEnabled } from '../../utils/environment-options';
23+
import { allowMangle } from '../../utils/environment-options';
2524
import { loadEsmModule } from '../../utils/load-esm';
2625
import {
2726
CommonJsUsageWarnPlugin,
@@ -133,14 +132,6 @@ export async function getCommonConfig(wco: WebpackConfigOptions): Promise<Config
133132
}
134133
}
135134

136-
if (profilingEnabled) {
137-
extraPlugins.push(
138-
new debug.ProfilingPlugin({
139-
outputPath: path.resolve(root, 'chrome-profiler-events.json'),
140-
}),
141-
);
142-
}
143-
144135
if (allowedCommonJsDependencies) {
145136
// When this is not defined it means the builder doesn't support showing common js usages.
146137
// When it does it will be an array.

tests/legacy-cli/e2e/tests/build/profile.ts

-12
This file was deleted.

0 commit comments

Comments
 (0)