@nx/react 0.0.0-pr-28808-6acf6c6 → 0.0.0-pr-28808-bceb02f
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/package.json +5 -5
- package/src/generators/application/application.js +2 -0
- package/src/generators/application/lib/add-project.js +2 -3
- package/src/generators/application/schema.d.ts +2 -0
- package/src/generators/application/schema.json +3 -3
- package/src/generators/host/host.js +3 -0
- package/src/generators/host/lib/update-module-federation-tsconfig.d.ts +3 -0
- package/src/generators/host/lib/update-module-federation-tsconfig.js +44 -0
- package/src/generators/library/schema.json +2 -2
- package/src/generators/remote/remote.js +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/react",
|
|
3
|
-
"version": "0.0.0-pr-28808-
|
|
3
|
+
"version": "0.0.0-pr-28808-bceb02f",
|
|
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, 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": {
|
|
@@ -39,10 +39,10 @@
|
|
|
39
39
|
"picocolors": "^1.1.0",
|
|
40
40
|
"tslib": "^2.3.0",
|
|
41
41
|
"@module-federation/enhanced": "0.6.9",
|
|
42
|
-
"@nx/devkit": "0.0.0-pr-28808-
|
|
43
|
-
"@nx/js": "0.0.0-pr-28808-
|
|
44
|
-
"@nx/eslint": "0.0.0-pr-28808-
|
|
45
|
-
"@nx/web": "0.0.0-pr-28808-
|
|
42
|
+
"@nx/devkit": "0.0.0-pr-28808-bceb02f",
|
|
43
|
+
"@nx/js": "0.0.0-pr-28808-bceb02f",
|
|
44
|
+
"@nx/eslint": "0.0.0-pr-28808-bceb02f",
|
|
45
|
+
"@nx/web": "0.0.0-pr-28808-bceb02f",
|
|
46
46
|
"express": "^4.19.2",
|
|
47
47
|
"http-proxy-middleware": "^3.0.3"
|
|
48
48
|
},
|
|
@@ -80,6 +80,7 @@ async function applicationGeneratorInternal(host, schema) {
|
|
|
80
80
|
tsConfigName: schema.rootProject ? 'tsconfig.json' : 'tsconfig.base.json',
|
|
81
81
|
skipFormat: true,
|
|
82
82
|
addTsPlugin: schema.useTsSolution,
|
|
83
|
+
formatter: schema.formatter,
|
|
83
84
|
});
|
|
84
85
|
tasks.push(jsInitTask);
|
|
85
86
|
const options = await (0, normalize_options_1.normalizeOptions)(host, schema);
|
|
@@ -256,6 +257,7 @@ async function applicationGeneratorInternal(host, schema) {
|
|
|
256
257
|
jsx: 'react-jsx',
|
|
257
258
|
module: 'esnext',
|
|
258
259
|
moduleResolution: 'bundler',
|
|
260
|
+
// outDir: 'dist/app',
|
|
259
261
|
});
|
|
260
262
|
if (!options.skipFormat) {
|
|
261
263
|
await (0, devkit_1.formatFiles)(host);
|
|
@@ -4,7 +4,6 @@ exports.addProject = addProject;
|
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const has_webpack_plugin_1 = require("../../../utils/has-webpack-plugin");
|
|
6
6
|
const maybe_js_1 = require("../../../utils/maybe-js");
|
|
7
|
-
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
8
7
|
const get_import_path_1 = require("@nx/js/src/utils/get-import-path");
|
|
9
8
|
function addProject(host, options) {
|
|
10
9
|
const project = {
|
|
@@ -22,7 +21,7 @@ function addProject(host, options) {
|
|
|
22
21
|
};
|
|
23
22
|
}
|
|
24
23
|
}
|
|
25
|
-
if (
|
|
24
|
+
if (options.isUsingTsSolutionConfig) {
|
|
26
25
|
(0, devkit_1.writeJson)(host, (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'package.json'), {
|
|
27
26
|
name: (0, get_import_path_1.getImportPath)(host, options.name),
|
|
28
27
|
version: '0.0.1',
|
|
@@ -32,7 +31,7 @@ function addProject(host, options) {
|
|
|
32
31
|
},
|
|
33
32
|
});
|
|
34
33
|
}
|
|
35
|
-
|
|
34
|
+
if (!options.isUsingTsSolutionConfig || options.alwaysGenerateProjectJson) {
|
|
36
35
|
(0, devkit_1.addProjectConfiguration)(host, options.projectName, {
|
|
37
36
|
...project,
|
|
38
37
|
});
|
|
@@ -29,6 +29,8 @@ export interface Schema {
|
|
|
29
29
|
addPlugin?: boolean;
|
|
30
30
|
nxCloudToken?: string;
|
|
31
31
|
useTsSolution?: boolean;
|
|
32
|
+
formatter?: 'prettier' | 'none';
|
|
33
|
+
alwaysGenerateProjectJson?: boolean; // this is needed for MF currently
|
|
32
34
|
}
|
|
33
35
|
|
|
34
36
|
export interface NormalizedSchema<T extends Schema = Schema> extends T {
|
|
@@ -102,7 +102,7 @@
|
|
|
102
102
|
"description": "The tool to use for running lint checks.",
|
|
103
103
|
"type": "string",
|
|
104
104
|
"enum": ["eslint", "none"],
|
|
105
|
-
"default": "
|
|
105
|
+
"default": "eslint",
|
|
106
106
|
"x-prompt": "Which linter would you like to use?",
|
|
107
107
|
"x-priority": "important"
|
|
108
108
|
},
|
|
@@ -110,7 +110,7 @@
|
|
|
110
110
|
"type": "string",
|
|
111
111
|
"enum": ["vitest", "jest", "none"],
|
|
112
112
|
"description": "Test runner to use for unit tests.",
|
|
113
|
-
"default": "
|
|
113
|
+
"default": "vitest",
|
|
114
114
|
"x-priority": "important"
|
|
115
115
|
},
|
|
116
116
|
"inSourceTests": {
|
|
@@ -123,7 +123,7 @@
|
|
|
123
123
|
"enum": ["playwright", "cypress", "none"],
|
|
124
124
|
"description": "Test runner to use for end to end (E2E) tests.",
|
|
125
125
|
"x-prompt": "Which E2E test runner would you like to use?",
|
|
126
|
-
"default": "
|
|
126
|
+
"default": "playwright"
|
|
127
127
|
},
|
|
128
128
|
"tags": {
|
|
129
129
|
"type": "string",
|
|
@@ -15,6 +15,7 @@ const add_mf_env_to_inputs_1 = require("../../utils/add-mf-env-to-inputs");
|
|
|
15
15
|
const js_1 = require("@nx/js");
|
|
16
16
|
const versions_1 = require("../../utils/versions");
|
|
17
17
|
const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
|
|
18
|
+
const update_module_federation_tsconfig_1 = require("./lib/update-module-federation-tsconfig");
|
|
18
19
|
async function hostGenerator(host, schema) {
|
|
19
20
|
const tasks = [];
|
|
20
21
|
const options = {
|
|
@@ -46,6 +47,7 @@ async function hostGenerator(host, schema) {
|
|
|
46
47
|
// The target use-case is loading remotes as child routes, thus always enable routing.
|
|
47
48
|
routing: true,
|
|
48
49
|
skipFormat: true,
|
|
50
|
+
alwaysGenerateProjectJson: true,
|
|
49
51
|
});
|
|
50
52
|
tasks.push(initTask);
|
|
51
53
|
const remotesWithPorts = [];
|
|
@@ -78,6 +80,7 @@ async function hostGenerator(host, schema) {
|
|
|
78
80
|
(0, add_module_federation_files_1.addModuleFederationFiles)(host, options, remotesWithPorts);
|
|
79
81
|
(0, update_module_federation_project_1.updateModuleFederationProject)(host, options);
|
|
80
82
|
(0, update_module_federation_e2e_project_1.updateModuleFederationE2eProject)(host, options);
|
|
83
|
+
(0, update_module_federation_tsconfig_1.updateModuleFederationTsconfig)(host, options);
|
|
81
84
|
if (options.ssr) {
|
|
82
85
|
const setupSsrTask = await (0, setup_ssr_1.default)(host, {
|
|
83
86
|
project: options.projectName,
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.updateModuleFederationTsconfig = updateModuleFederationTsconfig;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
6
|
+
function updateModuleFederationTsconfig(host, options) {
|
|
7
|
+
const tsconfigPath = (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.json');
|
|
8
|
+
const tsconfigRuntimePath = (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.app.json');
|
|
9
|
+
if (!host.exists(tsconfigPath) || !host.exists(tsconfigRuntimePath))
|
|
10
|
+
return;
|
|
11
|
+
// Using `composite: true` and not setting `baseUrl` currently does not work with MF.
|
|
12
|
+
// In integrated setup, `baseUrl` was set in `tsconfig.base.json` and we did not set `composite: true`.
|
|
13
|
+
if ((0, ts_solution_setup_1.isUsingTsSolutionSetup)(host)) {
|
|
14
|
+
(0, devkit_1.updateJson)(host, tsconfigRuntimePath, (json) => {
|
|
15
|
+
json.compilerOptions = {
|
|
16
|
+
...json.compilerOptions,
|
|
17
|
+
composite: false,
|
|
18
|
+
baseUrl: (0, devkit_1.offsetFromRoot)(options.appProjectRoot),
|
|
19
|
+
};
|
|
20
|
+
return json;
|
|
21
|
+
});
|
|
22
|
+
// Update references to match what `nx sync` does.
|
|
23
|
+
if (options.remotes?.length) {
|
|
24
|
+
(0, devkit_1.updateJson)(host, tsconfigPath, (json) => {
|
|
25
|
+
json.references ??= [];
|
|
26
|
+
for (const remote of options.remotes) {
|
|
27
|
+
const remotePath = `../${remote}`;
|
|
28
|
+
if (!json.references.some((ref) => ref.path === remotePath))
|
|
29
|
+
json.references.push({ path: remotePath });
|
|
30
|
+
}
|
|
31
|
+
return json;
|
|
32
|
+
});
|
|
33
|
+
(0, devkit_1.updateJson)(host, tsconfigRuntimePath, (json) => {
|
|
34
|
+
json.references ??= [];
|
|
35
|
+
for (const remote of options.remotes) {
|
|
36
|
+
const remotePath = `../${remote}/tsconfig.app.json`;
|
|
37
|
+
if (!json.references.some((ref) => ref.path === remotePath))
|
|
38
|
+
json.references.push({ path: remotePath });
|
|
39
|
+
}
|
|
40
|
+
return json;
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -75,14 +75,14 @@
|
|
|
75
75
|
"description": "The tool to use for running lint checks.",
|
|
76
76
|
"type": "string",
|
|
77
77
|
"enum": ["eslint", "none"],
|
|
78
|
-
"default": "
|
|
78
|
+
"default": "eslint",
|
|
79
79
|
"x-prompt": "Which linter would you like to use?",
|
|
80
80
|
"x-priority": "important"
|
|
81
81
|
},
|
|
82
82
|
"unitTestRunner": {
|
|
83
83
|
"type": "string",
|
|
84
84
|
"enum": ["vitest", "jest", "none"],
|
|
85
|
-
"default": "
|
|
85
|
+
"default": "vitest",
|
|
86
86
|
"description": "Test runner to use for unit tests.",
|
|
87
87
|
"x-prompt": "What unit test runner should be used?",
|
|
88
88
|
"x-priority": "important"
|