@nx/react
Version:
34 lines (33 loc) • 1.86 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.REACT_WITH_REACT_DEPRECATION_MESSAGE = void 0;
exports.suppressReactComposeHelperWarnings = suppressReactComposeHelperWarnings;
exports.warnReactWithReactDeprecation = warnReactWithReactDeprecation;
const devkit_1 = require("@nx/devkit");
// TODO(v24): Remove the webpack `withReact` config helper. It emits an
// Nx-specific webpack config function that only runs under the
// @nx/webpack:webpack executor; the inferred @nx/webpack/plugin works with
// standard webpack configs built around NxReactWebpackPlugin instead.
exports.REACT_WITH_REACT_DEPRECATION_MESSAGE = 'The `withReact` config helper from `@nx/react` is deprecated and will be removed in Nx v24. It produces an Nx-specific webpack config function that only runs under the `@nx/webpack:webpack` executor. Migrate to a standard webpack config that uses `NxReactWebpackPlugin` (from `@nx/react/webpack-plugin`) under the inferred `@nx/webpack/plugin` by running `nx g @nx/webpack:convert-to-inferred`. See https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.';
let withReactWarned = false;
let suppressDepth = 0;
// Nx-internal entry points compose `withReact` themselves (e.g. the storybook
// and component-testing presets). They wrap their synchronous composition in
// this so the warning fires only for user-authored configs.
function suppressReactComposeHelperWarnings(fn) {
suppressDepth++;
try {
return fn();
}
finally {
suppressDepth--;
}
}
// Warn once per process so HMR reloads and repeated config evaluation don't
// repeat the message.
function warnReactWithReactDeprecation() {
if (suppressDepth > 0 || withReactWarned)
return;
withReactWarned = true;
devkit_1.logger.warn(exports.REACT_WITH_REACT_DEPRECATION_MESSAGE);
}