Skip to content

Commit 422a919

Browse files
clydinfilipesilva
authored andcommitted
refactor(@ngtools/webpack): simplify vfs webpack integration
1 parent a47f024 commit 422a919

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
@@ -614,19 +614,21 @@ export class AngularCompilerPlugin implements Tapable {
614614
this._donePromise = null;
615615
});
616616

617-
// TODO: consider if it's better to remove this plugin and instead make it wait on the
618-
// VirtualFileSystemDecorator.
619617
compiler.plugin('after-resolvers', (compiler: any) => {
620-
// Virtual file system.
621-
// Wait for the plugin to be done when requesting `.ts` files directly (entry points), or
622-
// when the issuer is a `.ts` or `.ngfactory.js` file.
623-
compiler.resolvers.normal.plugin('before-resolve', (request: any, cb: () => void) => {
624-
if (this.done && (request.request.endsWith('.ts')
625-
|| (request.context.issuer && /\.ts|ngfactory\.js$/.test(request.context.issuer)))) {
626-
this.done.then(() => cb(), () => cb());
627-
} else {
628-
cb();
629-
}
618+
compiler.plugin('normal-module-factory', (nmf: any) => {
619+
// Virtual file system.
620+
// TODO: consider if it's better to remove this plugin and instead make it wait on the
621+
// VirtualFileSystemDecorator.
622+
// Wait for the plugin to be done when requesting `.ts` files directly (entry points), or
623+
// when the issuer is a `.ts` or `.ngfactory.js` file.
624+
nmf.plugin('before-resolve', (request: any, callback: any) => {
625+
if (this.done && (request.request.endsWith('.ts')
626+
|| (request.context.issuer && /\.ts|ngfactory\.js$/.test(request.context.issuer)))) {
627+
this.done.then(() => callback(null, request), () => callback(null, request));
628+
} else {
629+
callback(null, request);
630+
}
631+
});
630632
});
631633
});
632634

0 commit comments

Comments
 (0)