@nx/react 0.0.0-pr-30418-80f02f7 → 0.0.0-pr-3-4212ebd
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 +6 -6
- package/src/generators/application/application.js +20 -21
- package/src/generators/application/files/react-router-ssr/common/app/app-nav.tsx__tmpl__ +1 -0
- package/src/generators/application/lib/add-jest.js +2 -26
- package/src/generators/application/lib/normalize-options.js +1 -4
- package/src/generators/library/library.js +13 -15
- package/src/utils/assertion.d.ts +0 -2
- package/src/utils/assertion.js +0 -6
- package/src/utils/ct-utils.d.ts +1 -1
- package/src/utils/format-file.d.ts +1 -0
- package/src/utils/format-file.js +11 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/react",
|
|
3
|
-
"version": "0.0.0-pr-
|
|
3
|
+
"version": "0.0.0-pr-3-4212ebd",
|
|
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": {
|
|
@@ -38,11 +38,11 @@
|
|
|
38
38
|
"minimatch": "9.0.3",
|
|
39
39
|
"picocolors": "^1.1.0",
|
|
40
40
|
"tslib": "^2.3.0",
|
|
41
|
-
"@nx/devkit": "0.0.0-pr-
|
|
42
|
-
"@nx/js": "0.0.0-pr-
|
|
43
|
-
"@nx/eslint": "0.0.0-pr-
|
|
44
|
-
"@nx/web": "0.0.0-pr-
|
|
45
|
-
"@nx/module-federation": "0.0.0-pr-
|
|
41
|
+
"@nx/devkit": "0.0.0-pr-3-4212ebd",
|
|
42
|
+
"@nx/js": "0.0.0-pr-3-4212ebd",
|
|
43
|
+
"@nx/eslint": "0.0.0-pr-3-4212ebd",
|
|
44
|
+
"@nx/web": "0.0.0-pr-3-4212ebd",
|
|
45
|
+
"@nx/module-federation": "0.0.0-pr-3-4212ebd",
|
|
46
46
|
"express": "^4.21.2",
|
|
47
47
|
"http-proxy-middleware": "^3.0.3",
|
|
48
48
|
"semver": "^7.6.3"
|
|
@@ -46,26 +46,25 @@ async function applicationGeneratorInternal(tree, schema) {
|
|
|
46
46
|
});
|
|
47
47
|
tasks.push(jsInitTask);
|
|
48
48
|
const options = await (0, normalize_options_1.normalizeOptions)(tree, schema);
|
|
49
|
-
options.useReactRouter =
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
: false;
|
|
49
|
+
options.useReactRouter = options.routing
|
|
50
|
+
? options.useReactRouter ??
|
|
51
|
+
(await (0, prompt_1.promptWhenInteractive)({
|
|
52
|
+
name: 'response',
|
|
53
|
+
message: 'Would you like to use react-router for server-side rendering?',
|
|
54
|
+
type: 'autocomplete',
|
|
55
|
+
choices: [
|
|
56
|
+
{
|
|
57
|
+
name: 'Yes',
|
|
58
|
+
message: 'I want to use react-router [ https://reactrouter.com/start/framework/routing ]',
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
name: 'No',
|
|
62
|
+
message: 'I do not want to use react-router for server-side rendering',
|
|
63
|
+
},
|
|
64
|
+
],
|
|
65
|
+
initial: 0,
|
|
66
|
+
}, { response: 'No' }).then((r) => r.response === 'Yes'))
|
|
67
|
+
: false;
|
|
69
68
|
(0, show_possible_warnings_1.showPossibleWarnings)(tree, options);
|
|
70
69
|
const initTask = await (0, init_1.default)(tree, {
|
|
71
70
|
...options,
|
|
@@ -168,7 +167,7 @@ async function applicationGeneratorInternal(tree, schema) {
|
|
|
168
167
|
moduleResolution: 'bundler',
|
|
169
168
|
}, options.linter === 'eslint'
|
|
170
169
|
? ['eslint.config.js', 'eslint.config.cjs', 'eslint.config.mjs']
|
|
171
|
-
: undefined
|
|
170
|
+
: undefined);
|
|
172
171
|
(0, sort_fields_1.sortPackageJsonFields)(tree, options.appProjectRoot);
|
|
173
172
|
if (!options.skipFormat) {
|
|
174
173
|
await (0, devkit_1.formatFiles)(tree);
|
|
@@ -3,43 +3,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.addJest = addJest;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const versions_1 = require("../../../utils/versions");
|
|
6
|
-
const node_path_1 = require("node:path");
|
|
7
6
|
async function addJest(host, options) {
|
|
8
7
|
if (options.unitTestRunner === 'none') {
|
|
9
8
|
return () => { };
|
|
10
9
|
}
|
|
11
10
|
const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/jest', versions_1.nxVersion);
|
|
12
|
-
await configurationGenerator(host, {
|
|
11
|
+
return await configurationGenerator(host, {
|
|
13
12
|
...options,
|
|
14
13
|
project: options.projectName,
|
|
15
14
|
supportTsx: true,
|
|
16
15
|
skipSerializers: true,
|
|
17
|
-
setupFile:
|
|
16
|
+
setupFile: 'none',
|
|
18
17
|
compiler: options.compiler,
|
|
19
18
|
skipFormat: true,
|
|
20
19
|
runtimeTsconfigFileName: 'tsconfig.app.json',
|
|
21
20
|
});
|
|
22
|
-
if (options.useReactRouter) {
|
|
23
|
-
(0, devkit_1.updateJson)(host, (0, node_path_1.join)(options.appProjectRoot, 'tsconfig.spec.json'), (json) => {
|
|
24
|
-
json.include = json.include ?? [];
|
|
25
|
-
const reactRouterTestGlob = options.js
|
|
26
|
-
? [
|
|
27
|
-
'test/**/*.spec.jsx',
|
|
28
|
-
'test/**/*.spec.js',
|
|
29
|
-
'test/**/*.test.jsx',
|
|
30
|
-
'test/**/*.test.js',
|
|
31
|
-
]
|
|
32
|
-
: [
|
|
33
|
-
'test/**/*.spec.tsx',
|
|
34
|
-
'test/**/*.spec.ts',
|
|
35
|
-
'test/**/*.test.tsx',
|
|
36
|
-
'test/**/*.test.ts',
|
|
37
|
-
];
|
|
38
|
-
return {
|
|
39
|
-
...json,
|
|
40
|
-
include: Array.from(new Set([...json.include, ...reactRouterTestGlob])),
|
|
41
|
-
};
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
return () => { };
|
|
45
21
|
}
|
|
@@ -31,10 +31,7 @@ async function normalizeOptions(host, options) {
|
|
|
31
31
|
? null
|
|
32
32
|
: options.style;
|
|
33
33
|
(0, assertion_1.assertValidStyle)(options.style);
|
|
34
|
-
|
|
35
|
-
if (options.useReactRouter && !options.bundler) {
|
|
36
|
-
options.bundler = 'vite';
|
|
37
|
-
}
|
|
34
|
+
options.bundler = options.useReactRouter ? 'vite' : options.bundler;
|
|
38
35
|
options.useReactRouter = options.routing ? options.useReactRouter : false;
|
|
39
36
|
const normalized = {
|
|
40
37
|
...options,
|
|
@@ -2,29 +2,28 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.libraryGenerator = libraryGenerator;
|
|
4
4
|
exports.libraryGeneratorInternal = libraryGeneratorInternal;
|
|
5
|
+
const path_1 = require("path");
|
|
5
6
|
const devkit_1 = require("@nx/devkit");
|
|
6
7
|
const artifact_name_and_directory_utils_1 = require("@nx/devkit/src/generators/artifact-name-and-directory-utils");
|
|
7
8
|
const log_show_project_command_1 = require("@nx/devkit/src/utils/log-show-project-command");
|
|
8
9
|
const js_1 = require("@nx/js");
|
|
9
|
-
const path_1 = require("path");
|
|
10
|
-
const add_release_config_1 = require("@nx/js/src/generators/library/utils/add-release-config");
|
|
11
|
-
const sort_fields_1 = require("@nx/js/src/utils/package-json/sort-fields");
|
|
12
|
-
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
13
|
-
const use_legacy_versioning_1 = require("nx/src/command-line/release/config/use-legacy-versioning");
|
|
14
|
-
const create_ts_config_1 = require("../../utils/create-ts-config");
|
|
15
|
-
const jest_utils_1 = require("../../utils/jest-utils");
|
|
16
|
-
const maybe_js_1 = require("../../utils/maybe-js");
|
|
17
10
|
const versions_1 = require("../../utils/versions");
|
|
11
|
+
const maybe_js_1 = require("../../utils/maybe-js");
|
|
18
12
|
const component_1 = require("../component/component");
|
|
19
13
|
const init_1 = require("../init/init");
|
|
20
|
-
const
|
|
14
|
+
const jest_utils_1 = require("../../utils/jest-utils");
|
|
15
|
+
const normalize_options_1 = require("./lib/normalize-options");
|
|
21
16
|
const add_rollup_build_target_1 = require("./lib/add-rollup-build-target");
|
|
17
|
+
const add_linting_1 = require("./lib/add-linting");
|
|
18
|
+
const update_app_routes_1 = require("./lib/update-app-routes");
|
|
22
19
|
const create_files_1 = require("./lib/create-files");
|
|
23
|
-
const
|
|
20
|
+
const create_ts_config_1 = require("../../utils/create-ts-config");
|
|
24
21
|
const install_common_dependencies_1 = require("./lib/install-common-dependencies");
|
|
25
|
-
const normalize_options_1 = require("./lib/normalize-options");
|
|
26
22
|
const set_defaults_1 = require("./lib/set-defaults");
|
|
27
|
-
const
|
|
23
|
+
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
24
|
+
const determine_entry_fields_1 = require("./lib/determine-entry-fields");
|
|
25
|
+
const sort_fields_1 = require("@nx/js/src/utils/package-json/sort-fields");
|
|
26
|
+
const add_release_config_1 = require("@nx/js/src/generators/library/utils/add-release-config");
|
|
28
27
|
async function libraryGenerator(host, schema) {
|
|
29
28
|
return await libraryGeneratorInternal(host, {
|
|
30
29
|
addPlugin: false,
|
|
@@ -191,14 +190,13 @@ async function libraryGeneratorInternal(host, schema) {
|
|
|
191
190
|
});
|
|
192
191
|
tasks.push(componentTask);
|
|
193
192
|
}
|
|
194
|
-
if (options.publishable) {
|
|
193
|
+
if (options.publishable || options.buildable) {
|
|
195
194
|
const projectConfiguration = (0, devkit_1.readProjectConfiguration)(host, options.name);
|
|
196
195
|
if (options.isUsingTsSolutionConfig) {
|
|
197
196
|
await (0, add_release_config_1.addReleaseConfigForTsSolution)(host, options.name, projectConfiguration);
|
|
198
197
|
}
|
|
199
198
|
else {
|
|
200
|
-
|
|
201
|
-
await (0, add_release_config_1.addReleaseConfigForNonTsSolution)((0, use_legacy_versioning_1.shouldUseLegacyVersioning)(nxJson.release), host, options.name, projectConfiguration);
|
|
199
|
+
await (0, add_release_config_1.addReleaseConfigForNonTsSolution)(host, options.name, projectConfiguration);
|
|
202
200
|
}
|
|
203
201
|
(0, devkit_1.updateProjectConfiguration)(host, options.name, projectConfiguration);
|
|
204
202
|
tasks.push(await (0, add_release_config_1.releaseTasks)(host));
|
package/src/utils/assertion.d.ts
CHANGED
package/src/utils/assertion.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.assertValidStyle = assertValidStyle;
|
|
4
|
-
exports.assertValidReactRouter = assertValidReactRouter;
|
|
5
4
|
const VALID_STYLES = [
|
|
6
5
|
'css',
|
|
7
6
|
'scss',
|
|
@@ -17,8 +16,3 @@ function assertValidStyle(style) {
|
|
|
17
16
|
throw new Error(`Unsupported style option found: ${style}. Valid values are: "${VALID_STYLES.join('", "')}"`);
|
|
18
17
|
}
|
|
19
18
|
}
|
|
20
|
-
function assertValidReactRouter(reactRouter, bundler) {
|
|
21
|
-
if (reactRouter && bundler !== 'vite') {
|
|
22
|
-
throw new Error(`Unsupported bundler found: ${bundler}. React Router is only supported with 'vite'.`);
|
|
23
|
-
}
|
|
24
|
-
}
|
package/src/utils/ct-utils.d.ts
CHANGED
|
@@ -10,5 +10,5 @@ export declare function getBundlerFromTarget(found: FoundTarget, tree: Tree): Pr
|
|
|
10
10
|
export declare function getActualBundler(tree: Tree, options: {
|
|
11
11
|
buildTarget?: string;
|
|
12
12
|
bundler?: 'vite' | 'webpack';
|
|
13
|
-
}, found: FoundTarget): Promise<"
|
|
13
|
+
}, found: FoundTarget): Promise<"vite" | "webpack">;
|
|
14
14
|
export declare function isComponent(tree: Tree, filePath: string): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function formatFile(content: any, ...values: any[]): string;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.formatFile = formatFile;
|
|
4
|
+
const prettier_1 = require("prettier");
|
|
5
|
+
const devkit_1 = require("@nx/devkit");
|
|
6
|
+
function formatFile(content, ...values) {
|
|
7
|
+
return (0, prettier_1.format)((0, devkit_1.stripIndents)(content, values), {
|
|
8
|
+
singleQuote: true,
|
|
9
|
+
parser: 'typescript',
|
|
10
|
+
});
|
|
11
|
+
}
|