Skip to content

Commit ec5c9bc

Browse files
clydinfilipesilva
authored andcommitted
refactor(@ngtools/webpack): simplify vfs webpack integration
1 parent 122f65a commit ec5c9bc

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

packages/@ngtools/webpack/src/angular_compiler_plugin.ts

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -599,19 +599,21 @@ export class AngularCompilerPlugin implements Tapable {
599599
this._donePromise = null;
600600
});
601601

602-
// TODO: consider if it's better to remove this plugin and instead make it wait on the
603-
// VirtualFileSystemDecorator.
604602
compiler.plugin('after-resolvers', (compiler: any) => {
605-
// Virtual file system.
606-
// Wait for the plugin to be done when requesting `.ts` files directly (entry points), or
607-
// when the issuer is a `.ts` or `.ngfactory.js` file.
608-
compiler.resolvers.normal.plugin('before-resolve', (request: any, cb: () => void) => {
609-
if (this.done && (request.request.endsWith('.ts')
610-
|| (request.context.issuer && /\.ts|ngfactory\.js$/.test(request.context.issuer)))) {
611-
this.done.then(() => cb(), () => cb());
612-
} else {
613-
cb();
614-
}
603+
compiler.plugin('normal-module-factory', (nmf: any) => {
604+
// Virtual file system.
605+
// TODO: consider if it's better to remove this plugin and instead make it wait on the
606+
// VirtualFileSystemDecorator.
607+
// Wait for the plugin to be done when requesting `.ts` files directly (entry points), or
608+
// when the issuer is a `.ts` or `.ngfactory.js` file.
609+
nmf.plugin('before-resolve', (request: any, callback: any) => {
610+
if (this.done && (request.request.endsWith('.ts')
611+
|| (request.context.issuer && /\.ts|ngfactory\.js$/.test(request.context.issuer)))) {
612+
this.done.then(() => callback(null, request), () => callback(null, request));
613+
} else {
614+
callback(null, request);
615+
}
616+
});
615617
});
616618
});
617619

0 commit comments

Comments
 (0)