Skip to content
This repository was archived by the owner on Apr 8, 2020. It is now read-only.

Commit b82e70e

Browse files
Fix for prerendering hanging if webpack compilation fails
1 parent 44bd5f1 commit b82e70e

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/Microsoft.AspNetCore.SpaServices/npm/aspnet-webpack/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "aspnet-webpack",
3-
"version": "1.0.3",
3+
"version": "1.0.4",
44
"description": "Helpers for using Webpack in ASP.NET Core projects. Works in conjunction with the Microsoft.AspNetCore.SpaServices NuGet package.",
55
"main": "index.js",
66
"scripts": {

src/Microsoft.AspNetCore.SpaServices/npm/aspnet-webpack/src/LoadViaWebpack.ts

+9-4
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ function loadViaWebpackNoCache<T>(webpackConfigPath: string, modulePath: string)
5252
webpackConfig.plugins = webpackConfig.plugins.filter(plugin => {
5353
return !(plugin instanceof webpack.optimize.CommonsChunkPlugin);
5454
});
55-
55+
5656
// The typical use case for DllReferencePlugin is for referencing vendor modules. In a Node
5757
// environment, it doesn't make sense to load them from a DLL bundle, nor would that even
5858
// work, because then you'd get different module instances depending on whether a module
@@ -78,9 +78,14 @@ function loadViaWebpackNoCache<T>(webpackConfigPath: string, modulePath: string)
7878
if (err) {
7979
reject(err);
8080
} else {
81-
const fileContent = compiler.outputFileSystem.readFileSync('/webpack-output.js', 'utf8');
82-
const moduleInstance = requireFromString<T>(fileContent);
83-
resolve(moduleInstance);
81+
// We're in a callback, so need an explicit try/catch to propagate any errors up the promise chain
82+
try {
83+
const fileContent = compiler.outputFileSystem.readFileSync('/webpack-output.js', 'utf8');
84+
const moduleInstance = requireFromString<T>(fileContent);
85+
resolve(moduleInstance);
86+
} catch(ex) {
87+
reject(ex);
88+
}
8489
}
8590
});
8691
});

0 commit comments

Comments
 (0)