From 89395efde4bcb79b432f3ce56a6aa86881365e0a Mon Sep 17 00:00:00 2001 From: Ron Lavi <1ronlavi@gmail.com> Date: Sun, 24 Apr 2022 14:51:11 +0300 Subject: [PATCH] fix(stories): handle templateParameters as a promise got an error when trying to run storybook from Foreman: UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'createSnapshot' of undefined ISSUES: fixes #393 --- .../config/webpack/webpack.config.vendor.js | 34 ++++++++++++------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/packages/stories/src/config/webpack/webpack.config.vendor.js b/packages/stories/src/config/webpack/webpack.config.vendor.js index 1dd82a62..e5f67460 100644 --- a/packages/stories/src/config/webpack/webpack.config.vendor.js +++ b/packages/stories/src/config/webpack/webpack.config.vendor.js @@ -19,19 +19,27 @@ module.exports = ({ config, mode }) => { assets, assetTags, options - ) => ({ - compilation, - webpackConfig: compilation.options, - htmlWebpackPlugin: { - tags: assetTags, - files: { - ...assets, - js: [...vendorJsFiles, ...assets.js], - css: [...vendorCssFiles, ...assets.css], - }, - options, - }, - }); + ) => + Promise.resolve().then(() => { + try { + return { + compilation, + webpackConfig: compilation.options, + htmlWebpackPlugin: { + tags: assetTags, + files: { + ...assets, + js: [...vendorJsFiles, ...assets.js], + css: [...vendorCssFiles, ...assets.css], + }, + options, + }, + }; + } catch (e) { + compilation.errors.push(new Error(`Template execution failed: ${e}`)); + return Promise.reject(e); + } + }); config.plugins.push(new WebpackForemanVendorPlugin({ mode }));