Skip to content

Commit 1379e35

Browse files
committed
fixing e2e bug with aot
1 parent d80f57e commit 1379e35

File tree

5 files changed

+21
-11
lines changed

5 files changed

+21
-11
lines changed

packages/webpack/src/compiler_host.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ export class WebpackCompilerHost implements ts.CompilerHost {
116116
}
117117

118118
for (const fileName of Object.keys(this._files)) {
119+
console.log(1, fileName);
119120
const stats = this._files[fileName];
120121
fs._statStorage.data[fileName] = [null, stats];
121122
fs._readFileStorage.data[fileName] = [null, stats.content];

packages/webpack/src/loader.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,15 @@ function _replaceBootstrap(plugin: AotPlugin, refactor: TypeScriptFileRefactor)
7979
allCalls
8080
.filter(call => bootstraps.some(bs => bs == call.expression))
8181
.forEach((call: ts.CallExpression) => {
82-
refactor.replaceNode(call.arguments[0], entryModule.className + 'NgFactory', true);
82+
refactor.replaceNode(call.arguments[0], entryModule.className + 'NgFactory');
8383
});
8484

85-
calls.forEach(call => refactor.replaceNode(call.expression, 'platformBrowser', true));
85+
calls.forEach(call => refactor.replaceNode(call.expression, 'platformBrowser'));
8686

8787
bootstraps
8888
.forEach((bs: ts.PropertyAccessExpression) => {
8989
// This changes the call.
90-
refactor.replaceNode(bs.name, 'bootstrapModuleFactory', true);
90+
refactor.replaceNode(bs.name, 'bootstrapModuleFactory');
9191
});
9292

9393
refactor.insertImport('platformBrowser', '@angular/platform-browser');

packages/webpack/src/plugin.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ export class AotPlugin implements Tapable {
188188
(_: any, cb: any) => cb(null, this._lazyRoutes));
189189

190190
return callback(null, result);
191-
});
191+
}).catch((err) => callback(err));
192192
});
193193
});
194194

@@ -227,11 +227,6 @@ export class AotPlugin implements Tapable {
227227
basePath: this.basePath
228228
};
229229

230-
// Create a new Program, based on the old one. This will trigger a resolution of all
231-
// transitive modules, which include files that might just have been generated.
232-
this._program = ts.createProgram(
233-
this._rootFilePath, this._compilerOptions, this._compilerHost, this._program);
234-
235230
// We need to temporarily patch the CodeGenerator until either it's patched or allows us
236231
// to pass in our own ReflectorHost.
237232
let promise = Promise.resolve();
@@ -253,6 +248,14 @@ export class AotPlugin implements Tapable {
253248
}
254249

255250
this._donePromise = promise
251+
.then(() => {
252+
// Create a new Program, based on the old one. This will trigger a resolution of all
253+
// transitive modules, which include files that might just have been generated.
254+
// This needs to happen after the code generator has been created for generated files
255+
// to be properly resolved.
256+
this._program = ts.createProgram(
257+
this._rootFilePath, this._compilerOptions, this._compilerHost, this._program);
258+
})
256259
.then(() => {
257260
const diagnostics = this._program.getGlobalDiagnostics();
258261
if (diagnostics.length > 0) {

packages/webpack/src/refactor.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,12 @@ export class TypeScriptFileRefactor {
141141
this._changed = true;
142142
}
143143

144-
replaceNode(node: ts.Node, replacement: string, name = false) {
145-
this._sourceString.overwrite(node.getStart(this._sourceFile), node.getEnd(), replacement, name);
144+
replaceNode(node: ts.Node, replacement: string) {
145+
let replaceSymbolName: boolean = node.kind === ts.SyntaxKind.Identifier;
146+
this._sourceString.overwrite(node.getStart(this._sourceFile),
147+
node.getEnd(),
148+
replacement,
149+
replaceSymbolName);
146150
this._changed = true;
147151
}
148152

packages/webpack/src/webpack.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Declarations for (some) Webpack types. Only what's needed.
2+
13
export interface Request {
24
request?: Request;
35
relativePath: string;

0 commit comments

Comments
 (0)