Skip to content

Commit 8bc91cf

Browse files
committed
fix(@angular/cli): capture CPU profile
Replace the v8-profiler dependency with v8-profiler-node8 as the first one doesn't support node 8 and 10, and that @angular/cli support only node 8 and 10.
1 parent 8150838 commit 8bc91cf

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

lib/bootstrap-local.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ if (process.env['CODE_COVERAGE'] || process.argv.indexOf('--code-coverage') !==
2626
let profiler = null;
2727
if (process.env['DEVKIT_PROFILING']) {
2828
try {
29-
profiler = require('v8-profiler');
29+
profiler = require('v8-profiler-node8');
3030
} catch (err) {
31-
throw new Error(`Could not require 'v8-profiler'. You must install it separetely with` +
32-
`'npm install v8-profiler --no-save.\n\nOriginal error:\n\n${err}`);
31+
throw new Error(`Could not require 'v8-profiler-node8'. You must install it separetely with` +
32+
`'npm install v8-profiler-node8 --no-save.\n\nOriginal error:\n\n${err}`);
3333
}
3434

3535
profiler.startProfiling();

packages/angular/cli/lib/init.ts

+9-1
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,16 @@ function _fromPackageJson(cwd?: string) {
4343

4444
// Check if we need to profile this CLI run.
4545
if (process.env['NG_CLI_PROFILING']) {
46-
const profiler = require('v8-profiler'); // tslint:disable-line:no-implicit-dependencies
46+
let profiler: any = null;
47+
try {
48+
profiler = require('v8-profiler-node8'); // tslint:disable-line:no-implicit-dependencies
49+
} catch (err) {
50+
throw new Error(`Could not require 'v8-profiler-node8'. You must install it separetely with` +
51+
`'npm install v8-profiler-node8 --no-save.\n\nOriginal error:\n\n${err}`);
52+
}
53+
4754
profiler.startProfiling();
55+
4856
const exitHandler = (options: { cleanup?: boolean, exit?: boolean }) => {
4957
if (options.cleanup) {
5058
const cpuProfile = profiler.stopProfiling();

0 commit comments

Comments
 (0)