Better reporting of Webpack compilation errors to fix #159

This commit is contained in:
SteveSandersonMS
2016-07-01 10:30:59 +01:00
parent b82e70e192
commit 393e156b47
2 changed files with 6 additions and 1 deletions

View File

@@ -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": {

View File

@@ -80,6 +80,11 @@ function loadViaWebpackNoCache<T>(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<T>(fileContent);
resolve(moduleInstance);