Known issue: Self-hosted Flex 2.7.0 and later requires specific react-scripts version
If you use self-hosted Flex and your custom application uses react-scripts v5, you must apply a workaround to use Flex UI 2.7.0 or later due to a react-scripts issue. Without the workaround, Flex will fail to initialize.
This happens because react-scripts v5 includes a known issue that prevents CommonJS modules from loading correctly and defines them incorrectly in the final bundle. Because this react-scripts issue remains unresolved, use the following workaround to upgrade your Flex version.
You must modify the webpack configuration that is included with react-scripts v5 as shown in the example below. We recommend using craco, but you can also use other packages that allow you to tweak the react-scripts configuration, such as react-app-rewired.
This example shows craco.config.js extends the react-scripts webpack configuration:
1module.exports = {2webpack: {3configure: (config) => {4// ...5const fileLoaderRule = getFileLoaderRule(config.module.rules);6if(!fileLoaderRule) {7throw new Error("File loader not found");8}9fileLoaderRule.exclude.push(/\.cjs$/);10// ...11return config;12}13}14};1516function getFileLoaderRule(rules) {17for(const rule of rules) {18if("oneOf" in rule) {19const found = getFileLoaderRule(rule.oneOf);20if(found) {21return found;22}23} else if(rule.test === undefined && rule.type === 'asset/resource') {24return rule;25}26}27}