From 393e156b4798803c6d6ebfc82a82e79465b86458 Mon Sep 17 00:00:00 2001 From: SteveSandersonMS Date: Fri, 1 Jul 2016 10:30:59 +0100 Subject: [PATCH] Better reporting of Webpack compilation errors to fix #159 --- .../npm/aspnet-webpack/package.json | 2 +- .../npm/aspnet-webpack/src/LoadViaWebpack.ts | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.AspNetCore.SpaServices/npm/aspnet-webpack/package.json b/src/Microsoft.AspNetCore.SpaServices/npm/aspnet-webpack/package.json index bfcf501..db18530 100644 --- a/src/Microsoft.AspNetCore.SpaServices/npm/aspnet-webpack/package.json +++ b/src/Microsoft.AspNetCore.SpaServices/npm/aspnet-webpack/package.json @@ -1,6 +1,6 @@ { "name": "aspnet-webpack", - "version": "1.0.4", + "version": "1.0.5", "description": "Helpers for using Webpack in ASP.NET Core projects. Works in conjunction with the Microsoft.AspNetCore.SpaServices NuGet package.", "main": "index.js", "scripts": { diff --git a/src/Microsoft.AspNetCore.SpaServices/npm/aspnet-webpack/src/LoadViaWebpack.ts b/src/Microsoft.AspNetCore.SpaServices/npm/aspnet-webpack/src/LoadViaWebpack.ts index 93b4b4c..38cb948 100644 --- a/src/Microsoft.AspNetCore.SpaServices/npm/aspnet-webpack/src/LoadViaWebpack.ts +++ b/src/Microsoft.AspNetCore.SpaServices/npm/aspnet-webpack/src/LoadViaWebpack.ts @@ -80,6 +80,11 @@ function loadViaWebpackNoCache(webpackConfigPath: string, modulePath: string) } else { // We're in a callback, so need an explicit try/catch to propagate any errors up the promise chain try { + if (stats.hasErrors()) { + throw new Error('Webpack compilation reported errors. Compiler output follows: ' + + stats.toString({ chunks: false })); + } + const fileContent = compiler.outputFileSystem.readFileSync('/webpack-output.js', 'utf8'); const moduleInstance = requireFromString(fileContent); resolve(moduleInstance);