Skip to content
This repository was archived by the owner on May 1, 2020. It is now read-only.

Commit 4a2fda1

Browse files
committed
chore(logging): add additional logging
1 parent e6bcf22 commit 4a2fda1

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

src/aot/aot-compiler.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,11 @@ export class AotCompiler {
7070
// We need to temporarily patch the CodeGenerator until either it's patched or allows us
7171
// to pass in our own ReflectorHost.
7272
patchReflectorHost(codeGenerator);
73+
Logger.debug('[AotCompiler] compile: starting codegen ... ');
7374
return codeGenerator.codegen({transitiveModules: true});
7475
}).then(() => {
76+
Logger.debug('[AotCompiler] compile: starting codegen ... DONE');
77+
Logger.debug('[AotCompiler] compile: Creating and validating new TypeScript Program ...');
7578
// Create a new Program, based on the old one. This will trigger a resolution of all
7679
// transitive modules, which include files that might just have been generated.
7780
this.program = createProgram(this.tsConfig.parsed.fileNames, this.tsConfig.parsed.options, this.compilerHost, this.program);
@@ -92,23 +95,29 @@ export class AotCompiler {
9295
}
9396
})
9497
.then(() => {
98+
Logger.debug('[AotCompiler] compile: Creating and validating new TypeScript Program ... DONE');
99+
Logger.debug('[AotCompiler] compile: The following files are included in the program: ');
95100
for ( const fileName of this.tsConfig.parsed.fileNames) {
101+
Logger.debug(`[AotCompiler] compile: ${fileName}`);
96102
const cleanedFileName = normalize(resolve(fileName));
97103
const content = readFileSync(cleanedFileName).toString();
98104
this.context.fileCache.set(cleanedFileName, { path: cleanedFileName, content: content});
99105
}
100106
})
101107
.then(() => {
108+
Logger.debug('[AotCompiler] compile: Starting to process and modify entry point ...');
102109
const mainFile = this.context.fileCache.get(this.options.entryPoint);
103110
if (!mainFile) {
104111
throw new BuildError(new Error(`Could not find entry point (bootstrap file) ${this.options.entryPoint}`));
105112
}
106113
const mainSourceFile = getTypescriptSourceFile(mainFile.path, mainFile.content, ScriptTarget.Latest, false);
114+
Logger.debug('[AotCompiler] compile: Resolving NgModule from entry point');
107115
const AppNgModuleStringAndClassName = resolveAppNgModuleFromMain(mainSourceFile, this.context.fileCache, this.compilerHost, this.program);
108116
const AppNgModuleTokens = AppNgModuleStringAndClassName.split('#');
109117

110118
let modifiedFileContent: string = null;
111119
try {
120+
Logger.debug('[AotCompiler] compile: Dynamically changing entry point content to AOT mode content');
112121
modifiedFileContent = replaceBootstrap(mainFile.path, mainFile.content, AppNgModuleTokens[0], AppNgModuleTokens[1]);
113122
} catch (ex) {
114123
Logger.debug(`Failed to parse bootstrap: `, ex.message);
@@ -119,9 +128,12 @@ export class AotCompiler {
119128
modifiedFileContent = getFallbackMainContent();
120129
}
121130

131+
Logger.debug(`[AotCompiler] compile: Modified File Content: ${modifiedFileContent}`);
122132
this.context.fileCache.set(this.options.entryPoint, { path: this.options.entryPoint, content: modifiedFileContent});
123133
})
124134
.then(() => {
135+
Logger.debug('[AotCompiler] compile: Starting to process and modify entry point ... DONE');
136+
Logger.debug('[AotCompiler] compile: Removing decorators from program files ...');
125137
const tsFiles = this.context.fileCache.getAll().filter(file => extname(file.path) === '.ts' && file.path.indexOf('.d.ts') === -1);
126138
for (const tsFile of tsFiles) {
127139
const cleanedFileContent = removeDecorators(tsFile.path, tsFile.content);
@@ -138,6 +150,7 @@ export class AotCompiler {
138150
this.fileSystem.addVirtualFile(jsFilePath, transpileOutput.outputText);
139151
this.fileSystem.addVirtualFile(jsFilePath + '.map', transpileOutput.sourceMapText);
140152
}
153+
Logger.debug('[AotCompiler] compile: Removing decorators from program files ... DONE');
141154
});
142155
}
143156

src/aot/compiler-host.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { CancellationToken, CompilerHost, CompilerOptions, createCompilerHost, ScriptTarget, SourceFile } from 'typescript';
22
import { VirtualFileSystem } from '../util/interfaces';
33
import { getTypescriptSourceFile } from '../util/typescript-utils';
4+
import { Logger } from '../logger/logger';
45

56
export interface OnErrorFn {
67
(message: string): void;
@@ -82,6 +83,7 @@ export class NgcCompilerHost implements CompilerHost {
8283
}
8384

8485
writeFile(fileName: string, data: string, writeByteOrderMark: boolean, onError?: OnErrorFn) {
86+
Logger.debug(`[NgcCompilerHost] writeFile: adding ${fileName} to virtual file system`);
8587
this.fileSystem.addVirtualFile(fileName, data);
8688
}
8789

src/util/hybrid-file-system.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { basename, dirname } from 'path';
22
import { FileSystem, VirtualFileSystem } from './interfaces';
33
import { FileCache } from './file-cache';
44
import { VirtualDirStats, VirtualFileStats } from './virtual-file-utils';
5+
import { Logger } from '../logger/logger';
56

67
export class HybridFileSystem implements FileSystem, VirtualFileSystem {
78

@@ -58,6 +59,7 @@ export class HybridFileSystem implements FileSystem, VirtualFileSystem {
5859
}
5960

6061
readFile(path: string, callback: Function): any {
62+
Logger.debug(`[HybridFileSystem] readFile: reading ${path}`);
6163
const file = this.fileCache.get(path);
6264
if (file) {
6365
callback(null, new Buffer(file.content));
@@ -76,6 +78,7 @@ export class HybridFileSystem implements FileSystem, VirtualFileSystem {
7678
}
7779

7880
getFileContent(filePath: string) {
81+
Logger.debug(`[HybridFileSystem] getFileContent: get from cache ${filePath}`);
7982
const file = this.fileCache.get(filePath);
8083
if (file) {
8184
return file.content;

0 commit comments

Comments
 (0)