@nx/react 18.0.0-beta.0 → 18.0.0-beta.2
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/generators.json +1 -1
- package/migrations.json +6 -0
- package/package.json +6 -7
- package/plugins/component-testing/index.js +33 -10
- package/plugins/nx-react-webpack-plugin/lib/apply-react-config.js +0 -6
- package/src/generators/application/application.js +9 -0
- package/src/generators/application/files/nx-welcome/src/app/nx-welcome.tsx +19 -0
- package/src/generators/application/lib/add-e2e.js +1 -0
- package/src/generators/application/lib/add-project.js +1 -1
- package/src/generators/application/lib/normalize-options.js +1 -0
- package/src/generators/application/schema.d.ts +2 -0
- package/src/generators/application/schema.json +3 -3
- package/src/generators/component/schema.d.ts +4 -4
- package/src/generators/component/schema.json +7 -7
- package/src/generators/component-cypress-spec/schema.json +1 -1
- package/src/generators/component-story/schema.json +1 -1
- package/src/generators/component-test/schema.json +1 -1
- package/src/generators/cypress-component-configuration/cypress-component-configuration.d.ts +2 -1
- package/src/generators/cypress-component-configuration/cypress-component-configuration.js +14 -4
- package/src/generators/cypress-component-configuration/lib/add-files.js +1 -6
- package/src/generators/cypress-component-configuration/schema.d.ts +1 -0
- package/src/generators/federate-module/schema.json +1 -1
- package/src/generators/hook/schema.d.ts +4 -4
- package/src/generators/hook/schema.json +5 -5
- package/src/generators/host/files/module-federation-ts/webpack.config.prod.ts__tmpl__ +2 -1
- package/src/generators/host/files/module-federation-ts/webpack.config.ts__tmpl__ +2 -2
- package/src/generators/host/host.js +4 -0
- package/src/generators/host/schema.d.ts +3 -1
- package/src/generators/host/schema.json +3 -3
- package/src/generators/init/schema.json +1 -1
- package/src/generators/library/lib/add-linting.js +1 -0
- package/src/generators/library/lib/normalize-options.js +2 -1
- package/src/generators/library/library.js +7 -0
- package/src/generators/library/schema.d.ts +1 -0
- package/src/generators/library/schema.json +3 -3
- package/src/generators/redux/schema.d.ts +1 -1
- package/src/generators/redux/schema.json +2 -2
- package/src/generators/remote/remote.js +4 -0
- package/src/generators/remote/schema.d.ts +1 -1
- package/src/generators/remote/schema.json +3 -3
- package/src/generators/setup-ssr/schema.json +1 -1
- package/src/generators/setup-ssr/setup-ssr.js +16 -4
- package/src/generators/setup-tailwind/schema.json +1 -1
- package/src/generators/stories/schema.json +1 -1
- package/src/generators/stories/stories.js +15 -3
- package/src/generators/storybook-configuration/configuration.d.ts +1 -0
- package/src/generators/storybook-configuration/configuration.js +15 -5
- package/src/generators/storybook-configuration/schema.d.ts +1 -0
- package/src/generators/storybook-configuration/schema.json +4 -4
- 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/module-federation/with-module-federation-ssr.js +3 -0
- package/src/module-federation/with-module-federation.js +3 -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/src/utils/ct-utils.d.ts +6 -1
- package/src/utils/ct-utils.js +30 -9
package/generators.json
CHANGED
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"aliases": ["slice"]
|
|
38
38
|
},
|
|
39
39
|
"storybook-configuration": {
|
|
40
|
-
"factory": "./src/generators/storybook-configuration/configuration#
|
|
40
|
+
"factory": "./src/generators/storybook-configuration/configuration#storybookConfigurationGeneratorInternal",
|
|
41
41
|
"schema": "./src/generators/storybook-configuration/schema.json",
|
|
42
42
|
"description": "Set up storybook for a React app or library.",
|
|
43
43
|
"hidden": false
|
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": "18.0.0-beta.
|
|
3
|
+
"version": "18.0.0-beta.2",
|
|
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": {
|
|
@@ -34,14 +34,13 @@
|
|
|
34
34
|
"@phenomnomnominal/tsquery": "~5.0.1",
|
|
35
35
|
"@svgr/webpack": "^8.0.1",
|
|
36
36
|
"chalk": "^4.1.0",
|
|
37
|
-
"file-loader": "^6.2.0",
|
|
38
37
|
"minimatch": "9.0.3",
|
|
39
38
|
"tslib": "^2.3.0",
|
|
40
|
-
"@nx/devkit": "18.0.0-beta.
|
|
41
|
-
"@nx/js": "18.0.0-beta.
|
|
42
|
-
"@nx/eslint": "18.0.0-beta.
|
|
43
|
-
"@nx/web": "18.0.0-beta.
|
|
44
|
-
"@nrwl/react": "18.0.0-beta.
|
|
39
|
+
"@nx/devkit": "18.0.0-beta.2",
|
|
40
|
+
"@nx/js": "18.0.0-beta.2",
|
|
41
|
+
"@nx/eslint": "18.0.0-beta.2",
|
|
42
|
+
"@nx/web": "18.0.0-beta.2",
|
|
43
|
+
"@nrwl/react": "18.0.0-beta.2"
|
|
45
44
|
},
|
|
46
45
|
"publishConfig": {
|
|
47
46
|
"access": "public"
|
|
@@ -25,12 +25,17 @@ const path_1 = require("path");
|
|
|
25
25
|
* @param options override options
|
|
26
26
|
*/
|
|
27
27
|
function nxComponentTestingPreset(pathToConfig, options) {
|
|
28
|
-
const normalizedProjectRootPath = ['.ts', '.js'].some((ext) => pathToConfig.endsWith(ext))
|
|
29
|
-
? pathToConfig
|
|
30
|
-
: (0, path_1.dirname)(pathToConfig);
|
|
31
28
|
const basePresetSettings = (0, cypress_preset_1.nxBaseCypressPreset)(pathToConfig, {
|
|
32
29
|
testingType: 'component',
|
|
33
30
|
});
|
|
31
|
+
if (global.NX_GRAPH_CREATION || global.NX_CYPRESS_INIT_GENERATOR_RUNNING) {
|
|
32
|
+
// this is only used by plugins, so we don't need the component testing
|
|
33
|
+
// options, cast to any to avoid type errors
|
|
34
|
+
return basePresetSettings;
|
|
35
|
+
}
|
|
36
|
+
const normalizedProjectRootPath = ['.ts', '.js'].some((ext) => pathToConfig.endsWith(ext))
|
|
37
|
+
? pathToConfig
|
|
38
|
+
: (0, path_1.dirname)(pathToConfig);
|
|
34
39
|
if (options?.bundler === 'vite') {
|
|
35
40
|
return {
|
|
36
41
|
...basePresetSettings,
|
|
@@ -66,18 +71,24 @@ function nxComponentTestingPreset(pathToConfig, options) {
|
|
|
66
71
|
const ctTargetName = options?.ctTargetName || 'component-test';
|
|
67
72
|
const ctConfigurationName = process.env.NX_CYPRESS_TARGET_CONFIGURATION;
|
|
68
73
|
const ctExecutorContext = (0, ct_helpers_1.createExecutorContext)(graph, ctTargets, ctProjectName, ctTargetName, ctConfigurationName);
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
74
|
+
let buildTarget = options?.buildTarget;
|
|
75
|
+
if (!buildTarget) {
|
|
76
|
+
const ctExecutorOptions = (0, devkit_1.readTargetOptions)({
|
|
77
|
+
project: ctProjectName,
|
|
78
|
+
target: ctTargetName,
|
|
79
|
+
configuration: ctConfigurationName,
|
|
80
|
+
}, ctExecutorContext);
|
|
81
|
+
buildTarget = ctExecutorOptions.devServerTarget;
|
|
82
|
+
}
|
|
75
83
|
if (!buildTarget) {
|
|
76
84
|
throw new Error(`Unable to find the 'devServerTarget' executor option in the '${ctTargetName}' target of the '${ctProjectName}' project`);
|
|
77
85
|
}
|
|
78
86
|
webpackConfig = buildTargetWebpack(ctExecutorContext, buildTarget, ctProjectName);
|
|
79
87
|
}
|
|
80
88
|
catch (e) {
|
|
89
|
+
if (e instanceof InvalidExecutorError) {
|
|
90
|
+
throw e;
|
|
91
|
+
}
|
|
81
92
|
devkit_1.logger.warn((0, devkit_1.stripIndents) `Unable to build a webpack config with the project graph.
|
|
82
93
|
Falling back to default webpack config.`);
|
|
83
94
|
devkit_1.logger.warn(e);
|
|
@@ -137,6 +148,11 @@ function buildTargetWebpack(ctx, buildTarget, componentTestingProjectName) {
|
|
|
137
148
|
Has component config? ${!!ctProjectConfig}
|
|
138
149
|
`);
|
|
139
150
|
}
|
|
151
|
+
if (buildableProjectConfig.targets[parsed.target].executor !==
|
|
152
|
+
'@nx/webpack:webpack') {
|
|
153
|
+
throw new InvalidExecutorError(`The '${parsed.target}' target of the '${parsed.project}' project is not using the '@nx/webpack:webpack' executor. ` +
|
|
154
|
+
`Please make sure to use '@nx/webpack:webpack' executor in that target to use Cypress Component Testing.`);
|
|
155
|
+
}
|
|
140
156
|
const context = (0, ct_helpers_1.createExecutorContext)(graph, buildableProjectConfig.targets, parsed.project, parsed.target, parsed.target);
|
|
141
157
|
const { normalizeOptions, } = require('@nx/webpack/src/executors/webpack/lib/normalize-options');
|
|
142
158
|
const { resolveUserDefinedWebpackConfig, } = require('@nx/webpack/src/utils/webpack/resolve-user-defined-webpack-config');
|
|
@@ -152,7 +168,7 @@ function buildTargetWebpack(ctx, buildTarget, componentTestingProjectName) {
|
|
|
152
168
|
}
|
|
153
169
|
return async () => {
|
|
154
170
|
customWebpack = await customWebpack;
|
|
155
|
-
// TODO(
|
|
171
|
+
// TODO(v19): Once webpackConfig is always set in @nx/webpack:webpack and isolatedConfig is removed, we no longer need this default.
|
|
156
172
|
const configure = composePluginsSync(withNx(), withWeb());
|
|
157
173
|
const defaultWebpack = configure({}, {
|
|
158
174
|
options: {
|
|
@@ -197,3 +213,10 @@ function findTsConfig(projectRoot) {
|
|
|
197
213
|
}
|
|
198
214
|
}
|
|
199
215
|
}
|
|
216
|
+
class InvalidExecutorError extends Error {
|
|
217
|
+
constructor(message) {
|
|
218
|
+
super(message);
|
|
219
|
+
this.message = message;
|
|
220
|
+
this.name = 'InvalidExecutorError';
|
|
221
|
+
}
|
|
222
|
+
}
|
|
@@ -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) {
|
|
@@ -35,6 +36,7 @@ async function addLinting(host, options) {
|
|
|
35
36
|
skipFormat: true,
|
|
36
37
|
rootProject: options.rootProject,
|
|
37
38
|
skipPackageJson: options.skipPackageJson,
|
|
39
|
+
addPlugin: options.addPlugin,
|
|
38
40
|
});
|
|
39
41
|
tasks.push(lintTask);
|
|
40
42
|
if ((0, eslint_file_1.isEslintConfigSupported)(host)) {
|
|
@@ -50,6 +52,7 @@ async function addLinting(host, options) {
|
|
|
50
52
|
}
|
|
51
53
|
async function applicationGenerator(host, schema) {
|
|
52
54
|
return await applicationGeneratorInternal(host, {
|
|
55
|
+
addPlugin: false,
|
|
53
56
|
projectNameAndRootFormat: 'derived',
|
|
54
57
|
...schema,
|
|
55
58
|
});
|
|
@@ -75,6 +78,7 @@ async function applicationGeneratorInternal(host, schema) {
|
|
|
75
78
|
const webpackInitTask = await webpackInitGenerator(host, {
|
|
76
79
|
skipPackageJson: options.skipPackageJson,
|
|
77
80
|
skipFormat: true,
|
|
81
|
+
addPlugin: options.addPlugin,
|
|
78
82
|
});
|
|
79
83
|
tasks.push(webpackInitTask);
|
|
80
84
|
if (!options.skipPackageJson) {
|
|
@@ -102,6 +106,7 @@ async function applicationGeneratorInternal(host, schema) {
|
|
|
102
106
|
inSourceTests: options.inSourceTests,
|
|
103
107
|
compiler: options.compiler,
|
|
104
108
|
skipFormat: true,
|
|
109
|
+
addPlugin: options.addPlugin,
|
|
105
110
|
});
|
|
106
111
|
tasks.push(viteTask);
|
|
107
112
|
createOrEditViteConfig(host, {
|
|
@@ -142,6 +147,7 @@ async function applicationGeneratorInternal(host, schema) {
|
|
|
142
147
|
project: options.projectName,
|
|
143
148
|
inSourceTests: options.inSourceTests,
|
|
144
149
|
skipFormat: true,
|
|
150
|
+
addPlugin: options.addPlugin,
|
|
145
151
|
});
|
|
146
152
|
tasks.push(vitestTask);
|
|
147
153
|
createOrEditViteConfig(host, {
|
|
@@ -208,6 +214,9 @@ async function applicationGeneratorInternal(host, schema) {
|
|
|
208
214
|
if (!options.skipFormat) {
|
|
209
215
|
await (0, devkit_1.formatFiles)(host);
|
|
210
216
|
}
|
|
217
|
+
tasks.push(() => {
|
|
218
|
+
(0, log_show_project_command_1.logShowProjectCommand)(options.projectName);
|
|
219
|
+
});
|
|
211
220
|
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
212
221
|
}
|
|
213
222
|
exports.applicationGeneratorInternal = applicationGeneratorInternal;
|
|
@@ -795,6 +795,25 @@ export function NxWelcome({ title }: { title: string }) {
|
|
|
795
795
|
nx g @nx/react:component ui/src/lib/button
|
|
796
796
|
</pre>
|
|
797
797
|
</details>
|
|
798
|
+
<details>
|
|
799
|
+
<summary>
|
|
800
|
+
<svg
|
|
801
|
+
fill="none"
|
|
802
|
+
stroke="currentColor"
|
|
803
|
+
viewBox="0 0 24 24"
|
|
804
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
805
|
+
>
|
|
806
|
+
<path
|
|
807
|
+
strokeLinecap="round"
|
|
808
|
+
strokeLinejoin="round"
|
|
809
|
+
strokeWidth="2"
|
|
810
|
+
d="M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"
|
|
811
|
+
/>
|
|
812
|
+
</svg>
|
|
813
|
+
View project details
|
|
814
|
+
</summary>
|
|
815
|
+
<pre>nx show project {title} --web</pre>
|
|
816
|
+
</details>
|
|
798
817
|
<details>
|
|
799
818
|
<summary>
|
|
800
819
|
<svg
|
|
@@ -68,6 +68,7 @@ async function addE2e(tree, options) {
|
|
|
68
68
|
webServerCommand: `${(0, devkit_1.getPackageManagerCommand)().exec} nx serve ${options.name}`,
|
|
69
69
|
webServerAddress: 'http://localhost:4200',
|
|
70
70
|
rootProject: options.rootProject,
|
|
71
|
+
addPlugin: options.addPlugin,
|
|
71
72
|
});
|
|
72
73
|
}
|
|
73
74
|
case 'none':
|
|
@@ -12,7 +12,7 @@ function addProject(host, options) {
|
|
|
12
12
|
tags: options.parsedTags,
|
|
13
13
|
};
|
|
14
14
|
if (options.bundler === 'webpack') {
|
|
15
|
-
if (!(0, has_webpack_plugin_1.hasWebpackPlugin)(host)) {
|
|
15
|
+
if (!(0, has_webpack_plugin_1.hasWebpackPlugin)(host) || !options.addPlugin) {
|
|
16
16
|
project.targets = {
|
|
17
17
|
build: createBuildTarget(options),
|
|
18
18
|
serve: createServeTarget(options),
|
|
@@ -26,6 +26,7 @@ async function normalizeOptions(host, options, callingGenerator = '@nx/react:app
|
|
|
26
26
|
rootProject: options.rootProject,
|
|
27
27
|
callingGenerator,
|
|
28
28
|
});
|
|
29
|
+
options.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';
|
|
29
30
|
options.rootProject = appProjectRoot === '.';
|
|
30
31
|
options.projectNameAndRootFormat = projectNameAndRootFormat;
|
|
31
32
|
const e2eProjectName = options.rootProject ? 'e2e' : `${appProjectName}-e2e`;
|
|
@@ -28,6 +28,7 @@ export interface Schema {
|
|
|
28
28
|
rootProject?: boolean;
|
|
29
29
|
bundler?: 'webpack' | 'vite' | 'rspack';
|
|
30
30
|
minimal?: boolean;
|
|
31
|
+
addPlugin?: boolean;
|
|
31
32
|
}
|
|
32
33
|
|
|
33
34
|
export interface NormalizedSchema<T extends Schema = Schema> extends T {
|
|
@@ -40,4 +41,5 @@ export interface NormalizedSchema<T extends Schema = Schema> extends T {
|
|
|
40
41
|
styledModule: null | SupportedStyles;
|
|
41
42
|
hasStyles: boolean;
|
|
42
43
|
unitTestRunner: 'jest' | 'vitest' | 'none';
|
|
44
|
+
addPlugin?: boolean;
|
|
43
45
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$schema": "
|
|
2
|
+
"$schema": "https://json-schema.org/schema",
|
|
3
3
|
"cli": "nx",
|
|
4
4
|
"$id": "NxReactApp",
|
|
5
5
|
"title": "Create a React Application",
|
|
@@ -56,11 +56,11 @@
|
|
|
56
56
|
},
|
|
57
57
|
{
|
|
58
58
|
"value": "scss",
|
|
59
|
-
"label": "SASS(.scss) [
|
|
59
|
+
"label": "SASS(.scss) [ https://sass-lang.com ]"
|
|
60
60
|
},
|
|
61
61
|
{
|
|
62
62
|
"value": "less",
|
|
63
|
-
"label": "LESS [
|
|
63
|
+
"label": "LESS [ https://lesscss.org ]"
|
|
64
64
|
},
|
|
65
65
|
{
|
|
66
66
|
"value": "styled-components",
|
|
@@ -3,7 +3,7 @@ import { SupportedStyles } from '../../../typings/style';
|
|
|
3
3
|
export interface Schema {
|
|
4
4
|
name: string;
|
|
5
5
|
/**
|
|
6
|
-
* @deprecated Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx
|
|
6
|
+
* @deprecated Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx v19.
|
|
7
7
|
*/
|
|
8
8
|
project?: string;
|
|
9
9
|
style: SupportedStyles;
|
|
@@ -11,18 +11,18 @@ export interface Schema {
|
|
|
11
11
|
directory?: string;
|
|
12
12
|
export?: boolean;
|
|
13
13
|
/**
|
|
14
|
-
* @deprecated Provide the `name` in pascal-case and use the `as-provided` format. This option will be removed in Nx
|
|
14
|
+
* @deprecated Provide the `name` in pascal-case and use the `as-provided` format. This option will be removed in Nx v19.
|
|
15
15
|
*/
|
|
16
16
|
pascalCaseFiles?: boolean;
|
|
17
17
|
/**
|
|
18
|
-
* @deprecated Provide the `directory` in pascal-case and use the `as-provided` format. This option will be removed in Nx
|
|
18
|
+
* @deprecated Provide the `directory` in pascal-case and use the `as-provided` format. This option will be removed in Nx v19.
|
|
19
19
|
*/
|
|
20
20
|
pascalCaseDirectory?: boolean;
|
|
21
21
|
classComponent?: boolean;
|
|
22
22
|
routing?: boolean;
|
|
23
23
|
js?: boolean;
|
|
24
24
|
/**
|
|
25
|
-
* @deprecated Provide the `directory` option instead and use the `as-provided` format. This option will be removed in Nx
|
|
25
|
+
* @deprecated Provide the `directory` option instead and use the `as-provided` format. This option will be removed in Nx v19.
|
|
26
26
|
*/
|
|
27
27
|
flat?: boolean;
|
|
28
28
|
globalCss?: boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$schema": "
|
|
2
|
+
"$schema": "https://json-schema.org/schema",
|
|
3
3
|
"cli": "nx",
|
|
4
4
|
"$id": "NxReactComponent",
|
|
5
5
|
"title": "Create a React Component",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"$default": {
|
|
14
14
|
"$source": "projectName"
|
|
15
15
|
},
|
|
16
|
-
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx
|
|
16
|
+
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx v19."
|
|
17
17
|
},
|
|
18
18
|
"name": {
|
|
19
19
|
"type": "string",
|
|
@@ -40,11 +40,11 @@
|
|
|
40
40
|
},
|
|
41
41
|
{
|
|
42
42
|
"value": "scss",
|
|
43
|
-
"label": "SASS(.scss) [
|
|
43
|
+
"label": "SASS(.scss) [ https://sass-lang.com ]"
|
|
44
44
|
},
|
|
45
45
|
{
|
|
46
46
|
"value": "less",
|
|
47
|
-
"label": "LESS [
|
|
47
|
+
"label": "LESS [ https://lesscss.org ]"
|
|
48
48
|
},
|
|
49
49
|
{
|
|
50
50
|
"value": "styled-components",
|
|
@@ -91,7 +91,7 @@
|
|
|
91
91
|
"type": "boolean",
|
|
92
92
|
"description": "Create component at the source root rather than its own directory.",
|
|
93
93
|
"default": false,
|
|
94
|
-
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. This option will be removed in Nx
|
|
94
|
+
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. This option will be removed in Nx v19."
|
|
95
95
|
},
|
|
96
96
|
"export": {
|
|
97
97
|
"type": "boolean",
|
|
@@ -105,14 +105,14 @@
|
|
|
105
105
|
"description": "Use pascal case component file name (e.g. `App.tsx`).",
|
|
106
106
|
"alias": "P",
|
|
107
107
|
"default": false,
|
|
108
|
-
"x-deprecated": "Provide the `name` in pascal-case and use the `as-provided` format. This option will be removed in Nx
|
|
108
|
+
"x-deprecated": "Provide the `name` in pascal-case and use the `as-provided` format. This option will be removed in Nx v19."
|
|
109
109
|
},
|
|
110
110
|
"pascalCaseDirectory": {
|
|
111
111
|
"type": "boolean",
|
|
112
112
|
"description": "Use pascal case directory name (e.g. `App/App.tsx`).",
|
|
113
113
|
"alias": "R",
|
|
114
114
|
"default": false,
|
|
115
|
-
"x-deprecated": "Provide the `directory` in pascal-case and use the `as-provided` format. This option will be removed in Nx
|
|
115
|
+
"x-deprecated": "Provide the `directory` in pascal-case and use the `as-provided` format. This option will be removed in Nx v19."
|
|
116
116
|
},
|
|
117
117
|
"classComponent": {
|
|
118
118
|
"type": "boolean",
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { Tree } from '@nx/devkit';
|
|
2
2
|
import { CypressComponentConfigurationSchema } from './schema.d';
|
|
3
|
+
export declare function cypressComponentConfigGenerator(tree: Tree, options: CypressComponentConfigurationSchema): Promise<import("@nx/devkit").GeneratorCallback>;
|
|
3
4
|
/**
|
|
4
5
|
* This is for using cypresses own Component testing, if you want to use test
|
|
5
6
|
* storybook components then use componentCypressGenerator instead.
|
|
6
7
|
*
|
|
7
8
|
*/
|
|
8
|
-
export declare function
|
|
9
|
+
export declare function cypressComponentConfigGeneratorInternal(tree: Tree, options: CypressComponentConfigurationSchema): Promise<import("@nx/devkit").GeneratorCallback>;
|
|
9
10
|
export default cypressComponentConfigGenerator;
|
|
@@ -1,26 +1,36 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.cypressComponentConfigGenerator = void 0;
|
|
3
|
+
exports.cypressComponentConfigGeneratorInternal = exports.cypressComponentConfigGenerator = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const versions_1 = require("../../utils/versions");
|
|
6
6
|
const add_files_1 = require("./lib/add-files");
|
|
7
7
|
const ct_utils_1 = require("../../utils/ct-utils");
|
|
8
|
+
function cypressComponentConfigGenerator(tree, options) {
|
|
9
|
+
return cypressComponentConfigGeneratorInternal(tree, {
|
|
10
|
+
addPlugin: false,
|
|
11
|
+
...options,
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
exports.cypressComponentConfigGenerator = cypressComponentConfigGenerator;
|
|
8
15
|
/**
|
|
9
16
|
* This is for using cypresses own Component testing, if you want to use test
|
|
10
17
|
* storybook components then use componentCypressGenerator instead.
|
|
11
18
|
*
|
|
12
19
|
*/
|
|
13
|
-
async function
|
|
20
|
+
async function cypressComponentConfigGeneratorInternal(tree, options) {
|
|
14
21
|
const { componentConfigurationGenerator: baseCyCtConfig } = (0, devkit_1.ensurePackage)('@nx/cypress', versions_1.nxVersion);
|
|
22
|
+
options.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';
|
|
15
23
|
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.project);
|
|
16
24
|
const installTask = await baseCyCtConfig(tree, {
|
|
17
25
|
project: options.project,
|
|
18
26
|
skipFormat: true,
|
|
19
27
|
jsx: true,
|
|
28
|
+
addPlugin: options.addPlugin,
|
|
20
29
|
});
|
|
21
|
-
const found = await (0, ct_utils_1.
|
|
30
|
+
const found = await (0, ct_utils_1.configureCypressCT)(tree, {
|
|
22
31
|
project: options.project,
|
|
23
32
|
buildTarget: options.buildTarget,
|
|
33
|
+
bundler: options.bundler,
|
|
24
34
|
validExecutorNames: new Set([
|
|
25
35
|
'@nx/webpack:webpack',
|
|
26
36
|
'@nx/vite:build',
|
|
@@ -34,5 +44,5 @@ async function cypressComponentConfigGenerator(tree, options) {
|
|
|
34
44
|
}
|
|
35
45
|
return installTask;
|
|
36
46
|
}
|
|
37
|
-
exports.
|
|
47
|
+
exports.cypressComponentConfigGeneratorInternal = cypressComponentConfigGeneratorInternal;
|
|
38
48
|
exports.default = cypressComponentConfigGenerator;
|
|
@@ -10,9 +10,7 @@ async function addFiles(tree, projectConfig, options, found) {
|
|
|
10
10
|
// when importing react
|
|
11
11
|
const { addMountDefinition, addDefaultCTConfig } = await Promise.resolve().then(() => require('@nx/cypress/src/utils/config'));
|
|
12
12
|
// Specifically undefined to allow Remix workaround of passing an empty string
|
|
13
|
-
const actualBundler =
|
|
14
|
-
? options.bundler
|
|
15
|
-
: await (0, ct_utils_1.getBundlerFromTarget)(found, tree);
|
|
13
|
+
const actualBundler = await (0, ct_utils_1.getActualBundler)(tree, options, found);
|
|
16
14
|
if (options.bundler && options.bundler !== actualBundler) {
|
|
17
15
|
devkit_1.logger.warn(`You have specified ${options.bundler} as the bundler but this project is configured to use ${actualBundler}.
|
|
18
16
|
This may cause errors. If you are seeing errors, try removing the --bundler option.`);
|
|
@@ -21,9 +19,6 @@ async function addFiles(tree, projectConfig, options, found) {
|
|
|
21
19
|
const commandFile = (0, devkit_1.joinPathFragments)(projectConfig.root, 'cypress', 'support', 'component.ts');
|
|
22
20
|
const updatedCommandFile = await addMountDefinition(tree.read(commandFile, 'utf-8'));
|
|
23
21
|
tree.write(commandFile, `import { mount } from 'cypress/react18';\n${updatedCommandFile}`);
|
|
24
|
-
const cyFile = (0, devkit_1.joinPathFragments)(projectConfig.root, 'cypress.config.ts');
|
|
25
|
-
const updatedCyConfig = await addDefaultCTConfig(tree.read(cyFile, 'utf-8'), { bundler: bundlerToUse });
|
|
26
|
-
tree.write(cyFile, `import { nxComponentTestingPreset } from '@nx/react/plugins/component-testing';\n${updatedCyConfig}`);
|
|
27
22
|
if (options.bundler === 'webpack' ||
|
|
28
23
|
(!options.bundler && actualBundler === 'webpack')) {
|
|
29
24
|
(0, devkit_1.addDependenciesToPackageJson)(tree, {}, { '@nx/webpack': versions_1.nxVersion });
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
export interface Schema {
|
|
2
2
|
name: string;
|
|
3
3
|
/**
|
|
4
|
-
* @deprecated Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx
|
|
4
|
+
* @deprecated Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx v19.
|
|
5
5
|
*/
|
|
6
6
|
project: string;
|
|
7
7
|
skipTests?: boolean;
|
|
8
8
|
directory?: string;
|
|
9
9
|
export?: boolean;
|
|
10
10
|
/**
|
|
11
|
-
* @deprecated Provide the `name` option instead and use the `as-provided` format. This option will be removed in Nx
|
|
11
|
+
* @deprecated Provide the `name` option instead and use the `as-provided` format. This option will be removed in Nx v19.
|
|
12
12
|
*/
|
|
13
13
|
pascalCaseFiles?: boolean;
|
|
14
14
|
/**
|
|
15
|
-
* @deprecated Provide the `directory` option instead and use the `as-provided` format. This option will be removed in Nx
|
|
15
|
+
* @deprecated Provide the `directory` option instead and use the `as-provided` format. This option will be removed in Nx v19.
|
|
16
16
|
*/
|
|
17
17
|
pascalCaseDirectory?: boolean;
|
|
18
18
|
/**
|
|
19
|
-
* @deprecated Provide the `directory` option instead and use the `as-provided` format. This option will be removed in Nx
|
|
19
|
+
* @deprecated Provide the `directory` option instead and use the `as-provided` format. This option will be removed in Nx v19.
|
|
20
20
|
*/
|
|
21
21
|
flat?: boolean;
|
|
22
22
|
js?: boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$schema": "
|
|
2
|
+
"$schema": "https://json-schema.org/schema",
|
|
3
3
|
"cli": "nx",
|
|
4
4
|
"$id": "NxReactHook",
|
|
5
5
|
"title": "Create a React Hook for Nx",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"$default": {
|
|
20
20
|
"$source": "projectName"
|
|
21
21
|
},
|
|
22
|
-
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx
|
|
22
|
+
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx v19."
|
|
23
23
|
},
|
|
24
24
|
"name": {
|
|
25
25
|
"type": "string",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"type": "boolean",
|
|
57
57
|
"description": "Create hook at the source root rather than its own directory.",
|
|
58
58
|
"default": false,
|
|
59
|
-
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx
|
|
59
|
+
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v19."
|
|
60
60
|
},
|
|
61
61
|
"export": {
|
|
62
62
|
"type": "boolean",
|
|
@@ -70,14 +70,14 @@
|
|
|
70
70
|
"description": "Use pascal case hook file name (e.g. `useHook.ts`).",
|
|
71
71
|
"alias": "P",
|
|
72
72
|
"default": false,
|
|
73
|
-
"x-deprecated": "Provide the `name` in pascal-case and use the `as-provided` format. This option will be removed in Nx
|
|
73
|
+
"x-deprecated": "Provide the `name` in pascal-case and use the `as-provided` format. This option will be removed in Nx v19."
|
|
74
74
|
},
|
|
75
75
|
"pascalCaseDirectory": {
|
|
76
76
|
"type": "boolean",
|
|
77
77
|
"description": "Use pascal case directory name (e.g. `useHook/useHook.ts`).",
|
|
78
78
|
"alias": "R",
|
|
79
79
|
"default": false,
|
|
80
|
-
"x-deprecated": "Provide the `directory` in pascal-case and use the `as-provided` format. This option will be removed in Nx
|
|
80
|
+
"x-deprecated": "Provide the `directory` in pascal-case and use the `as-provided` format. This option will be removed in Nx v19."
|
|
81
81
|
}
|
|
82
82
|
},
|
|
83
83
|
"required": ["name"]
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { composePlugins, withNx } from '@nx/webpack';
|
|
2
2
|
import { withReact } from '@nx/react';
|
|
3
3
|
import { withModuleFederation } from '@nx/react/module-federation';
|
|
4
|
+
import { ModuleFederationConfig } from '@nx/webpack';
|
|
4
5
|
|
|
5
6
|
import baseConfig from './module-federation.config';
|
|
6
7
|
|
|
7
|
-
const prodConfig = {
|
|
8
|
+
const prodConfig: ModuleFederationConfig = {
|
|
8
9
|
...baseConfig,
|
|
9
10
|
/*
|
|
10
11
|
* Remote overrides for production.
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {composePlugins, withNx} from '@nx/webpack';
|
|
1
|
+
import {composePlugins, withNx, ModuleFederationConfig} from '@nx/webpack';
|
|
2
2
|
import {withReact} from '@nx/react';
|
|
3
3
|
import {withModuleFederation} from '@nx/react/module-federation';
|
|
4
4
|
|
|
5
5
|
import baseConfig from './module-federation.config';
|
|
6
6
|
|
|
7
|
-
const config = {
|
|
7
|
+
const config: ModuleFederationConfig = {
|
|
8
8
|
...baseConfig,
|
|
9
9
|
};
|
|
10
10
|
|
|
@@ -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',
|
|
@@ -24,6 +25,8 @@ async function hostGeneratorInternal(host, schema) {
|
|
|
24
25
|
...(await (0, normalize_options_1.normalizeOptions)(host, schema, '@nx/react:host')),
|
|
25
26
|
typescriptConfiguration: schema.typescriptConfiguration ?? true,
|
|
26
27
|
dynamic: schema.dynamic ?? false,
|
|
28
|
+
// TODO(colum): remove when MF works with Crystal
|
|
29
|
+
addPlugin: false,
|
|
27
30
|
};
|
|
28
31
|
const initTask = await (0, application_1.default)(host, {
|
|
29
32
|
...options,
|
|
@@ -78,6 +81,7 @@ async function hostGeneratorInternal(host, schema) {
|
|
|
78
81
|
if (!options.setParserOptionsProject) {
|
|
79
82
|
host.delete((0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.lint.json'));
|
|
80
83
|
}
|
|
84
|
+
(0, add_mf_env_to_inputs_1.addMfEnvToTargetDefaultInputs)(host);
|
|
81
85
|
if (!options.skipFormat) {
|
|
82
86
|
await (0, devkit_1.formatFiles)(host);
|
|
83
87
|
}
|