Skip to content

Commit 7c1b045

Browse files
committed
feat(@ngtools/webpack): create compiler host for webpack child compilations
1 parent 03d238f commit 7c1b045

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

packages/ngtools/webpack/src/angular_compiler_plugin.ts

+16
Original file line numberDiff line numberDiff line change
@@ -822,6 +822,22 @@ export class AngularCompilerPlugin {
822822
throw new Error('An @ngtools/webpack plugin already exist for this compilation.');
823823
}
824824

825+
// If there is no compiler host at this point, it means that the environment hook did not run.
826+
// This happens in child compilations that inherit the parent compilation file system.
827+
if (this._compilerHost === undefined) {
828+
// Create a simplified compiler host for child compilations.
829+
const host: virtualFs.Host<fs.Stats> = new WebpackInputHost(
830+
compilation.compiler.inputFileSystem,
831+
);
832+
const webpackCompilerHost = new WebpackCompilerHost(
833+
this._compilerOptions, this._basePath, host, true, true,
834+
);
835+
this._compilerHost = createCompilerHost({
836+
options: this._compilerOptions,
837+
tsHost: webpackCompilerHost,
838+
}) as CompilerHost & WebpackCompilerHost;
839+
}
840+
825841
// Set a private variable for this plugin instance.
826842
// tslint:disable-next-line:no-any
827843
(compilation as any)._ngToolsWebpackPluginInstance = this;

0 commit comments

Comments
 (0)