mirror of
https://github.com/aspnet/JavaScriptServices.git
synced 2025-12-23 10:08:57 +00:00
Fix for prerendering hanging if webpack compilation fails
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "aspnet-webpack",
|
"name": "aspnet-webpack",
|
||||||
"version": "1.0.3",
|
"version": "1.0.4",
|
||||||
"description": "Helpers for using Webpack in ASP.NET Core projects. Works in conjunction with the Microsoft.AspNetCore.SpaServices NuGet package.",
|
"description": "Helpers for using Webpack in ASP.NET Core projects. Works in conjunction with the Microsoft.AspNetCore.SpaServices NuGet package.",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ function loadViaWebpackNoCache<T>(webpackConfigPath: string, modulePath: string)
|
|||||||
webpackConfig.plugins = webpackConfig.plugins.filter(plugin => {
|
webpackConfig.plugins = webpackConfig.plugins.filter(plugin => {
|
||||||
return !(plugin instanceof webpack.optimize.CommonsChunkPlugin);
|
return !(plugin instanceof webpack.optimize.CommonsChunkPlugin);
|
||||||
});
|
});
|
||||||
|
|
||||||
// The typical use case for DllReferencePlugin is for referencing vendor modules. In a Node
|
// The typical use case for DllReferencePlugin is for referencing vendor modules. In a Node
|
||||||
// environment, it doesn't make sense to load them from a DLL bundle, nor would that even
|
// environment, it doesn't make sense to load them from a DLL bundle, nor would that even
|
||||||
// work, because then you'd get different module instances depending on whether a module
|
// 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)
|
|||||||
if (err) {
|
if (err) {
|
||||||
reject(err);
|
reject(err);
|
||||||
} else {
|
} else {
|
||||||
const fileContent = compiler.outputFileSystem.readFileSync('/webpack-output.js', 'utf8');
|
// We're in a callback, so need an explicit try/catch to propagate any errors up the promise chain
|
||||||
const moduleInstance = requireFromString<T>(fileContent);
|
try {
|
||||||
resolve(moduleInstance);
|
const fileContent = compiler.outputFileSystem.readFileSync('/webpack-output.js', 'utf8');
|
||||||
|
const moduleInstance = requireFromString<T>(fileContent);
|
||||||
|
resolve(moduleInstance);
|
||||||
|
} catch(ex) {
|
||||||
|
reject(ex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user