From c3ad156453cbf30872a9fda0cb741026ba48887c Mon Sep 17 00:00:00 2001 From: Alexander <113525996+alex-fko@users.noreply.github.com> Date: Thu, 29 Sep 2022 18:05:14 +0300 Subject: [PATCH] #8586 Make eager option configurable for extensions shared libraries (#8587) (#8633) (cherry picked from commit 3c31f3c7e83aafda6c1c0996954e8bf5bcc0f5a6) Co-authored-by: Alexander --- build/createExtensionWebpackConfig.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/build/createExtensionWebpackConfig.js b/build/createExtensionWebpackConfig.js index a259d5ca2c..fbab8b2231 100644 --- a/build/createExtensionWebpackConfig.js +++ b/build/createExtensionWebpackConfig.js @@ -11,13 +11,14 @@ const MiniCssExtractPlugin = require("mini-css-extract-plugin"); * @param {boolean} cfg.prod discriminates the production or development environment * @param {string} cfg.name the name of the plugin/extension * @param {object} cfg.exposes this is the main entry point of the module federation plugin. For MapStore extension plugin it must be { './plugin': "path/to/the/plugin/file>"} + * @param {boolean} cfg.sharedLibrariesEager this flag controls whether shared libraries should be included into index.js of extensions or loaded asynchronously * @param {object} cfg.alias aliases for the JS build * @param {object} cfg.publicPath the publicPath, useful for debugging * @param {string} cfg.destination the destination folder of the build packages * @param {array} cfg.plugins additional plugins, more then the default ones. * @param {object} cfg.overrides any other configuration you want to add to the configuration. */ -module.exports = ({ prod = true, name, exposes, alias = {}, publicPath, destination, plugins = [], overrides = {} }) => ({ +module.exports = ({ prod = true, name, exposes, sharedLibrariesEager = true, alias = {}, publicPath, destination, plugins = [], overrides = {} }) => ({ target: "web", mode: prod ? "production" : "development", entry: {}, @@ -44,7 +45,10 @@ module.exports = ({ prod = true, name, exposes, alias = {}, publicPath, destinat name, filename: "index.js", // "bundle.[chunkhash:8].js", // [chunkhash:8] exposes, - shared + shared: Object.keys(shared).reduce((prev, el) => { + prev[el] = {...shared[el], eager: sharedLibrariesEager}; + return prev; + }, {}) }), new MiniCssExtractPlugin({ filename: "assets/css/[name].css"