mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-22 15:02:11 +08:00
build: add bootstrap debug logs
This commit is contained in:
parent
50a7f4ad8d
commit
3c0bb12091
20
lib/bootstrap-local.js
vendored
20
lib/bootstrap-local.js
vendored
@ -7,6 +7,11 @@
|
|||||||
*/
|
*/
|
||||||
/* eslint-disable no-console */
|
/* eslint-disable no-console */
|
||||||
'use strict';
|
'use strict';
|
||||||
|
const debug = require('debug');
|
||||||
|
const debugLocal = debug('ng:local');
|
||||||
|
const debugBuildEjs = debug('ng:local:build:ejs');
|
||||||
|
const debugBuildSchema = debug('ng:local:build:schema');
|
||||||
|
const debugBuildTs = debug('ng:local:build:ts');
|
||||||
|
|
||||||
const child_process = require('child_process');
|
const child_process = require('child_process');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
@ -16,12 +21,15 @@ const ts = require('typescript');
|
|||||||
|
|
||||||
const tmpRoot = temp.mkdirSync('angular-devkit-');
|
const tmpRoot = temp.mkdirSync('angular-devkit-');
|
||||||
|
|
||||||
|
debugLocal('starting bootstrap local');
|
||||||
|
|
||||||
const compilerOptions = ts.readConfigFile(path.join(__dirname, '../tsconfig.json'), p => {
|
const compilerOptions = ts.readConfigFile(path.join(__dirname, '../tsconfig.json'), p => {
|
||||||
return fs.readFileSync(p, 'utf-8');
|
return fs.readFileSync(p, 'utf-8');
|
||||||
}).config;
|
}).config;
|
||||||
|
|
||||||
let _istanbulRequireHook = null;
|
let _istanbulRequireHook = null;
|
||||||
if (process.env['CODE_COVERAGE'] || process.argv.indexOf('--code-coverage') !== -1) {
|
if (process.env['CODE_COVERAGE'] || process.argv.indexOf('--code-coverage') !== -1) {
|
||||||
|
debugLocal('setup code coverage');
|
||||||
_istanbulRequireHook = require('./istanbul-local').istanbulRequireHook;
|
_istanbulRequireHook = require('./istanbul-local').istanbulRequireHook;
|
||||||
// async keyword isn't supported by the Esprima version used by Istanbul version used by us.
|
// async keyword isn't supported by the Esprima version used by Istanbul version used by us.
|
||||||
// TODO: update istanbul to istanbul-lib-* (see http://istanbul.js.org/) and remove this hack.
|
// TODO: update istanbul to istanbul-lib-* (see http://istanbul.js.org/) and remove this hack.
|
||||||
@ -32,6 +40,7 @@ if (process.env['CODE_COVERAGE'] || process.argv.indexOf('--code-coverage') !==
|
|||||||
// Check if we need to profile this CLI run.
|
// Check if we need to profile this CLI run.
|
||||||
let profiler = null;
|
let profiler = null;
|
||||||
if (process.env['DEVKIT_PROFILING']) {
|
if (process.env['DEVKIT_PROFILING']) {
|
||||||
|
debugLocal('setup profiling');
|
||||||
try {
|
try {
|
||||||
profiler = require('v8-profiler-node8');
|
profiler = require('v8-profiler-node8');
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@ -47,6 +56,7 @@ if (process.env['DEVKIT_PROFILING']) {
|
|||||||
const profileData = JSON.stringify(cpuProfile);
|
const profileData = JSON.stringify(cpuProfile);
|
||||||
const filePath = path.resolve(process.cwd(), process.env.DEVKIT_PROFILING) + '.cpuprofile';
|
const filePath = path.resolve(process.cwd(), process.env.DEVKIT_PROFILING) + '.cpuprofile';
|
||||||
|
|
||||||
|
debugLocal('saving profiling data');
|
||||||
console.log(`Profiling data saved in "${filePath}": ${profileData.length} bytes`);
|
console.log(`Profiling data saved in "${filePath}": ${profileData.length} bytes`);
|
||||||
fs.writeFileSync(filePath, profileData);
|
fs.writeFileSync(filePath, profileData);
|
||||||
}
|
}
|
||||||
@ -62,6 +72,7 @@ if (process.env['DEVKIT_PROFILING']) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (process.env['DEVKIT_LONG_STACK_TRACE']) {
|
if (process.env['DEVKIT_LONG_STACK_TRACE']) {
|
||||||
|
debugLocal('setup long stack trace');
|
||||||
Error.stackTraceLimit = Infinity;
|
Error.stackTraceLimit = Infinity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,6 +92,8 @@ require.extensions['.ts'] = function (m, filename) {
|
|||||||
return m._compile(fs.readFileSync(filename), filename);
|
return m._compile(fs.readFileSync(filename), filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
debugBuildTs(filename);
|
||||||
|
|
||||||
// Node requires all require hooks to be sync.
|
// Node requires all require hooks to be sync.
|
||||||
const source = fs.readFileSync(filename).toString();
|
const source = fs.readFileSync(filename).toString();
|
||||||
|
|
||||||
@ -90,6 +103,7 @@ require.extensions['.ts'] = function (m, filename) {
|
|||||||
if (_istanbulRequireHook) {
|
if (_istanbulRequireHook) {
|
||||||
result = _istanbulRequireHook(result, filename);
|
result = _istanbulRequireHook(result, filename);
|
||||||
}
|
}
|
||||||
|
debugBuildTs('done');
|
||||||
|
|
||||||
// Send it to node to execute.
|
// Send it to node to execute.
|
||||||
return m._compile(result, filename);
|
return m._compile(result, filename);
|
||||||
@ -102,10 +116,13 @@ require.extensions['.ts'] = function (m, filename) {
|
|||||||
|
|
||||||
|
|
||||||
require.extensions['.ejs'] = function (m, filename) {
|
require.extensions['.ejs'] = function (m, filename) {
|
||||||
|
debugBuildEjs(filename);
|
||||||
|
|
||||||
const source = fs.readFileSync(filename).toString();
|
const source = fs.readFileSync(filename).toString();
|
||||||
const template = require('@angular-devkit/core').template;
|
const template = require('@angular-devkit/core').template;
|
||||||
const result = template(source, { sourceURL: filename, sourceMap: true });
|
const result = template(source, { sourceURL: filename, sourceMap: true });
|
||||||
|
|
||||||
|
debugBuildEjs('done');
|
||||||
return m._compile(result.source.replace(/return/, 'module.exports.default = '), filename);
|
return m._compile(result.source.replace(/return/, 'module.exports.default = '), filename);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -157,6 +174,8 @@ if (!__dirname.match(new RegExp(`\\${path.sep}node_modules\\${path.sep}`))) {
|
|||||||
if (fs.existsSync(maybeTsPath)) {
|
if (fs.existsSync(maybeTsPath)) {
|
||||||
return maybeTsPath;
|
return maybeTsPath;
|
||||||
} else {
|
} else {
|
||||||
|
debugBuildSchema('%s', resolved);
|
||||||
|
|
||||||
// This script has the be synchronous, so we spawnSync instead of, say, requiring the runner and calling
|
// This script has the be synchronous, so we spawnSync instead of, say, requiring the runner and calling
|
||||||
// the method directly.
|
// the method directly.
|
||||||
const tmpJsonSchemaPath = path.join(tmpRoot, maybeTsPath.replace(/[^0-9a-zA-Z.]/g, '_'));
|
const tmpJsonSchemaPath = path.join(tmpRoot, maybeTsPath.replace(/[^0-9a-zA-Z.]/g, '_'));
|
||||||
@ -166,6 +185,7 @@ if (!__dirname.match(new RegExp(`\\${path.sep}node_modules\\${path.sep}`))) {
|
|||||||
child_process.spawnSync('node', [quicktypeRunnerPath, resolved, tmpJsonSchemaPath]);
|
child_process.spawnSync('node', [quicktypeRunnerPath, resolved, tmpJsonSchemaPath]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
debugBuildSchema('done');
|
||||||
return tmpJsonSchemaPath;
|
return tmpJsonSchemaPath;
|
||||||
} catch (_) {
|
} catch (_) {
|
||||||
// Just return resolvedPath and let Node deals with it.
|
// Just return resolvedPath and let Node deals with it.
|
||||||
|
@ -63,8 +63,10 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@types/debug": "^4.1.2",
|
||||||
"@types/node-fetch": "^2.1.6",
|
"@types/node-fetch": "^2.1.6",
|
||||||
"@types/progress": "^2.0.3",
|
"@types/progress": "^2.0.3",
|
||||||
|
"debug": "^4.1.1",
|
||||||
"glob": "^7.0.3",
|
"glob": "^7.0.3",
|
||||||
"node-fetch": "^2.2.0",
|
"node-fetch": "^2.2.0",
|
||||||
"puppeteer": "1.12.2",
|
"puppeteer": "1.12.2",
|
||||||
|
@ -291,6 +291,11 @@
|
|||||||
"@types/minimatch" "*"
|
"@types/minimatch" "*"
|
||||||
"@types/webpack" "*"
|
"@types/webpack" "*"
|
||||||
|
|
||||||
|
"@types/debug@^4.1.2":
|
||||||
|
version "4.1.2"
|
||||||
|
resolved "https://registry.yarnpkg.com/@types/debug/-/debug-4.1.2.tgz#84824e9259fc583dd9385635738359c9582f7f82"
|
||||||
|
integrity sha512-jkf6UiWUjcOqdQbatbvOm54/YbCdjt3JjiAzT/9KS2XtMmOkYHdKsI5u8fulhbuTUuiqNBfa6J5GSDiwjK+zLA==
|
||||||
|
|
||||||
"@types/estree@0.0.39":
|
"@types/estree@0.0.39":
|
||||||
version "0.0.39"
|
version "0.0.39"
|
||||||
resolved "https://registry.yarnpkg.com/@types/estree/-/estree-0.0.39.tgz#e177e699ee1b8c22d23174caaa7422644389509f"
|
resolved "https://registry.yarnpkg.com/@types/estree/-/estree-0.0.39.tgz#e177e699ee1b8c22d23174caaa7422644389509f"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user