From 675bc16c1bc25cc7b40140843dc1d851f09b0c7c Mon Sep 17 00:00:00 2001 From: MariaAga Date: Mon, 14 Jul 2025 10:54:03 +0100 Subject: [PATCH] Fixes #38570 - adding scalprum to shared webpack --- config/webpack.config.js | 44 +++++++++++++++++++++++++++++++--------- config/webpack.vendor.js | 12 ++++++++++- package.json | 4 ++++ 3 files changed, 49 insertions(+), 11 deletions(-) diff --git a/config/webpack.config.js b/config/webpack.config.js index 5c16d1799a..ad94abedf0 100644 --- a/config/webpack.config.js +++ b/config/webpack.config.js @@ -22,8 +22,8 @@ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8')); const dependencies = packageJson.dependencies || {}; const devDependencies = packageJson.devDependencies || {}; const allDependencies = { ...dependencies, ...devDependencies }; -const shared = isPlugin => - Object.keys(allDependencies).map(dep => ({ +const shared = isPlugin => { + const sharedArr = Object.keys(allDependencies).map(dep => ({ [dep]: { eager: !isPlugin, // core should load all dependencies eagerly so they will be available for plugins singleton: true, @@ -31,6 +31,33 @@ const shared = isPlugin => import: isPlugin ? false : dep, }, })); + return [ + ...sharedArr, + { + /* + have to use '@scalprum/core/index' in vendor.js entry otherwise we get + Uncaught ReferenceError: __webpack_exports__ is not defined + but without need to "convert" @scalprum/core/index to @scalprum/core + so the shared context can find it + */ + '@scalprum/react-core': { + eager: !isPlugin, + singleton: true, + import: isPlugin ? false : '@scalprum/react-core/index', + packageName: '@scalprum/react-core', + }, + }, + { + '@scalprum/core': { + eager: !isPlugin, + singleton: true, + import: isPlugin ? false : '@scalprum/core/index', + import: '@scalprum/core/index', + packageName: '@scalprum/core', + }, + }, + ]; +}; class AddRuntimeRequirement { // to avoid "webpackRequire.l is not a function" error @@ -97,19 +124,17 @@ const commonConfig = function() { }, alias: { 'patternfly-react$': path.resolve( - __dirname, - '..', + root, 'node_modules/patternfly-react/dist/js/index.js' ), // to avoid circular dependency in dist/esm '/node_modules/jquery': path.resolve( - __dirname, - '..', + root, 'webpack/assets/javascripts/jquery.js' ), jquery: path.resolve(root, 'webpack/assets/javascripts/jquery.js'), foremanReact: path.join( - __dirname, - '../webpack/assets/javascripts/react_app' + root, + '/webpack/assets/javascripts/react_app' ), 'react/jsx-runtime': 'react/jsx-runtime.js', // for react-dnd 'react/jsx-dev-runtime': 'react/jsx-dev-runtime.js', // for react-dnd @@ -291,8 +316,7 @@ const pluginConfig = function(plugin) { var chunkFilename = '[name]-[chunkhash].js'; } else { var outputPath = path.join( - __dirname, - '..', + root, 'public', 'webpack', pluginName diff --git a/config/webpack.vendor.js b/config/webpack.vendor.js index 001cfce756..e3e55def82 100644 --- a/config/webpack.vendor.js +++ b/config/webpack.vendor.js @@ -94,7 +94,17 @@ module.exports = [ 'select2', 'multiselect', '@novnc/novnc/core/rfb', - + 'sanitize-html', + + /* + * for rh_cloud + * /index is a workaround until we find a better way + */ + 'unleash-proxy-client', + '@unleash/proxy-client-react', + '@scalprum/core/index', + '@scalprum/react-core/index', + // '@webcomponents/webcomponentsjs/webcomponents-bundle', // '@webcomponents/webcomponentsjs/custom-elements-es5-adapter', ]; diff --git a/package.json b/package.json index 1d78303225..ced6eadc2e 100644 --- a/package.json +++ b/package.json @@ -34,8 +34,11 @@ "@patternfly/react-table": "^5.2.0", "@patternfly/react-tokens": "^5.2.0", "@reduxjs/toolkit": "^1.6.0", + "@scalprum/core": "^0.8.1", + "@scalprum/react-core": "^0.9.3", "@spice-project/spice-html5": "^0.2.1", "@theforeman/vendor": "^15.0.0", + "@unleash/proxy-client-react": "^5.0.0", "@webcomponents/webcomponentsjs": "^2.2.10", "ace-builds": "^1.4.13", "axios": "^0.21.1", @@ -97,6 +100,7 @@ "seamless-immutable": "^7.1.2", "select2": "4.0.12", "unidiff": "^1.0.0", + "unleash-proxy-client": "^3.7.6", "urijs": "^1.19.4", "uuid": "^3.3.2", "yup": "^0.29.3"