@nx/react 0.0.0-pr-22179-271588f → 0.0.0-pr-26515-856ef7f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +1 -1
- package/index.d.ts +3 -1
- package/index.js +5 -3
- package/migrations.json +57 -160
- package/package.json +11 -9
- package/plugins/bundle-rollup.js +1 -1
- package/plugins/component-testing/index.js +5 -2
- package/plugins/component-testing/webpack-fallback.js +1 -1
- package/plugins/nx-react-webpack-plugin/lib/apply-react-config.d.ts +2 -1
- package/plugins/nx-react-webpack-plugin/lib/apply-react-config.js +33 -5
- package/plugins/storybook/index.js +1 -1
- package/plugins/with-react.d.ts +6 -1
- package/src/executors/module-federation-dev-server/module-federation-dev-server.impl.d.ts +5 -1
- package/src/executors/module-federation-dev-server/module-federation-dev-server.impl.js +58 -28
- package/src/executors/module-federation-dev-server/schema.json +25 -3
- package/src/generators/application/application.js +17 -4
- package/src/generators/application/files/base-webpack/webpack.config.js__tmpl__ +3 -3
- package/src/generators/application/lib/add-e2e.js +7 -6
- package/src/generators/application/lib/normalize-options.js +31 -4
- package/src/generators/application/schema.d.ts +3 -0
- package/src/generators/application/schema.json +2 -2
- package/src/generators/component/files/__fileName__.tsx__tmpl__ +3 -7
- package/src/generators/component/schema.d.ts +1 -1
- package/src/generators/component/schema.json +1 -1
- package/src/generators/hook/schema.d.ts +1 -1
- package/src/generators/hook/schema.json +2 -2
- package/src/generators/host/host.js +11 -0
- package/src/generators/host/schema.json +2 -2
- package/src/generators/library/lib/add-rollup-build-target.js +65 -28
- package/src/generators/redux/schema.d.ts +1 -1
- package/src/generators/redux/schema.json +1 -1
- package/src/generators/remote/lib/update-host-with-remote.js +1 -10
- package/src/generators/remote/remote.js +9 -0
- package/src/generators/remote/schema.json +2 -2
- package/src/generators/setup-tailwind/lib/add-tailwind-style-imports.js +7 -15
- package/src/generators/storybook-configuration/schema.json +3 -3
- package/src/migrations/{update-15-6-3/webpack-config-setup.d.ts → update-18-1-1/fix-target-defaults-inputs.d.ts} +1 -1
- package/src/migrations/update-18-1-1/fix-target-defaults-inputs.js +53 -0
- package/src/module-federation/with-module-federation.js +5 -0
- package/src/utils/add-mf-env-to-inputs.js +4 -1
- package/src/utils/ct-utils.js +1 -1
- package/src/utils/versions.d.ts +11 -11
- package/src/utils/versions.js +11 -11
- package/webpack-plugin.d.ts +1 -0
- package/webpack-plugin.js +5 -0
- package/src/migrations/update-15-3-0/install-webpack-rollup-dependencies.d.ts +0 -3
- package/src/migrations/update-15-3-0/install-webpack-rollup-dependencies.js +0 -37
- package/src/migrations/update-15-3-0/update-rollup-executor.d.ts +0 -3
- package/src/migrations/update-15-3-0/update-rollup-executor.js +0 -15
- package/src/migrations/update-15-6-3/webpack-config-setup.js +0 -103
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
|
|
25
25
|
Nx is a build system with built-in tooling and advanced CI capabilities. It helps you maintain and scale monorepos, both locally and on CI.
|
|
26
26
|
|
|
27
|
-
This package is a [React plugin for Nx](https://nx.dev/
|
|
27
|
+
This package is a [React plugin for Nx](https://nx.dev/nx-api/react).
|
|
28
28
|
|
|
29
29
|
## Getting Started
|
|
30
30
|
|
package/index.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { NxReactWebpackPlugin as _NxReactWebpackPlugin } from './plugins/nx-react-webpack-plugin/nx-react-webpack-plugin';
|
|
2
|
+
/** @deprecated Use '@nx/react/webpack-plugin' instead. */
|
|
3
|
+
export declare const NxReactWebpackPlugin: typeof _NxReactWebpackPlugin;
|
|
1
4
|
export { extraEslintDependencies, extendReactEslintJson, } from './src/utils/lint';
|
|
2
5
|
export { cssInJsDependenciesBabel } from './src/utils/styled';
|
|
3
6
|
export { assertValidStyle } from './src/utils/assertion';
|
|
@@ -19,4 +22,3 @@ export { componentTestGenerator } from './src/generators/component-test/componen
|
|
|
19
22
|
export { setupTailwindGenerator } from './src/generators/setup-tailwind/setup-tailwind';
|
|
20
23
|
export type { SupportedStyles } from './typings/style';
|
|
21
24
|
export * from './plugins/with-react';
|
|
22
|
-
export { NxReactWebpackPlugin } from './plugins/nx-react-webpack-plugin/nx-react-webpack-plugin';
|
package/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.setupTailwindGenerator = exports.componentTestGenerator = exports.cypressComponentConfigGenerator = exports.remoteGenerator = exports.hostGenerator = exports.storybookConfigurationGenerator = exports.storiesGenerator = exports.reduxGenerator = exports.reactInitGenerator = exports.libraryGenerator = exports.componentStoryGenerator = exports.componentCypressGenerator = exports.hookGenerator = exports.componentGenerator = exports.applicationGenerator = exports.reactVersion = exports.reactDomVersion = exports.assertValidStyle = exports.cssInJsDependenciesBabel = exports.extendReactEslintJson = exports.extraEslintDependencies = exports.NxReactWebpackPlugin = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
+
const nx_react_webpack_plugin_1 = require("./plugins/nx-react-webpack-plugin/nx-react-webpack-plugin");
|
|
6
|
+
// TODO(v20): Remove this in favor of deep imports in order to load configs faster (150-200ms faster).
|
|
7
|
+
/** @deprecated Use '@nx/react/webpack-plugin' instead. */
|
|
8
|
+
exports.NxReactWebpackPlugin = nx_react_webpack_plugin_1.NxReactWebpackPlugin;
|
|
5
9
|
var lint_1 = require("./src/utils/lint");
|
|
6
10
|
Object.defineProperty(exports, "extraEslintDependencies", { enumerable: true, get: function () { return lint_1.extraEslintDependencies; } });
|
|
7
11
|
Object.defineProperty(exports, "extendReactEslintJson", { enumerable: true, get: function () { return lint_1.extendReactEslintJson; } });
|
|
@@ -43,5 +47,3 @@ Object.defineProperty(exports, "componentTestGenerator", { enumerable: true, get
|
|
|
43
47
|
var setup_tailwind_1 = require("./src/generators/setup-tailwind/setup-tailwind");
|
|
44
48
|
Object.defineProperty(exports, "setupTailwindGenerator", { enumerable: true, get: function () { return setup_tailwind_1.setupTailwindGenerator; } });
|
|
45
49
|
tslib_1.__exportStar(require("./plugins/with-react"), exports);
|
|
46
|
-
var nx_react_webpack_plugin_1 = require("./plugins/nx-react-webpack-plugin/nx-react-webpack-plugin");
|
|
47
|
-
Object.defineProperty(exports, "NxReactWebpackPlugin", { enumerable: true, get: function () { return nx_react_webpack_plugin_1.NxReactWebpackPlugin; } });
|
package/migrations.json
CHANGED
|
@@ -1,23 +1,5 @@
|
|
|
1
1
|
{
|
|
2
2
|
"generators": {
|
|
3
|
-
"update-rollup-executor": {
|
|
4
|
-
"cli": "nx",
|
|
5
|
-
"version": "15.3.0-beta.0",
|
|
6
|
-
"description": "Update projects using @nrwl/web:rollup to @nrwl/rollup:rollup for build.",
|
|
7
|
-
"factory": "./src/migrations/update-15-3-0/update-rollup-executor"
|
|
8
|
-
},
|
|
9
|
-
"install-webpack-rollup-dependencies": {
|
|
10
|
-
"cli": "nx",
|
|
11
|
-
"version": "15.3.0-beta.0",
|
|
12
|
-
"description": "Install new dependencies for React projects using Webpack or Rollup.",
|
|
13
|
-
"factory": "./src/migrations/update-15-3-0/install-webpack-rollup-dependencies"
|
|
14
|
-
},
|
|
15
|
-
"react-webpack-config-setup": {
|
|
16
|
-
"cli": "nx",
|
|
17
|
-
"version": "15.6.3-beta.0",
|
|
18
|
-
"description": "Creates or updates webpack.config.js file with the new options for webpack.",
|
|
19
|
-
"factory": "./src/migrations/update-15-6-3/webpack-config-setup"
|
|
20
|
-
},
|
|
21
3
|
"update-16-0-0-add-nx-packages": {
|
|
22
4
|
"cli": "nx",
|
|
23
5
|
"version": "16.0.0-beta.1",
|
|
@@ -53,151 +35,15 @@
|
|
|
53
35
|
"version": "18.0.0-beta.0",
|
|
54
36
|
"description": "Add NX_MF_DEV_SERVER_STATIC_REMOTES to inputs for task hashing when '@nx/webpack:webpack' is used for Module Federation.",
|
|
55
37
|
"factory": "./src/migrations/update-18-0-0/add-mf-env-var-to-target-defaults"
|
|
38
|
+
},
|
|
39
|
+
"fix-target-defaults-for-webpack": {
|
|
40
|
+
"cli": "nx",
|
|
41
|
+
"version": "18.1.1-beta.0",
|
|
42
|
+
"description": "Ensure targetDefaults inputs for task hashing when '@nx/webpack:webpack' is used are correct for Module Federation.",
|
|
43
|
+
"factory": "./src/migrations/update-18-1-1/fix-target-defaults-inputs"
|
|
56
44
|
}
|
|
57
45
|
},
|
|
58
46
|
"packageJsonUpdates": {
|
|
59
|
-
"15.2.2-beta.0": {
|
|
60
|
-
"version": "15.2.2-beta.0",
|
|
61
|
-
"packages": {
|
|
62
|
-
"@types/react": {
|
|
63
|
-
"version": "18.0.25",
|
|
64
|
-
"alwaysAddToPackageJson": false
|
|
65
|
-
},
|
|
66
|
-
"@types/react-dom": {
|
|
67
|
-
"version": "18.0.9",
|
|
68
|
-
"alwaysAddToPackageJson": false
|
|
69
|
-
},
|
|
70
|
-
"@types/node": {
|
|
71
|
-
"version": "18.11.9",
|
|
72
|
-
"alwaysAddToPackageJson": false
|
|
73
|
-
},
|
|
74
|
-
"styled-components": {
|
|
75
|
-
"version": "5.3.6",
|
|
76
|
-
"alwaysAddToPackageJson": false
|
|
77
|
-
},
|
|
78
|
-
"@emotion/styled": {
|
|
79
|
-
"version": "11.10.5",
|
|
80
|
-
"alwaysAddToPackageJson": false
|
|
81
|
-
},
|
|
82
|
-
"@emotion/react": {
|
|
83
|
-
"version": "11.10.5",
|
|
84
|
-
"alwaysAddToPackageJson": false
|
|
85
|
-
},
|
|
86
|
-
"@emotion/babel-plugin": {
|
|
87
|
-
"version": "11.10.5",
|
|
88
|
-
"alwaysAddToPackageJson": false
|
|
89
|
-
},
|
|
90
|
-
"styled-jsx": {
|
|
91
|
-
"version": "5.1.0",
|
|
92
|
-
"alwaysAddToPackageJson": false
|
|
93
|
-
},
|
|
94
|
-
"react-router-dom": {
|
|
95
|
-
"version": "6.4.3",
|
|
96
|
-
"alwaysAddToPackageJson": false
|
|
97
|
-
},
|
|
98
|
-
"@reduxjs/toolkit": {
|
|
99
|
-
"version": "1.9.0",
|
|
100
|
-
"alwaysAddToPackageJson": false
|
|
101
|
-
},
|
|
102
|
-
"react-redux": {
|
|
103
|
-
"version": "8.0.5",
|
|
104
|
-
"alwaysAddToPackageJson": false
|
|
105
|
-
},
|
|
106
|
-
"eslint-plugin-react": {
|
|
107
|
-
"version": "7.31.11",
|
|
108
|
-
"alwaysAddToPackageJson": false
|
|
109
|
-
},
|
|
110
|
-
"postcss": {
|
|
111
|
-
"version": "8.4.19",
|
|
112
|
-
"alwaysAddToPackageJson": false
|
|
113
|
-
},
|
|
114
|
-
"tailwindcss": {
|
|
115
|
-
"version": "3.2.4",
|
|
116
|
-
"alwaysAddToPackageJson": false
|
|
117
|
-
},
|
|
118
|
-
"autoprefixer": {
|
|
119
|
-
"version": "10.4.13",
|
|
120
|
-
"alwaysAddToPackageJson": false
|
|
121
|
-
},
|
|
122
|
-
"@types/express": {
|
|
123
|
-
"version": "4.17.14",
|
|
124
|
-
"alwaysAddToPackageJson": false
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
},
|
|
128
|
-
"15.8.0": {
|
|
129
|
-
"version": "15.8.0-beta.0",
|
|
130
|
-
"packages": {
|
|
131
|
-
"@types/react": {
|
|
132
|
-
"version": "18.0.28",
|
|
133
|
-
"alwaysAddToPackageJson": false
|
|
134
|
-
},
|
|
135
|
-
"@types/react-dom": {
|
|
136
|
-
"version": "18.0.11",
|
|
137
|
-
"alwaysAddToPackageJson": false
|
|
138
|
-
},
|
|
139
|
-
"@types/node": {
|
|
140
|
-
"version": "18.14.2",
|
|
141
|
-
"alwaysAddToPackageJson": false
|
|
142
|
-
},
|
|
143
|
-
"@emotion/styled": {
|
|
144
|
-
"version": "11.10.6",
|
|
145
|
-
"alwaysAddToPackageJson": false
|
|
146
|
-
},
|
|
147
|
-
"@emotion/react": {
|
|
148
|
-
"version": "11.10.6",
|
|
149
|
-
"alwaysAddToPackageJson": false
|
|
150
|
-
},
|
|
151
|
-
"@emotion/babel-plugin": {
|
|
152
|
-
"version": "11.10.6",
|
|
153
|
-
"alwaysAddToPackageJson": false
|
|
154
|
-
},
|
|
155
|
-
"styled-jsx": {
|
|
156
|
-
"version": "5.1.2",
|
|
157
|
-
"alwaysAddToPackageJson": false
|
|
158
|
-
},
|
|
159
|
-
"react-router-dom": {
|
|
160
|
-
"version": "6.8.1",
|
|
161
|
-
"alwaysAddToPackageJson": false
|
|
162
|
-
},
|
|
163
|
-
"@testing-library/react": {
|
|
164
|
-
"version": "14.0.0",
|
|
165
|
-
"alwaysAddToPackageJson": false
|
|
166
|
-
},
|
|
167
|
-
"@reduxjs/toolkit": {
|
|
168
|
-
"version": "1.9.3",
|
|
169
|
-
"alwaysAddToPackageJson": false
|
|
170
|
-
},
|
|
171
|
-
"eslint-plugin-import": {
|
|
172
|
-
"version": "2.27.5",
|
|
173
|
-
"alwaysAddToPackageJson": false
|
|
174
|
-
},
|
|
175
|
-
"eslint-plugin-jsx-a11y": {
|
|
176
|
-
"version": "6.7.1",
|
|
177
|
-
"alwaysAddToPackageJson": false
|
|
178
|
-
},
|
|
179
|
-
"eslint-plugin-react": {
|
|
180
|
-
"version": "7.32.2",
|
|
181
|
-
"alwaysAddToPackageJson": false
|
|
182
|
-
},
|
|
183
|
-
"postcss": {
|
|
184
|
-
"version": "8.4.21",
|
|
185
|
-
"alwaysAddToPackageJson": false
|
|
186
|
-
},
|
|
187
|
-
"tailwindcss": {
|
|
188
|
-
"version": "3.2.7",
|
|
189
|
-
"alwaysAddToPackageJson": false
|
|
190
|
-
},
|
|
191
|
-
"@types/express": {
|
|
192
|
-
"version": "4.17.17",
|
|
193
|
-
"alwaysAddToPackageJson": false
|
|
194
|
-
},
|
|
195
|
-
"less": {
|
|
196
|
-
"version": "4.1.3",
|
|
197
|
-
"alwaysAddToPackageJson": false
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
},
|
|
201
47
|
"16.3.0": {
|
|
202
48
|
"version": "16.3.0-beta.2",
|
|
203
49
|
"packages": {
|
|
@@ -305,6 +151,57 @@
|
|
|
305
151
|
"alwaysAddToPackageJson": false
|
|
306
152
|
}
|
|
307
153
|
}
|
|
154
|
+
},
|
|
155
|
+
"19.0.0": {
|
|
156
|
+
"version": "19.0.0-beta.12",
|
|
157
|
+
"packages": {
|
|
158
|
+
"react": {
|
|
159
|
+
"version": "18.3.1",
|
|
160
|
+
"alwaysAddToPackageJson": false
|
|
161
|
+
},
|
|
162
|
+
"react-dom": {
|
|
163
|
+
"version": "18.3.1",
|
|
164
|
+
"alwaysAddToPackageJson": false
|
|
165
|
+
},
|
|
166
|
+
"react-is": {
|
|
167
|
+
"version": "18.3.1",
|
|
168
|
+
"alwaysAddToPackageJson": false
|
|
169
|
+
},
|
|
170
|
+
"@types/react": {
|
|
171
|
+
"version": "18.3.1",
|
|
172
|
+
"alwaysAddToPackageJson": false
|
|
173
|
+
},
|
|
174
|
+
"@types/react-dom": {
|
|
175
|
+
"version": "18.3.0",
|
|
176
|
+
"alwaysAddToPackageJson": false
|
|
177
|
+
},
|
|
178
|
+
"@types/react-is": {
|
|
179
|
+
"version": "18.3.0",
|
|
180
|
+
"alwaysAddToPackageJson": false
|
|
181
|
+
},
|
|
182
|
+
"@testing-library/react": {
|
|
183
|
+
"version": "15.0.6",
|
|
184
|
+
"alwaysAddToPackageJson": false
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
},
|
|
188
|
+
"19.0.3": {
|
|
189
|
+
"version": "19.0.3-beta.0",
|
|
190
|
+
"packages": {
|
|
191
|
+
"tailwindcss": {
|
|
192
|
+
"version": "3.4.3",
|
|
193
|
+
"alwaysAddToPackageJson": false
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
},
|
|
197
|
+
"19.2.0": {
|
|
198
|
+
"version": "19.2.0-beta.8",
|
|
199
|
+
"packages": {
|
|
200
|
+
"postcss": {
|
|
201
|
+
"version": "8.4.38",
|
|
202
|
+
"alwaysAddToPackageJson": false
|
|
203
|
+
}
|
|
204
|
+
}
|
|
308
205
|
}
|
|
309
206
|
}
|
|
310
207
|
}
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/react",
|
|
3
|
-
"version": "0.0.0-pr-
|
|
3
|
+
"version": "0.0.0-pr-26515-856ef7f",
|
|
4
4
|
"private": false,
|
|
5
|
-
"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, 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.",
|
|
5
|
+
"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.",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "https://github.com/nrwl/nx.git",
|
|
@@ -14,9 +14,10 @@
|
|
|
14
14
|
"Web",
|
|
15
15
|
"Jest",
|
|
16
16
|
"Cypress",
|
|
17
|
-
"CLI"
|
|
17
|
+
"CLI",
|
|
18
|
+
"Front-end"
|
|
18
19
|
],
|
|
19
|
-
"main": "./index
|
|
20
|
+
"main": "./index",
|
|
20
21
|
"typings": "./index.d.ts",
|
|
21
22
|
"author": "Victor Savkin",
|
|
22
23
|
"license": "MIT",
|
|
@@ -34,13 +35,14 @@
|
|
|
34
35
|
"@phenomnomnominal/tsquery": "~5.0.1",
|
|
35
36
|
"@svgr/webpack": "^8.0.1",
|
|
36
37
|
"chalk": "^4.1.0",
|
|
38
|
+
"file-loader": "^6.2.0",
|
|
37
39
|
"minimatch": "9.0.3",
|
|
38
40
|
"tslib": "^2.3.0",
|
|
39
|
-
"@nx/devkit": "0.0.0-pr-
|
|
40
|
-
"@nx/js": "0.0.0-pr-
|
|
41
|
-
"@nx/eslint": "0.0.0-pr-
|
|
42
|
-
"@nx/web": "0.0.0-pr-
|
|
43
|
-
"@nrwl/react": "0.0.0-pr-
|
|
41
|
+
"@nx/devkit": "0.0.0-pr-26515-856ef7f",
|
|
42
|
+
"@nx/js": "0.0.0-pr-26515-856ef7f",
|
|
43
|
+
"@nx/eslint": "0.0.0-pr-26515-856ef7f",
|
|
44
|
+
"@nx/web": "0.0.0-pr-26515-856ef7f",
|
|
45
|
+
"@nrwl/react": "0.0.0-pr-26515-856ef7f"
|
|
44
46
|
},
|
|
45
47
|
"publishConfig": {
|
|
46
48
|
"access": "public"
|
package/plugins/bundle-rollup.js
CHANGED
|
@@ -28,7 +28,7 @@ function nxComponentTestingPreset(pathToConfig, options) {
|
|
|
28
28
|
const basePresetSettings = (0, cypress_preset_1.nxBaseCypressPreset)(pathToConfig, {
|
|
29
29
|
testingType: 'component',
|
|
30
30
|
});
|
|
31
|
-
if (global.NX_GRAPH_CREATION
|
|
31
|
+
if (global.NX_GRAPH_CREATION) {
|
|
32
32
|
// this is only used by plugins, so we don't need the component testing
|
|
33
33
|
// options, cast to any to avoid type errors
|
|
34
34
|
return basePresetSettings;
|
|
@@ -168,7 +168,10 @@ function buildTargetWebpack(ctx, buildTarget, componentTestingProjectName) {
|
|
|
168
168
|
}
|
|
169
169
|
return async () => {
|
|
170
170
|
customWebpack = await customWebpack;
|
|
171
|
-
// TODO(
|
|
171
|
+
// TODO(v20): Component testing need to be agnostic of the underlying executor. With Crystal, we're not using `@nx/webpack:webpack` by default.
|
|
172
|
+
// We need to decouple CT from the build target of the app, we just care about bundler config (e.g. webpack.config.js).
|
|
173
|
+
// The generated setup should support both Webpack and Vite as documented here: https://docs.cypress.io/guides/component-testing/react/overview
|
|
174
|
+
// Related issue: https://github.com/nrwl/nx/issues/21546
|
|
172
175
|
const configure = composePluginsSync(withNx(), withWeb());
|
|
173
176
|
const defaultWebpack = configure({}, {
|
|
174
177
|
options: {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Configuration, WebpackOptionsNormalized } from 'webpack';
|
|
2
|
+
import { SvgrOptions } from '../../with-react';
|
|
2
3
|
export declare function applyReactConfig(options: {
|
|
3
|
-
svgr?: boolean;
|
|
4
|
+
svgr?: boolean | SvgrOptions;
|
|
4
5
|
}, config?: Partial<WebpackOptionsNormalized | Configuration>): void;
|
|
@@ -5,18 +5,46 @@ function applyReactConfig(options, config = {}) {
|
|
|
5
5
|
if (!process.env['NX_TASK_TARGET_PROJECT'])
|
|
6
6
|
return;
|
|
7
7
|
addHotReload(config);
|
|
8
|
-
if (options.svgr !== false) {
|
|
8
|
+
if (options.svgr !== false || typeof options.svgr === 'object') {
|
|
9
9
|
removeSvgLoaderIfPresent(config);
|
|
10
|
+
const defaultSvgrOptions = {
|
|
11
|
+
svgo: false,
|
|
12
|
+
titleProp: true,
|
|
13
|
+
ref: true,
|
|
14
|
+
};
|
|
15
|
+
const svgrOptions = typeof options.svgr === 'object' ? options.svgr : defaultSvgrOptions;
|
|
16
|
+
// TODO(v20): Remove file-loader and use `?react` querystring to differentiate between asset and SVGR.
|
|
17
|
+
// It should be:
|
|
18
|
+
// use: [{
|
|
19
|
+
// test: /\.svg$/i,
|
|
20
|
+
// type: 'asset',
|
|
21
|
+
// resourceQuery: /react/, // *.svg?react
|
|
22
|
+
// },
|
|
23
|
+
// {
|
|
24
|
+
// test: /\.svg$/i,
|
|
25
|
+
// issuer: /\.[jt]sx?$/,
|
|
26
|
+
// resourceQuery: { not: [/react/] }, // exclude react component if *.svg?react
|
|
27
|
+
// use: ['@svgr/webpack'],
|
|
28
|
+
// }],
|
|
29
|
+
// See:
|
|
30
|
+
// - SVGR: https://react-svgr.com/docs/webpack/#use-svgr-and-asset-svg-in-the-same-project
|
|
31
|
+
// - Vite: https://www.npmjs.com/package/vite-plugin-svgr
|
|
32
|
+
// - Rsbuild: https://github.com/web-infra-dev/rsbuild/pull/1783
|
|
33
|
+
// Note: We also need a migration for any projects that are using SVGR to convert
|
|
34
|
+
// `import { ReactComponent as X } from './x.svg` to
|
|
35
|
+
// `import X from './x.svg?react';
|
|
10
36
|
config.module.rules.push({
|
|
11
37
|
test: /\.svg$/,
|
|
12
38
|
issuer: /\.(js|ts|md)x?$/,
|
|
13
39
|
use: [
|
|
14
40
|
{
|
|
15
41
|
loader: require.resolve('@svgr/webpack'),
|
|
42
|
+
options: svgrOptions,
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
loader: require.resolve('file-loader'),
|
|
16
46
|
options: {
|
|
17
|
-
|
|
18
|
-
titleProp: true,
|
|
19
|
-
ref: true,
|
|
47
|
+
name: '[name].[hash].[ext]',
|
|
20
48
|
},
|
|
21
49
|
},
|
|
22
50
|
],
|
|
@@ -47,7 +75,7 @@ function addHotReload(config) {
|
|
|
47
75
|
];
|
|
48
76
|
}
|
|
49
77
|
const ReactRefreshPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
|
|
50
|
-
config.plugins.push(new ReactRefreshPlugin());
|
|
78
|
+
config.plugins.push(new ReactRefreshPlugin({ overlay: false }));
|
|
51
79
|
}
|
|
52
80
|
}
|
|
53
81
|
// We remove potentially conflicting rules that target SVGs because we use @svgr/webpack loader
|
|
@@ -13,7 +13,7 @@ const fs_1 = require("fs");
|
|
|
13
13
|
function getClientEnvironment(mode) {
|
|
14
14
|
// Grab NODE_ENV and NX_* and STORYBOOK_* environment variables and prepare them to be
|
|
15
15
|
// injected into the application via DefinePlugin in webpack configuration.
|
|
16
|
-
const NX_PREFIX = /^
|
|
16
|
+
const NX_PREFIX = /^NX_PUBLIC_/i;
|
|
17
17
|
const STORYBOOK_PREFIX = /^STORYBOOK_/i;
|
|
18
18
|
const raw = Object.keys(process.env)
|
|
19
19
|
.filter((key) => NX_PREFIX.test(key) || STORYBOOK_PREFIX.test(key))
|
package/plugins/with-react.d.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import type { Configuration } from 'webpack';
|
|
2
2
|
import type { NxWebpackExecutionContext, WithWebOptions } from '@nx/webpack';
|
|
3
|
+
export interface SvgrOptions {
|
|
4
|
+
svgo?: boolean;
|
|
5
|
+
titleProp?: boolean;
|
|
6
|
+
ref?: boolean;
|
|
7
|
+
}
|
|
3
8
|
export interface WithReactOptions extends WithWebOptions {
|
|
4
|
-
svgr?:
|
|
9
|
+
svgr?: boolean | SvgrOptions;
|
|
5
10
|
}
|
|
6
11
|
/**
|
|
7
12
|
* @param {WithReactOptions} pluginOptions
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import { ExecutorContext } from '@nx/devkit';
|
|
2
2
|
import { WebDevServerOptions } from '@nx/webpack/src/executors/dev-server/schema';
|
|
3
3
|
type ModuleFederationDevServerOptions = WebDevServerOptions & {
|
|
4
|
-
devRemotes?: string
|
|
4
|
+
devRemotes?: (string | {
|
|
5
|
+
remoteName: string;
|
|
6
|
+
configuration: string;
|
|
7
|
+
})[];
|
|
5
8
|
skipRemotes?: string[];
|
|
6
9
|
static?: boolean;
|
|
7
10
|
isInitialHost?: boolean;
|
|
8
11
|
parallel?: number;
|
|
9
12
|
staticRemotesPort?: number;
|
|
13
|
+
pathToManifestFile?: string;
|
|
10
14
|
};
|
|
11
15
|
type StaticRemoteConfig = {
|
|
12
16
|
basePath: string;
|