Files
Jack Hsu 820a3a6aaa fix(react): make module federation packages optional peer dependencies (#36492)
## Current Behavior

Installing `@nx/react` pulls `@nx/module-federation`, `express`,
`http-proxy-middleware`, `@svgr/webpack` and `@nx/rollup` as direct
dependencies. Installing `@nx/next` pulls `@nx/webpack` and
`@svgr/webpack`. Workspaces on esbuild, Vite or Rspack never run any of
it. `@nx/module-federation` also pins `webpack` exactly while
`@nx/webpack` installs a floating range, so workspaces end up with two
webpack copies and Module Federation builds fail.

## Expected Behavior

Module Federation packages become optional peers loaded lazily behind an
`assertPackageIsInstalled` guard; `@svgr/webpack` is removed outright
(SVGR support was removed in v23 and the v22 migrations inlined it to
userland); `@nx/module-federation` declares `webpack` as an optional
peer so it shares the app's copy. `23.2.0` migrations backfill the
Module Federation packages for workspaces that need them, and
`@svgr/webpack` for workspaces whose webpack or next configs reference
it (the v22 migrations inlined the `require.resolve` without declaring
the package). Same shape as #36310 for `@nx/angular`.

## Related Issue(s)

NXC-4688
2026-07-30 12:22:19 -04:00

233 lines
6.5 KiB
JSON

{
"name": "@nx/react",
"version": "0.0.1",
"private": false,
"description": "The React plugin for Nx contains executors and generators for managing React applications and libraries within an Nx workspace. It provides:\n\n\n- Integration with libraries such as Jest, Vitest, Playwright, Cypress, and Storybook.\n\n- Generators for applications, libraries, components, hooks, and more.\n\n- Library build support for publishing packages to npm or other registries.\n\n- Utilities for automatic workspace refactoring.",
"repository": {
"type": "git",
"url": "https://github.com/nrwl/nx.git",
"directory": "packages/react"
},
"keywords": [
"Monorepo",
"React",
"Web",
"Jest",
"Cypress",
"CLI",
"Front-end"
],
"main": "./dist/index.js",
"type": "commonjs",
"types": "./dist/index.d.ts",
"files": [
"dist",
"!dist/tsconfig.tsbuildinfo",
"typings",
"migrations.json",
"executors.json",
"generators.json"
],
"typesVersions": {
"*": {
"mf": [
"dist/mf/index.d.ts"
],
"babel": [
"dist/babel.d.ts"
],
"tailwind": [
"dist/tailwind.d.ts"
],
"module-federation": [
"dist/module-federation.d.ts"
],
"webpack-plugin": [
"dist/webpack-plugin.d.ts"
],
"router-plugin": [
"dist/router-plugin.d.ts"
],
"ast-utils": [
"dist/ast-utils.d.ts"
],
"plugins/storybook": [
"dist/plugins/storybook/index.d.ts"
],
"plugins/component-testing": [
"dist/plugins/component-testing/index.d.ts"
],
"plugins/webpack": [
"dist/plugins/webpack.d.ts"
],
"plugins/bundle-rollup": [
"dist/plugins/bundle-rollup.d.ts"
],
"plugins/jest": [
"dist/plugins/jest.d.ts"
],
"plugins/with-react": [
"dist/plugins/with-react.d.ts"
],
"typings/*.d.ts": [
"dist/typings/*.d.ts"
],
"internal": [
"dist/internal.d.ts"
]
}
},
"author": "Victor Savkin",
"license": "MIT",
"bugs": {
"url": "https://github.com/nrwl/nx/issues"
},
"homepage": "https://nx.dev",
"executors": "./executors.json",
"generators": "./generators.json",
"ng-update": {
"requirements": {},
"migrations": "./migrations.json",
"supportsOptionalMigrations": true
},
"peerDependencies": {
"babel-plugin-react-compiler": "^1.0.0",
"react": ">=18.0.0 <20.0.0",
"react-dom": ">=18.0.0 <20.0.0",
"@nx/module-federation": "workspace:*",
"express": "^4.21.2",
"http-proxy-middleware": "catalog:"
},
"peerDependenciesMeta": {
"babel-plugin-react-compiler": {
"optional": true
},
"@nx/module-federation": {
"optional": true
},
"express": {
"optional": true
},
"http-proxy-middleware": {
"optional": true
}
},
"dependencies": {
"@babel/preset-react": "^7.22.5",
"@phenomnomnominal/tsquery": "catalog:typescript",
"minimatch": "catalog:",
"tslib": "catalog:typescript",
"@nx/devkit": "workspace:*",
"@nx/js": "workspace:*",
"@nx/eslint": "workspace:*",
"@nx/web": "workspace:*",
"semver": "catalog:"
},
"devDependencies": {
"@nx/cypress": "workspace:*",
"@nx/module-federation": "workspace:*",
"@nx/playwright": "workspace:*",
"@nx/rollup": "workspace:*",
"@nx/rsbuild": "workspace:*",
"@nx/vite": "workspace:*",
"@nx/vitest": "workspace:*",
"@nx/webpack": "workspace:*",
"@nx/storybook": "workspace:*",
"express": "^4.21.2",
"http-proxy-middleware": "catalog:",
"nx": "workspace:*"
},
"optionalDependencies": {
"@nx/vite": "workspace:*"
},
"publishConfig": {
"access": "public"
},
"exports": {
".": {
"@nx/nx-source": "./index.ts",
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
},
"./package.json": "./package.json",
"./migrations.json": "./migrations.json",
"./generators.json": "./generators.json",
"./executors.json": "./executors.json",
"./mf": {
"@nx/nx-source": "./mf/index.ts",
"types": "./dist/mf/index.d.ts",
"default": "./dist/mf/index.js"
},
"./babel": {
"@nx/nx-source": "./babel.ts",
"types": "./dist/babel.d.ts",
"default": "./dist/babel.js"
},
"./tailwind": {
"@nx/nx-source": "./tailwind.ts",
"types": "./dist/tailwind.d.ts",
"default": "./dist/tailwind.js"
},
"./module-federation": {
"@nx/nx-source": "./module-federation.ts",
"types": "./dist/module-federation.d.ts",
"default": "./dist/module-federation.js"
},
"./webpack-plugin": {
"@nx/nx-source": "./webpack-plugin.ts",
"types": "./dist/webpack-plugin.d.ts",
"default": "./dist/webpack-plugin.js"
},
"./router-plugin": {
"@nx/nx-source": "./router-plugin.ts",
"types": "./dist/router-plugin.d.ts",
"default": "./dist/router-plugin.js"
},
"./ast-utils": {
"@nx/nx-source": "./ast-utils.ts",
"types": "./dist/ast-utils.d.ts",
"default": "./dist/ast-utils.js"
},
"./plugins/storybook": {
"@nx/nx-source": "./plugins/storybook/index.ts",
"types": "./dist/plugins/storybook/index.d.ts",
"default": "./dist/plugins/storybook/index.js"
},
"./plugins/component-testing": {
"@nx/nx-source": "./plugins/component-testing/index.ts",
"types": "./dist/plugins/component-testing/index.d.ts",
"default": "./dist/plugins/component-testing/index.js"
},
"./plugins/webpack": {
"@nx/nx-source": "./plugins/webpack.ts",
"types": "./dist/plugins/webpack.d.ts",
"default": "./dist/plugins/webpack.js"
},
"./plugins/bundle-rollup": {
"@nx/nx-source": "./plugins/bundle-rollup.ts",
"types": "./dist/plugins/bundle-rollup.d.ts",
"default": "./dist/plugins/bundle-rollup.js"
},
"./plugins/jest": {
"@nx/nx-source": "./plugins/jest.ts",
"types": "./dist/plugins/jest.d.ts",
"default": "./dist/plugins/jest.js"
},
"./plugins/with-react": {
"@nx/nx-source": "./plugins/with-react.ts",
"types": "./dist/plugins/with-react.d.ts",
"default": "./dist/plugins/with-react.js"
},
"./typings/*.d.ts": {
"@nx/nx-source": "./typings/*.d.ts",
"types": "./dist/typings/*.d.ts",
"default": "./dist/typings/*.d.ts"
},
"./internal": {
"@nx/nx-source": "./internal.ts",
"types": "./dist/internal.d.ts",
"default": "./dist/internal.js"
}
}
}