Skip to content

Commit

Permalink
fix(@angular/cli): capture CPU profile
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
nlm-pro authored and hansl committed Oct 3, 2018
1 parent eab4c2e commit 3de49db
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
6 changes: 3 additions & 3 deletions lib/bootstrap-local.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ if (process.env['CODE_COVERAGE'] || process.argv.indexOf('--code-coverage') !==
let profiler = null;
if (process.env['DEVKIT_PROFILING']) {
try {
profiler = require('v8-profiler');
profiler = require('v8-profiler-node8');
} catch (err) {
throw new Error(`Could not require 'v8-profiler'. You must install it separetely with` +
`'npm install v8-profiler --no-save.\n\nOriginal error:\n\n${err}`);
throw new Error(`Could not require 'v8-profiler-node8'. You must install it separetely with` +
`'npm install v8-profiler-node8 --no-save.\n\nOriginal error:\n\n${err}`);
}

profiler.startProfiling();
Expand Down
10 changes: 9 additions & 1 deletion packages/angular/cli/lib/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,16 @@ function _fromPackageJson(cwd?: string) {

// Check if we need to profile this CLI run.
if (process.env['NG_CLI_PROFILING']) {
const profiler = require('v8-profiler'); // tslint:disable-line:no-implicit-dependencies
let profiler: any = null;
try {
profiler = require('v8-profiler-node8'); // tslint:disable-line:no-implicit-dependencies
} catch (err) {
throw new Error(`Could not require 'v8-profiler-node8'. You must install it separetely with` +
`'npm install v8-profiler-node8 --no-save.\n\nOriginal error:\n\n${err}`);
}

profiler.startProfiling();

const exitHandler = (options: { cleanup?: boolean, exit?: boolean }) => {
if (options.cleanup) {
const cpuProfile = profiler.stopProfiling();
Expand Down

0 comments on commit 3de49db

Please sign in to comment.