@nx/react 17.3.1 → 18.0.0-beta.1
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/migrations.json +6 -0
- package/package.json +6 -6
- package/src/generators/application/application.js +4 -0
- package/src/generators/host/host.js +2 -0
- package/src/generators/library/library.js +4 -0
- package/src/generators/remote/remote.js +2 -0
- package/src/migrations/update-18-0-0/add-mf-env-var-to-target-defaults.d.ts +2 -0
- package/src/migrations/update-18-0-0/add-mf-env-var-to-target-defaults.js +26 -0
- package/src/utils/add-mf-env-to-inputs.d.ts +2 -0
- package/src/utils/add-mf-env-to-inputs.js +24 -0
package/migrations.json
CHANGED
|
@@ -47,6 +47,12 @@
|
|
|
47
47
|
"version": "16.7.0-beta.2",
|
|
48
48
|
"description": "Add @nx/react types to tsconfig types array",
|
|
49
49
|
"implementation": "./src/migrations/update-16-7-0-add-typings/update-16-7-0-add-typings"
|
|
50
|
+
},
|
|
51
|
+
"add-module-federation-env-var-to-target-defaults": {
|
|
52
|
+
"cli": "nx",
|
|
53
|
+
"version": "18.0.0-beta.0",
|
|
54
|
+
"description": "Add NX_MF_DEV_SERVER_STATIC_REMOTES to inputs for task hashing when '@nx/webpack:webpack' is used for Module Federation.",
|
|
55
|
+
"factory": "./src/migrations/update-18-0-0/add-mf-env-var-to-target-defaults"
|
|
50
56
|
}
|
|
51
57
|
},
|
|
52
58
|
"packageJsonUpdates": {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/react",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "18.0.0-beta.1",
|
|
4
4
|
"private": false,
|
|
5
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.",
|
|
6
6
|
"repository": {
|
|
@@ -37,11 +37,11 @@
|
|
|
37
37
|
"file-loader": "^6.2.0",
|
|
38
38
|
"minimatch": "9.0.3",
|
|
39
39
|
"tslib": "^2.3.0",
|
|
40
|
-
"@nx/devkit": "
|
|
41
|
-
"@nx/js": "
|
|
42
|
-
"@nx/eslint": "
|
|
43
|
-
"@nx/web": "
|
|
44
|
-
"@nrwl/react": "
|
|
40
|
+
"@nx/devkit": "18.0.0-beta.1",
|
|
41
|
+
"@nx/js": "18.0.0-beta.1",
|
|
42
|
+
"@nx/eslint": "18.0.0-beta.1",
|
|
43
|
+
"@nx/web": "18.0.0-beta.1",
|
|
44
|
+
"@nrwl/react": "18.0.0-beta.1"
|
|
45
45
|
},
|
|
46
46
|
"publishConfig": {
|
|
47
47
|
"access": "public"
|
|
@@ -22,6 +22,7 @@ const show_possible_warnings_1 = require("./lib/show-possible-warnings");
|
|
|
22
22
|
const add_e2e_1 = require("./lib/add-e2e");
|
|
23
23
|
const eslint_file_1 = require("@nx/eslint/src/generators/utils/eslint-file");
|
|
24
24
|
const js_1 = require("@nx/js");
|
|
25
|
+
const log_show_project_command_1 = require("@nx/devkit/src/utils/log-show-project-command");
|
|
25
26
|
async function addLinting(host, options) {
|
|
26
27
|
const tasks = [];
|
|
27
28
|
if (options.linter === eslint_1.Linter.EsLint) {
|
|
@@ -208,6 +209,9 @@ async function applicationGeneratorInternal(host, schema) {
|
|
|
208
209
|
if (!options.skipFormat) {
|
|
209
210
|
await (0, devkit_1.formatFiles)(host);
|
|
210
211
|
}
|
|
212
|
+
tasks.push(() => {
|
|
213
|
+
(0, log_show_project_command_1.logShowProjectCommand)(options.projectName);
|
|
214
|
+
});
|
|
211
215
|
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
212
216
|
}
|
|
213
217
|
exports.applicationGeneratorInternal = applicationGeneratorInternal;
|
|
@@ -11,6 +11,7 @@ const add_module_federation_files_1 = require("./lib/add-module-federation-files
|
|
|
11
11
|
const normalize_remote_1 = require("./lib/normalize-remote");
|
|
12
12
|
const setup_ssr_for_host_1 = require("./lib/setup-ssr-for-host");
|
|
13
13
|
const update_module_federation_e2e_project_1 = require("./lib/update-module-federation-e2e-project");
|
|
14
|
+
const add_mf_env_to_inputs_1 = require("../../utils/add-mf-env-to-inputs");
|
|
14
15
|
async function hostGenerator(host, schema) {
|
|
15
16
|
return hostGeneratorInternal(host, {
|
|
16
17
|
projectNameAndRootFormat: 'derived',
|
|
@@ -78,6 +79,7 @@ async function hostGeneratorInternal(host, schema) {
|
|
|
78
79
|
if (!options.setParserOptionsProject) {
|
|
79
80
|
host.delete((0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.lint.json'));
|
|
80
81
|
}
|
|
82
|
+
(0, add_mf_env_to_inputs_1.addMfEnvToTargetDefaultInputs)(host);
|
|
81
83
|
if (!options.skipFormat) {
|
|
82
84
|
await (0, devkit_1.formatFiles)(host);
|
|
83
85
|
}
|
|
@@ -17,6 +17,7 @@ const create_ts_config_1 = require("../../utils/create-ts-config");
|
|
|
17
17
|
const install_common_dependencies_1 = require("./lib/install-common-dependencies");
|
|
18
18
|
const set_defaults_1 = require("./lib/set-defaults");
|
|
19
19
|
const path_1 = require("path");
|
|
20
|
+
const log_show_project_command_1 = require("@nx/devkit/src/utils/log-show-project-command");
|
|
20
21
|
async function libraryGenerator(host, schema) {
|
|
21
22
|
return await libraryGeneratorInternal(host, {
|
|
22
23
|
projectNameAndRootFormat: 'derived',
|
|
@@ -179,6 +180,9 @@ async function libraryGeneratorInternal(host, schema) {
|
|
|
179
180
|
if (!options.skipFormat) {
|
|
180
181
|
await (0, devkit_1.formatFiles)(host);
|
|
181
182
|
}
|
|
183
|
+
tasks.push(() => {
|
|
184
|
+
(0, log_show_project_command_1.logShowProjectCommand)(options.name);
|
|
185
|
+
});
|
|
182
186
|
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
183
187
|
}
|
|
184
188
|
exports.libraryGeneratorInternal = libraryGeneratorInternal;
|
|
@@ -11,6 +11,7 @@ const setup_ssr_1 = require("../setup-ssr/setup-ssr");
|
|
|
11
11
|
const setup_ssr_for_remote_1 = require("./lib/setup-ssr-for-remote");
|
|
12
12
|
const setup_tspath_for_remote_1 = require("./lib/setup-tspath-for-remote");
|
|
13
13
|
const add_remote_to_dynamic_host_1 = require("./lib/add-remote-to-dynamic-host");
|
|
14
|
+
const add_mf_env_to_inputs_1 = require("../../utils/add-mf-env-to-inputs");
|
|
14
15
|
function addModuleFederationFiles(host, options) {
|
|
15
16
|
const templateVariables = {
|
|
16
17
|
...(0, devkit_1.names)(options.name),
|
|
@@ -85,6 +86,7 @@ async function remoteGeneratorInternal(host, schema) {
|
|
|
85
86
|
const pathToMFManifest = (0, devkit_1.joinPathFragments)(hostConfig.sourceRoot, 'assets/module-federation.manifest.json');
|
|
86
87
|
(0, add_remote_to_dynamic_host_1.addRemoteToDynamicHost)(host, options.name, options.devServerPort, pathToMFManifest);
|
|
87
88
|
}
|
|
89
|
+
(0, add_mf_env_to_inputs_1.addMfEnvToTargetDefaultInputs)(host);
|
|
88
90
|
if (!options.skipFormat) {
|
|
89
91
|
await (0, devkit_1.formatFiles)(host);
|
|
90
92
|
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const devkit_1 = require("@nx/devkit");
|
|
4
|
+
const add_mf_env_to_inputs_1 = require("../../utils/add-mf-env-to-inputs");
|
|
5
|
+
async function default_1(tree) {
|
|
6
|
+
if (!hasModuleFederationProject(tree)) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
(0, add_mf_env_to_inputs_1.addMfEnvToTargetDefaultInputs)(tree);
|
|
10
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
11
|
+
}
|
|
12
|
+
exports.default = default_1;
|
|
13
|
+
function hasModuleFederationProject(tree) {
|
|
14
|
+
const projects = (0, devkit_1.getProjects)(tree);
|
|
15
|
+
for (const project of projects.values()) {
|
|
16
|
+
const targets = project.targets;
|
|
17
|
+
for (const [_, target] of Object.entries(targets)) {
|
|
18
|
+
if (target.executor === '@nx/webpack:webpack' &&
|
|
19
|
+
(tree.exists((0, devkit_1.joinPathFragments)(project.root, 'module-federation.config.ts')) ||
|
|
20
|
+
tree.exists((0, devkit_1.joinPathFragments)(project.root, 'module-federation.config.js')))) {
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addMfEnvToTargetDefaultInputs = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
function addMfEnvToTargetDefaultInputs(tree) {
|
|
6
|
+
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
7
|
+
const webpackExecutor = '@nx/webpack:webpack';
|
|
8
|
+
const mfEnvVar = 'NX_MF_DEV_SERVER_STATIC_REMOTES';
|
|
9
|
+
nxJson.targetDefaults ??= {};
|
|
10
|
+
nxJson.targetDefaults[webpackExecutor] ??= {};
|
|
11
|
+
nxJson.targetDefaults[webpackExecutor].inputs ??= [];
|
|
12
|
+
let mfEnvVarExists = false;
|
|
13
|
+
for (const input of nxJson.targetDefaults[webpackExecutor].inputs) {
|
|
14
|
+
if (typeof input === 'object' && input['env'] === mfEnvVar) {
|
|
15
|
+
mfEnvVarExists = true;
|
|
16
|
+
break;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
if (!mfEnvVarExists) {
|
|
20
|
+
nxJson.targetDefaults[webpackExecutor].inputs.push({ env: mfEnvVar });
|
|
21
|
+
(0, devkit_1.updateNxJson)(tree, nxJson);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.addMfEnvToTargetDefaultInputs = addMfEnvToTargetDefaultInputs;
|