From 9604c76380d211908a07c228f0de80b10608f489 Mon Sep 17 00:00:00 2001 From: Ryan Clark Date: Sat, 14 Jan 2017 02:03:47 +0000 Subject: [PATCH] fix(@ngtools/webpack): fix compilation not working properly with webpack-dev-server Fix files not compiling first time when using @ngtools/webpack with webpack-dev-server, either the server would need to be restarted or another rebuild triggered before updates would show. Fixes #3084 --- packages/@ngtools/webpack/src/plugin.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/@ngtools/webpack/src/plugin.ts b/packages/@ngtools/webpack/src/plugin.ts index 939efd0e4017..ea23d5882109 100644 --- a/packages/@ngtools/webpack/src/plugin.ts +++ b/packages/@ngtools/webpack/src/plugin.ts @@ -260,6 +260,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,