cli: remove FORCE_REACT_DEVELOPMENT

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2025-05-31 16:46:50 +02:00
parent 477b4e5542
commit 2b9633f176
2 changed files with 6 additions and 43 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/cli': patch
---
The experimental `FORCE_REACT_DEVELOPMENT` flag has been removed.
@@ -15,8 +15,7 @@
*/
import { BundlingOptions, ModuleFederationOptions } from './types';
import { resolve as resolvePath, dirname } from 'path';
import chalk from 'chalk';
import { resolve as resolvePath } from 'path';
import webpack from 'webpack';
import { BundlingPaths } from './paths';
@@ -346,47 +345,6 @@ export async function createConfig(
const mode = isDev ? 'development' : 'production';
const optimization = optimizationConfig(options);
if (
mode === 'production' &&
process.env.EXPERIMENTAL_MODULE_FEDERATION &&
process.env.FORCE_REACT_DEVELOPMENT
) {
console.log(
chalk.yellow(
`⚠️ WARNING: Forcing react and react-dom into development mode. This build should not be used in production.`,
),
);
const reactPackageDirs = [
`${dirname(require.resolve('react/package.json'))}/`,
`${dirname(require.resolve('react-dom/package.json'))}/`,
];
// Don't define process.env.NODE_ENV with value matching config.mode. If we
// don't set this to false, webpack will define the value of
// process.env.NODE_ENV for us, and the definition below will be ignored.
optimization.nodeEnv = false;
// Instead, provide a custom definition which always uses "development" if
// the module is part of `react` or `react-dom`, and `config.mode` otherwise.
plugins.push(
new bundler.DefinePlugin({
'process.env.NODE_ENV': rspack
? // FIXME: see also https://github.com/web-infra-dev/rspack/issues/5606
JSON.stringify(mode)
: webpack.DefinePlugin.runtimeValue(({ module }) => {
if (
reactPackageDirs.some(val => module.resource.startsWith(val))
) {
return '"development"';
}
return `"${mode}"`;
}),
}),
);
}
return {
mode,
profile: false,