diff --git a/packages/@ngtools/webpack/src/plugin.ts b/packages/@ngtools/webpack/src/plugin.ts index bff8a01e15ef..0ef52434a4b8 100644 --- a/packages/@ngtools/webpack/src/plugin.ts +++ b/packages/@ngtools/webpack/src/plugin.ts @@ -388,6 +388,11 @@ export class AotPlugin implements Tapable { return; } + // Create a new Program before compiling to get the latest source file contents, + // otherwise when using webpack-dev-server the files will be outdated at this point + this._program = ts.createProgram( + this._rootFilePath, this._compilerOptions, this._compilerHost, this._program); + // Create the Code Generator. return __NGTOOLS_PRIVATE_API_2.codeGen({ basePath: this._basePath,