diff --git a/lib/bootstrap-local.js b/lib/bootstrap-local.js index c8194e11fb..c6ff2e45f6 100644 --- a/lib/bootstrap-local.js +++ b/lib/bootstrap-local.js @@ -7,6 +7,11 @@ */ /* eslint-disable no-console */ '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 fs = require('fs'); @@ -16,12 +21,15 @@ const ts = require('typescript'); const tmpRoot = temp.mkdirSync('angular-devkit-'); +debugLocal('starting bootstrap local'); + const compilerOptions = ts.readConfigFile(path.join(__dirname, '../tsconfig.json'), p => { return fs.readFileSync(p, 'utf-8'); }).config; let _istanbulRequireHook = null; if (process.env['CODE_COVERAGE'] || process.argv.indexOf('--code-coverage') !== -1) { + debugLocal('setup code coverage'); _istanbulRequireHook = require('./istanbul-local').istanbulRequireHook; // 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. @@ -32,6 +40,7 @@ if (process.env['CODE_COVERAGE'] || process.argv.indexOf('--code-coverage') !== // Check if we need to profile this CLI run. let profiler = null; if (process.env['DEVKIT_PROFILING']) { + debugLocal('setup profiling'); try { profiler = require('v8-profiler-node8'); } catch (err) { @@ -47,6 +56,7 @@ if (process.env['DEVKIT_PROFILING']) { const profileData = JSON.stringify(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`); fs.writeFileSync(filePath, profileData); } @@ -62,6 +72,7 @@ if (process.env['DEVKIT_PROFILING']) { } if (process.env['DEVKIT_LONG_STACK_TRACE']) { + debugLocal('setup long stack trace'); Error.stackTraceLimit = Infinity; } @@ -81,6 +92,8 @@ require.extensions['.ts'] = function (m, filename) { return m._compile(fs.readFileSync(filename), filename); } + debugBuildTs(filename); + // Node requires all require hooks to be sync. const source = fs.readFileSync(filename).toString(); @@ -90,6 +103,7 @@ require.extensions['.ts'] = function (m, filename) { if (_istanbulRequireHook) { result = _istanbulRequireHook(result, filename); } + debugBuildTs('done'); // Send it to node to execute. return m._compile(result, filename); @@ -102,10 +116,13 @@ require.extensions['.ts'] = function (m, filename) { require.extensions['.ejs'] = function (m, filename) { + debugBuildEjs(filename); + const source = fs.readFileSync(filename).toString(); const template = require('@angular-devkit/core').template; const result = template(source, { sourceURL: filename, sourceMap: true }); + debugBuildEjs('done'); 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)) { return maybeTsPath; } else { + debugBuildSchema('%s', resolved); + // This script has the be synchronous, so we spawnSync instead of, say, requiring the runner and calling // the method directly. 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]); } + debugBuildSchema('done'); return tmpJsonSchemaPath; } catch (_) { // Just return resolvedPath and let Node deals with it. diff --git a/package.json b/package.json index 6823e18f46..0360c86103 100644 --- a/package.json +++ b/package.json @@ -63,8 +63,10 @@ ] }, "dependencies": { + "@types/debug": "^4.1.2", "@types/node-fetch": "^2.1.6", "@types/progress": "^2.0.3", + "debug": "^4.1.1", "glob": "^7.0.3", "node-fetch": "^2.2.0", "puppeteer": "1.12.2", diff --git a/yarn.lock b/yarn.lock index 634f403763..3ae32cc8cc 100644 --- a/yarn.lock +++ b/yarn.lock @@ -291,6 +291,11 @@ "@types/minimatch" "*" "@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": version "0.0.39" resolved "https://registry.yarnpkg.com/@types/estree/-/estree-0.0.39.tgz#e177e699ee1b8c22d23174caaa7422644389509f"