@nx/react 17.0.5 → 17.0.6
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 +4 -9
- package/generators.json +1 -1
- package/index.d.ts +0 -1
- package/index.js +1 -3
- package/migrations.json +0 -21
- package/package.json +7 -7
- package/plugins/component-testing/index.js +24 -52
- package/plugins/component-testing/webpack-fallback.js +1 -1
- package/plugins/storybook/index.js +2 -6
- package/plugins/storybook/merge-plugins.d.ts +1 -1
- package/plugins/webpack.d.ts +3 -1
- package/plugins/webpack.js +11 -3
- package/plugins/with-react.d.ts +4 -2
- package/plugins/with-react.js +58 -2
- package/src/executors/module-federation-dev-server/module-federation-dev-server.impl.d.ts +0 -13
- package/src/executors/module-federation-dev-server/module-federation-dev-server.impl.js +58 -173
- package/src/executors/module-federation-dev-server/schema.json +1 -13
- package/src/generators/application/application.js +18 -41
- package/src/generators/application/files/base-vite/index.html__tmpl__ +1 -1
- package/src/generators/application/files/base-webpack/src/environments/environment.prod.ts__tmpl__ +3 -0
- package/src/generators/application/files/base-webpack/src/environments/environment.ts__tmpl__ +6 -0
- package/src/generators/application/files/base-webpack/src/index.html +2 -0
- package/src/generators/application/files/base-webpack/webpack.config.js__tmpl__ +5 -46
- package/src/generators/application/files/nx-welcome/src/app/nx-welcome.tsx +13 -54
- package/src/generators/application/lib/add-e2e.js +7 -25
- package/src/generators/application/lib/add-jest.js +2 -2
- package/src/generators/application/lib/add-project.d.ts +2 -2
- package/src/generators/application/lib/add-project.js +15 -12
- package/src/generators/application/lib/add-routing.d.ts +1 -1
- package/src/generators/application/lib/add-routing.js +8 -4
- package/src/generators/application/lib/create-application-files.js +1 -30
- package/src/generators/application/lib/install-common-dependencies.js +1 -15
- package/src/generators/application/lib/normalize-options.js +1 -35
- package/src/generators/application/lib/set-defaults.js +0 -1
- package/src/generators/application/lib/update-jest-config.js +8 -8
- package/src/generators/application/schema.d.ts +0 -5
- package/src/generators/application/schema.json +3 -7
- package/src/generators/component/files/__fileName__.tsx__tmpl__ +22 -39
- package/src/generators/component/lib/normalize-options.js +2 -4
- package/src/generators/component/schema.d.ts +4 -6
- 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 +1 -2
- package/src/generators/cypress-component-configuration/cypress-component-configuration.js +7 -18
- package/src/generators/cypress-component-configuration/lib/add-files.js +6 -1
- package/src/generators/cypress-component-configuration/schema.d.ts +0 -1
- package/src/generators/federate-module/federate-module.js +2 -2
- package/src/generators/federate-module/schema.d.ts +1 -1
- package/src/generators/federate-module/schema.json +3 -4
- package/src/generators/hook/files/__fileName__.ts__tmpl__ +15 -15
- package/src/generators/hook/schema.d.ts +4 -4
- package/src/generators/hook/schema.json +5 -5
- package/src/generators/host/files/module-federation/module-federation.config.js__tmpl__ +2 -17
- package/src/generators/host/files/module-federation/src/main.ts__tmpl__ +1 -0
- package/src/generators/host/files/module-federation-ssr/module-federation.server.config.js__tmpl__ +2 -5
- package/src/generators/host/files/module-federation-ssr-ts/module-federation.server.config.ts__tmpl__ +2 -5
- package/src/generators/host/files/module-federation-ts/module-federation.config.ts__tmpl__ +2 -17
- package/src/generators/host/files/module-federation-ts/src/main.ts__tmpl__ +1 -0
- package/src/generators/host/files/module-federation-ts/webpack.config.prod.ts__tmpl__ +1 -2
- package/src/generators/host/files/module-federation-ts/webpack.config.ts__tmpl__ +2 -2
- package/src/generators/host/host.js +1 -15
- package/src/generators/host/lib/add-module-federation-files.d.ts +1 -2
- package/src/generators/host/lib/add-module-federation-files.js +11 -24
- package/src/generators/host/lib/setup-ssr-for-host.js +0 -1
- package/src/generators/host/lib/update-module-federation-e2e-project.js +5 -7
- package/src/generators/host/schema.d.ts +2 -5
- package/src/generators/host/schema.json +6 -16
- package/src/generators/init/init.d.ts +1 -1
- package/src/generators/init/init.js +49 -10
- package/src/generators/init/schema.d.ts +6 -1
- package/src/generators/init/schema.json +22 -5
- package/src/generators/library/lib/add-linting.js +2 -2
- package/src/generators/library/lib/add-rollup-build-target.d.ts +1 -2
- package/src/generators/library/lib/add-rollup-build-target.js +8 -16
- package/src/generators/library/lib/install-common-dependencies.js +5 -13
- package/src/generators/library/lib/maybe-js.d.ts +2 -0
- package/src/generators/library/lib/normalize-options.js +5 -34
- package/src/generators/library/lib/update-app-routes.js +1 -1
- package/src/generators/library/library.js +6 -17
- package/src/generators/library/schema.d.ts +0 -1
- 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/files/module-federation/module-federation.config.js__tmpl__ +1 -4
- package/src/generators/remote/files/module-federation-ssr/module-federation.server.config.js__tmpl__ +1 -1
- package/src/generators/remote/files/module-federation-ssr-ts/module-federation.server.config.ts__tmpl__ +1 -1
- package/src/generators/remote/files/module-federation-ts/module-federation.config.ts__tmpl__ +1 -4
- package/src/generators/remote/lib/setup-ssr-for-remote.js +1 -5
- package/src/generators/remote/lib/setup-tspath-for-remote.js +1 -2
- package/src/generators/remote/lib/update-host-with-remote.js +1 -10
- package/src/generators/remote/remote.js +2 -22
- package/src/generators/remote/schema.d.ts +2 -3
- package/src/generators/remote/schema.json +6 -17
- package/src/generators/setup-ssr/schema.json +1 -1
- package/src/generators/setup-ssr/setup-ssr.js +7 -23
- package/src/generators/setup-tailwind/schema.json +1 -1
- package/src/generators/stories/schema.json +1 -1
- package/src/generators/stories/stories.js +5 -17
- package/src/generators/storybook-configuration/configuration.d.ts +0 -2
- package/src/generators/storybook-configuration/configuration.js +15 -37
- package/src/generators/storybook-configuration/schema.d.ts +1 -2
- package/src/generators/storybook-configuration/schema.json +7 -7
- package/src/module-federation/ast-utils.js +1 -1
- package/src/module-federation/utils.js +1 -8
- package/src/module-federation/with-module-federation-ssr.js +0 -3
- package/src/module-federation/with-module-federation.d.ts +3 -3
- package/src/module-federation/with-module-federation.js +4 -14
- package/src/rules/update-module-federation-project.d.ts +0 -2
- package/src/rules/update-module-federation-project.js +3 -12
- package/src/utils/assertion.js +0 -1
- package/src/utils/ct-utils.d.ts +1 -6
- package/src/utils/ct-utils.js +9 -39
- package/src/utils/get-in-source-vitest-tests-template.js +1 -1
- package/src/utils/versions.d.ts +1 -1
- package/src/utils/versions.js +1 -1
- package/typings/style.d.ts +0 -1
- package/mf/dynamic-federation.d.ts +0 -4
- package/mf/dynamic-federation.js +0 -75
- package/mf/index.d.ts +0 -1
- package/mf/index.js +0 -7
- package/plugins/nx-react-webpack-plugin/lib/apply-react-config.d.ts +0 -4
- package/plugins/nx-react-webpack-plugin/lib/apply-react-config.js +0 -86
- package/plugins/nx-react-webpack-plugin/nx-react-webpack-plugin.d.ts +0 -8
- package/plugins/nx-react-webpack-plugin/nx-react-webpack-plugin.js +0 -13
- package/src/generators/application/files/style-tailwind/src/app/__fileName__.tsx__tmpl__ +0 -33
- package/src/generators/application/files/style-tailwind/src/styles.css +0 -1
- package/src/generators/host/files/common/src/main.js__tmpl__ +0 -10
- package/src/generators/host/files/common/tsconfig.lint.json__tmpl__ +0 -19
- package/src/generators/host/files/common-ts/src/app/__fileName__.tsx__tmpl__ +0 -41
- package/src/generators/host/files/common-ts/src/main.ts__tmpl__ +0 -10
- package/src/generators/remote/files/module-federation-ssr-ts/tsconfig.lint.json__tmpl__ +0 -19
- package/src/generators/remote/files/module-federation-ts/tsconfig.lint.json__tmpl__ +0 -19
- package/src/generators/remote/lib/add-remote-to-dynamic-host.d.ts +0 -2
- package/src/generators/remote/lib/add-remote-to-dynamic-host.js +0 -11
- package/src/migrations/update-18-0-0/add-mf-env-var-to-target-defaults.d.ts +0 -2
- package/src/migrations/update-18-0-0/add-mf-env-var-to-target-defaults.js +0 -26
- package/src/migrations/update-18-1-1/fix-target-defaults-inputs.d.ts +0 -2
- package/src/migrations/update-18-1-1/fix-target-defaults-inputs.js +0 -53
- package/src/utils/add-mf-env-to-inputs.d.ts +0 -2
- package/src/utils/add-mf-env-to-inputs.js +0 -27
- package/src/utils/has-vite-plugin.d.ts +0 -2
- package/src/utils/has-vite-plugin.js +0 -11
- package/src/utils/has-webpack-plugin.d.ts +0 -2
- package/src/utils/has-webpack-plugin.js +0 -11
- package/src/utils/maybe-js.d.ts +0 -3
- /package/src/generators/host/files/common/src/app/{__fileName__.js__tmpl__ → __fileName__.tsx__tmpl__} +0 -0
- /package/src/{utils → generators/library/lib}/maybe-js.js +0 -0
- /package/src/generators/remote/files/{common/src/main.js__tmpl__ → module-federation/src/main.ts__tmpl__} +0 -0
- /package/src/generators/remote/files/{common/src/remote-entry.js__tmpl__ → module-federation/src/remote-entry.ts__tmpl__} +0 -0
- /package/src/generators/remote/files/{common-ts → module-federation-ts}/src/main.ts__tmpl__ +0 -0
- /package/src/generators/remote/files/{common-ts → module-federation-ts}/src/remote-entry.ts__tmpl__ +0 -0
|
@@ -5,13 +5,11 @@ const devkit_1 = require("@nx/devkit");
|
|
|
5
5
|
function updateModuleFederationE2eProject(host, options) {
|
|
6
6
|
try {
|
|
7
7
|
let projectConfig = (0, devkit_1.readProjectConfiguration)(host, options.e2eProjectName);
|
|
8
|
-
|
|
9
|
-
projectConfig.targets.e2e.options
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
(0, devkit_1.updateProjectConfiguration)(host, options.e2eProjectName, projectConfig);
|
|
14
|
-
}
|
|
8
|
+
projectConfig.targets.e2e.options = {
|
|
9
|
+
...projectConfig.targets.e2e.options,
|
|
10
|
+
baseUrl: `http://localhost:${options.devServerPort}`,
|
|
11
|
+
};
|
|
12
|
+
(0, devkit_1.updateProjectConfiguration)(host, options.e2eProjectName, projectConfig);
|
|
15
13
|
}
|
|
16
14
|
catch {
|
|
17
15
|
// nothing
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ProjectNameAndRootFormat } from '@nx/devkit/src/generators/project-name-and-root-utils';
|
|
2
2
|
import type { Linter } from '@nx/eslint';
|
|
3
|
-
import type { SupportedStyles } from '../../../typings
|
|
3
|
+
import type { SupportedStyles } from '../../../typings';
|
|
4
4
|
|
|
5
5
|
export interface Schema {
|
|
6
6
|
classComponent?: boolean;
|
|
@@ -8,7 +8,7 @@ export interface Schema {
|
|
|
8
8
|
devServerPort?: number;
|
|
9
9
|
directory?: string;
|
|
10
10
|
projectNameAndRootFormat?: ProjectNameAndRootFormat;
|
|
11
|
-
e2eTestRunner: 'cypress' | '
|
|
11
|
+
e2eTestRunner: 'cypress' | 'none';
|
|
12
12
|
globalCss?: boolean;
|
|
13
13
|
js?: boolean;
|
|
14
14
|
linter: Linter;
|
|
@@ -25,13 +25,10 @@ export interface Schema {
|
|
|
25
25
|
unitTestRunner: 'jest' | 'vitest' | 'none';
|
|
26
26
|
minimal?: boolean;
|
|
27
27
|
typescriptConfiguration?: boolean;
|
|
28
|
-
dynamic?: boolean;
|
|
29
|
-
addPlugin?: boolean;
|
|
30
28
|
}
|
|
31
29
|
|
|
32
30
|
export interface NormalizedSchema extends Schema {
|
|
33
31
|
appProjectRoot: string;
|
|
34
32
|
e2eProjectName: string;
|
|
35
33
|
projectName: string;
|
|
36
|
-
addPlugin?: boolean;
|
|
37
34
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$schema": "
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
3
|
"$id": "GeneratorReactHost",
|
|
4
4
|
"cli": "nx",
|
|
5
5
|
"title": "Generate Module Federation Setup for React Host App",
|
|
@@ -43,15 +43,11 @@
|
|
|
43
43
|
},
|
|
44
44
|
{
|
|
45
45
|
"value": "scss",
|
|
46
|
-
"label": "SASS(.scss) [
|
|
46
|
+
"label": "SASS(.scss) [ http://sass-lang.com ]"
|
|
47
47
|
},
|
|
48
48
|
{
|
|
49
49
|
"value": "less",
|
|
50
|
-
"label": "LESS [
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
"value": "tailwind",
|
|
54
|
-
"label": "tailwind [ https://tailwindcss.com/ ]"
|
|
50
|
+
"label": "LESS [ http://lesscss.org ]"
|
|
55
51
|
},
|
|
56
52
|
{
|
|
57
53
|
"value": "styled-components",
|
|
@@ -78,11 +74,6 @@
|
|
|
78
74
|
"enum": ["eslint"],
|
|
79
75
|
"default": "eslint"
|
|
80
76
|
},
|
|
81
|
-
"dynamic": {
|
|
82
|
-
"type": "boolean",
|
|
83
|
-
"description": "Should the host application use dynamic federation?",
|
|
84
|
-
"default": false
|
|
85
|
-
},
|
|
86
77
|
"skipFormat": {
|
|
87
78
|
"description": "Skip formatting files.",
|
|
88
79
|
"type": "boolean",
|
|
@@ -103,9 +94,8 @@
|
|
|
103
94
|
},
|
|
104
95
|
"e2eTestRunner": {
|
|
105
96
|
"type": "string",
|
|
106
|
-
"enum": ["cypress", "
|
|
107
|
-
"description": "Test runner to use for end to end (
|
|
108
|
-
"x-prompt": "Which E2E test runner would you like to use?",
|
|
97
|
+
"enum": ["cypress", "none"],
|
|
98
|
+
"description": "Test runner to use for end to end (e2e) tests.",
|
|
109
99
|
"default": "cypress"
|
|
110
100
|
},
|
|
111
101
|
"tags": {
|
|
@@ -175,7 +165,7 @@
|
|
|
175
165
|
},
|
|
176
166
|
"typescriptConfiguration": {
|
|
177
167
|
"type": "boolean",
|
|
178
|
-
"description": "Whether the module federation configuration and webpack configuration files should use TS.
|
|
168
|
+
"description": "Whether the module federation configuration and webpack configuration files should use TS.",
|
|
179
169
|
"default": true
|
|
180
170
|
}
|
|
181
171
|
},
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { GeneratorCallback, Tree } from '@nx/devkit';
|
|
2
2
|
import { InitSchema } from './schema';
|
|
3
3
|
export declare function reactInitGenerator(host: Tree, schema: InitSchema): Promise<GeneratorCallback>;
|
|
4
4
|
export default reactInitGenerator;
|
|
@@ -2,20 +2,59 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.reactInitGenerator = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const js_1 = require("@nx/js");
|
|
5
6
|
const versions_1 = require("../../utils/versions");
|
|
7
|
+
function setDefault(host) {
|
|
8
|
+
const workspace = (0, devkit_1.readNxJson)(host);
|
|
9
|
+
workspace.generators = workspace.generators || {};
|
|
10
|
+
const reactGenerators = workspace.generators['@nx/react'] || {};
|
|
11
|
+
const generators = {
|
|
12
|
+
...workspace.generators,
|
|
13
|
+
'@nx/react': {
|
|
14
|
+
...reactGenerators,
|
|
15
|
+
application: {
|
|
16
|
+
...reactGenerators.application,
|
|
17
|
+
babel: true,
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
(0, devkit_1.updateNxJson)(host, { ...workspace, generators });
|
|
22
|
+
}
|
|
23
|
+
function updateDependencies(host, schema) {
|
|
24
|
+
(0, devkit_1.removeDependenciesFromPackageJson)(host, ['@nx/react'], []);
|
|
25
|
+
const dependencies = {
|
|
26
|
+
react: versions_1.reactVersion,
|
|
27
|
+
'react-dom': versions_1.reactDomVersion,
|
|
28
|
+
};
|
|
29
|
+
if (!schema.skipHelperLibs) {
|
|
30
|
+
dependencies['tslib'] = versions_1.tsLibVersion;
|
|
31
|
+
}
|
|
32
|
+
return (0, devkit_1.addDependenciesToPackageJson)(host, dependencies, {
|
|
33
|
+
'@nx/react': versions_1.nxVersion,
|
|
34
|
+
'@types/node': versions_1.typesNodeVersion,
|
|
35
|
+
'@types/react': versions_1.typesReactVersion,
|
|
36
|
+
'@types/react-dom': versions_1.typesReactDomVersion,
|
|
37
|
+
'@testing-library/react': versions_1.testingLibraryReactVersion,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
6
40
|
async function reactInitGenerator(host, schema) {
|
|
7
41
|
const tasks = [];
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
42
|
+
const jsInitTask = await (0, js_1.initGenerator)(host, {
|
|
43
|
+
...schema,
|
|
44
|
+
tsConfigName: schema.rootProject ? 'tsconfig.json' : 'tsconfig.base.json',
|
|
45
|
+
skipFormat: true,
|
|
46
|
+
});
|
|
47
|
+
tasks.push(jsInitTask);
|
|
48
|
+
setDefault(host);
|
|
49
|
+
if (!schema.e2eTestRunner || schema.e2eTestRunner === 'cypress') {
|
|
50
|
+
(0, devkit_1.ensurePackage)('@nx/cypress', versions_1.nxVersion);
|
|
51
|
+
const { cypressInitGenerator } = await Promise.resolve().then(() => require('@nx/cypress/src/generators/init/init'));
|
|
52
|
+
const cypressTask = await cypressInitGenerator(host, {});
|
|
53
|
+
tasks.push(cypressTask);
|
|
16
54
|
}
|
|
17
|
-
if (!schema.
|
|
18
|
-
|
|
55
|
+
if (!schema.skipPackageJson) {
|
|
56
|
+
const installTask = updateDependencies(host, schema);
|
|
57
|
+
tasks.push(installTask);
|
|
19
58
|
}
|
|
20
59
|
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
21
60
|
}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
export interface InitSchema {
|
|
2
|
+
unitTestRunner?: 'jest' | 'vitest' | 'none';
|
|
3
|
+
e2eTestRunner?: 'cypress' | 'playwright' | 'none';
|
|
2
4
|
skipFormat?: boolean;
|
|
3
5
|
skipPackageJson?: boolean;
|
|
4
|
-
|
|
6
|
+
skipHelperLibs?: boolean;
|
|
7
|
+
js?: boolean;
|
|
8
|
+
|
|
9
|
+
rootProject?: boolean;
|
|
5
10
|
}
|
|
@@ -1,11 +1,23 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$schema": "
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
3
|
"$id": "NxReactNgInit",
|
|
4
4
|
"title": "Init React Plugin",
|
|
5
5
|
"description": "Initialize a React Plugin.",
|
|
6
6
|
"cli": "nx",
|
|
7
7
|
"type": "object",
|
|
8
8
|
"properties": {
|
|
9
|
+
"unitTestRunner": {
|
|
10
|
+
"description": "Adds the specified unit test runner.",
|
|
11
|
+
"type": "string",
|
|
12
|
+
"enum": ["jest", "none"],
|
|
13
|
+
"default": "jest"
|
|
14
|
+
},
|
|
15
|
+
"e2eTestRunner": {
|
|
16
|
+
"description": "Adds the specified E2E test runner.",
|
|
17
|
+
"type": "string",
|
|
18
|
+
"enum": ["cypress", "playwright", "none"],
|
|
19
|
+
"default": "cypress"
|
|
20
|
+
},
|
|
9
21
|
"skipFormat": {
|
|
10
22
|
"description": "Skip formatting files.",
|
|
11
23
|
"type": "boolean",
|
|
@@ -16,11 +28,16 @@
|
|
|
16
28
|
"type": "boolean",
|
|
17
29
|
"default": false
|
|
18
30
|
},
|
|
19
|
-
"
|
|
31
|
+
"skipHelperLibs": {
|
|
32
|
+
"description": "Do not install tslib.",
|
|
20
33
|
"type": "boolean",
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
|
|
34
|
+
"default": false,
|
|
35
|
+
"hidden": true
|
|
36
|
+
},
|
|
37
|
+
"js": {
|
|
38
|
+
"type": "boolean",
|
|
39
|
+
"default": false,
|
|
40
|
+
"description": "Use JavaScript instead of TypeScript"
|
|
24
41
|
}
|
|
25
42
|
},
|
|
26
43
|
"required": []
|
|
@@ -15,17 +15,17 @@ async function addLinting(host, options) {
|
|
|
15
15
|
(0, path_1.joinPathFragments)(options.projectRoot, 'tsconfig.lib.json'),
|
|
16
16
|
],
|
|
17
17
|
unitTestRunner: options.unitTestRunner,
|
|
18
|
+
eslintFilePatterns: [`${options.projectRoot}/**/*.{ts,tsx,js,jsx}`],
|
|
18
19
|
skipFormat: true,
|
|
19
20
|
skipPackageJson: options.skipPackageJson,
|
|
20
21
|
setParserOptionsProject: options.setParserOptionsProject,
|
|
21
|
-
addPlugin: options.addPlugin,
|
|
22
22
|
});
|
|
23
23
|
if ((0, eslint_file_1.isEslintConfigSupported)(host)) {
|
|
24
24
|
(0, eslint_file_1.addExtendsToLintConfig)(host, options.projectRoot, 'plugin:@nx/react');
|
|
25
25
|
}
|
|
26
26
|
let installTask = () => { };
|
|
27
27
|
if (!options.skipPackageJson) {
|
|
28
|
-
installTask = (0, devkit_1.addDependenciesToPackageJson)(host, lint_1.extraEslintDependencies.dependencies, lint_1.extraEslintDependencies.devDependencies);
|
|
28
|
+
installTask = await (0, devkit_1.addDependenciesToPackageJson)(host, lint_1.extraEslintDependencies.dependencies, lint_1.extraEslintDependencies.devDependencies);
|
|
29
29
|
}
|
|
30
30
|
return (0, devkit_1.runTasksInSerial)(lintTask, installTask);
|
|
31
31
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import { Tree } from 'nx/src/generators/tree';
|
|
2
|
-
import { GeneratorCallback } from '@nx/devkit';
|
|
3
2
|
import { NormalizedSchema } from '../schema';
|
|
4
|
-
export declare function addRollupBuildTarget(host: Tree, options: NormalizedSchema): Promise<GeneratorCallback>;
|
|
3
|
+
export declare function addRollupBuildTarget(host: Tree, options: NormalizedSchema): Promise<import("@nx/devkit").GeneratorCallback>;
|
|
@@ -2,23 +2,15 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.addRollupBuildTarget = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const maybe_js_1 = require("
|
|
5
|
+
const maybe_js_1 = require("./maybe-js");
|
|
6
6
|
const versions_1 = require("../../../utils/versions");
|
|
7
7
|
async function addRollupBuildTarget(host, options) {
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}));
|
|
15
|
-
if (!options.skipPackageJson) {
|
|
16
|
-
// These are used in `@nx/react/plugins/bundle-rollup`
|
|
17
|
-
tasks.push((0, devkit_1.addDependenciesToPackageJson)(host, {}, {
|
|
18
|
-
'@rollup/plugin-url': versions_1.rollupPluginUrlVersion,
|
|
19
|
-
'@svgr/rollup': versions_1.svgrRollupVersion,
|
|
20
|
-
}));
|
|
21
|
-
}
|
|
8
|
+
const { rollupInitGenerator } = (0, devkit_1.ensurePackage)('@nx/rollup', versions_1.nxVersion);
|
|
9
|
+
// These are used in `@nx/react/plugins/bundle-rollup`
|
|
10
|
+
(0, devkit_1.addDependenciesToPackageJson)(host, {}, {
|
|
11
|
+
'@rollup/plugin-url': versions_1.rollupPluginUrlVersion,
|
|
12
|
+
'@svgr/rollup': versions_1.svgrRollupVersion,
|
|
13
|
+
});
|
|
22
14
|
const { targets } = (0, devkit_1.readProjectConfiguration)(host, options.name);
|
|
23
15
|
const external = ['react', 'react-dom'];
|
|
24
16
|
if (options.style === '@emotion/styled') {
|
|
@@ -54,6 +46,6 @@ async function addRollupBuildTarget(host, options) {
|
|
|
54
46
|
tags: options.parsedTags,
|
|
55
47
|
targets,
|
|
56
48
|
});
|
|
57
|
-
return (
|
|
49
|
+
return rollupInitGenerator(host, { ...options, skipFormat: true });
|
|
58
50
|
}
|
|
59
51
|
exports.addRollupBuildTarget = addRollupBuildTarget;
|
|
@@ -6,15 +6,7 @@ const add_swc_dependencies_1 = require("@nx/js/src/utils/swc/add-swc-dependencie
|
|
|
6
6
|
const versions_1 = require("../../../utils/versions");
|
|
7
7
|
function installCommonDependencies(host, options) {
|
|
8
8
|
const tasks = [];
|
|
9
|
-
const
|
|
10
|
-
const devDependencies = {
|
|
11
|
-
'@types/node': versions_1.typesNodeVersion,
|
|
12
|
-
'@types/react': versions_1.typesReactVersion,
|
|
13
|
-
'@types/react-dom': versions_1.typesReactDomVersion,
|
|
14
|
-
};
|
|
15
|
-
if (options.bundler !== 'vite') {
|
|
16
|
-
dependencies['tslib'] = versions_1.tsLibVersion;
|
|
17
|
-
}
|
|
9
|
+
const devDependencies = {};
|
|
18
10
|
// Vite requires style preprocessors to be installed manually.
|
|
19
11
|
// `@nx/webpack` installs them automatically for now.
|
|
20
12
|
// TODO(jack): Once we clean up webpack we can remove this check
|
|
@@ -28,10 +20,10 @@ function installCommonDependencies(host, options) {
|
|
|
28
20
|
break;
|
|
29
21
|
}
|
|
30
22
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
23
|
+
const baseInstallTask = (0, devkit_1.addDependenciesToPackageJson)(host, {
|
|
24
|
+
react: versions_1.reactVersion,
|
|
25
|
+
'react-dom': versions_1.reactDomVersion,
|
|
26
|
+
}, devDependencies);
|
|
35
27
|
tasks.push(baseInstallTask);
|
|
36
28
|
if (options.compiler === 'swc') {
|
|
37
29
|
tasks.push((0, add_swc_dependencies_1.addSwcDependencies)(host));
|
|
@@ -13,10 +13,6 @@ async function normalizeOptions(host, options) {
|
|
|
13
13
|
projectNameAndRootFormat: options.projectNameAndRootFormat,
|
|
14
14
|
callingGenerator: '@nx/react:library',
|
|
15
15
|
});
|
|
16
|
-
const nxJson = (0, devkit_1.readNxJson)(host);
|
|
17
|
-
const addPlugin = process.env.NX_ADD_PLUGINS !== 'false' &&
|
|
18
|
-
nxJson.useInferencePlugins !== false;
|
|
19
|
-
options.addPlugin ??= addPlugin;
|
|
20
16
|
const fileName = options.simpleName
|
|
21
17
|
? projectNames.projectSimpleName
|
|
22
18
|
: projectNames.projectFileName;
|
|
@@ -53,12 +49,11 @@ async function normalizeOptions(host, options) {
|
|
|
53
49
|
if (appProjectConfig.projectType !== 'application') {
|
|
54
50
|
throw new Error(`appProject expected type of "application" but got "${appProjectConfig.projectType}"`);
|
|
55
51
|
}
|
|
56
|
-
|
|
57
|
-
appProjectConfig.targets.build
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
if (!normalized.appMain) {
|
|
52
|
+
try {
|
|
53
|
+
normalized.appMain = appProjectConfig.targets.build.options.main;
|
|
54
|
+
normalized.appSourceRoot = (0, devkit_1.normalizePath)(appProjectConfig.sourceRoot);
|
|
55
|
+
}
|
|
56
|
+
catch (e) {
|
|
62
57
|
throw new Error(`Could not locate project main for ${options.appProject}`);
|
|
63
58
|
}
|
|
64
59
|
}
|
|
@@ -66,27 +61,3 @@ async function normalizeOptions(host, options) {
|
|
|
66
61
|
return normalized;
|
|
67
62
|
}
|
|
68
63
|
exports.normalizeOptions = normalizeOptions;
|
|
69
|
-
function findMainEntry(tree, projectRoot) {
|
|
70
|
-
const mainFiles = [
|
|
71
|
-
// These are the main files we generate with.
|
|
72
|
-
'src/main.ts',
|
|
73
|
-
'src/main.tsx',
|
|
74
|
-
'src/main.js',
|
|
75
|
-
'src/main.jsx',
|
|
76
|
-
// Other options just in case
|
|
77
|
-
'src/index.ts',
|
|
78
|
-
'src/index.tsx',
|
|
79
|
-
'src/index.js',
|
|
80
|
-
'src/index.jsx',
|
|
81
|
-
'main.ts',
|
|
82
|
-
'main.tsx',
|
|
83
|
-
'main.js',
|
|
84
|
-
'main.jsx',
|
|
85
|
-
'index.ts',
|
|
86
|
-
'index.tsx',
|
|
87
|
-
'index.js',
|
|
88
|
-
'index.jsx',
|
|
89
|
-
];
|
|
90
|
-
const mainEntry = mainFiles.find((file) => tree.exists((0, devkit_1.joinPathFragments)(projectRoot, file)));
|
|
91
|
-
return mainEntry ? (0, devkit_1.joinPathFragments)(projectRoot, mainEntry) : undefined;
|
|
92
|
-
}
|
|
@@ -4,7 +4,7 @@ exports.updateAppRoutes = void 0;
|
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const ast_utils_1 = require("../../../utils/ast-utils");
|
|
6
6
|
const ast_utils_2 = require("../../../utils/ast-utils");
|
|
7
|
-
const maybe_js_1 = require("
|
|
7
|
+
const maybe_js_1 = require("./maybe-js");
|
|
8
8
|
const versions_1 = require("../../../utils/versions");
|
|
9
9
|
const ensure_typescript_1 = require("@nx/js/src/utils/typescript/ensure-typescript");
|
|
10
10
|
let tsModule;
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.libraryGeneratorInternal = exports.libraryGenerator = void 0;
|
|
4
|
-
const path_1 = require("path");
|
|
5
4
|
const devkit_1 = require("@nx/devkit");
|
|
6
5
|
const artifact_name_and_directory_utils_1 = require("@nx/devkit/src/generators/artifact-name-and-directory-utils");
|
|
7
|
-
const log_show_project_command_1 = require("@nx/devkit/src/utils/log-show-project-command");
|
|
8
6
|
const js_1 = require("@nx/js");
|
|
9
7
|
const versions_1 = require("../../utils/versions");
|
|
10
|
-
const maybe_js_1 = require("../../utils/maybe-js");
|
|
11
8
|
const component_1 = require("../component/component");
|
|
12
9
|
const init_1 = require("../init/init");
|
|
13
10
|
const jest_utils_1 = require("../../utils/jest-utils");
|
|
@@ -19,9 +16,9 @@ const create_files_1 = require("./lib/create-files");
|
|
|
19
16
|
const create_ts_config_1 = require("../../utils/create-ts-config");
|
|
20
17
|
const install_common_dependencies_1 = require("./lib/install-common-dependencies");
|
|
21
18
|
const set_defaults_1 = require("./lib/set-defaults");
|
|
19
|
+
const path_1 = require("path");
|
|
22
20
|
async function libraryGenerator(host, schema) {
|
|
23
21
|
return await libraryGeneratorInternal(host, {
|
|
24
|
-
addPlugin: false,
|
|
25
22
|
projectNameAndRootFormat: 'derived',
|
|
26
23
|
...schema,
|
|
27
24
|
});
|
|
@@ -36,14 +33,11 @@ async function libraryGeneratorInternal(host, schema) {
|
|
|
36
33
|
if (!options.component) {
|
|
37
34
|
options.style = 'none';
|
|
38
35
|
}
|
|
39
|
-
const jsInitTask = await (0, js_1.initGenerator)(host, {
|
|
40
|
-
...schema,
|
|
41
|
-
skipFormat: true,
|
|
42
|
-
});
|
|
43
|
-
tasks.push(jsInitTask);
|
|
44
36
|
const initTask = await (0, init_1.default)(host, {
|
|
45
37
|
...options,
|
|
38
|
+
e2eTestRunner: 'none',
|
|
46
39
|
skipFormat: true,
|
|
40
|
+
skipHelperLibs: options.bundler === 'vite',
|
|
47
41
|
});
|
|
48
42
|
tasks.push(initTask);
|
|
49
43
|
(0, devkit_1.addProjectConfiguration)(host, options.name, {
|
|
@@ -69,7 +63,6 @@ async function libraryGeneratorInternal(host, schema) {
|
|
|
69
63
|
compiler: options.compiler,
|
|
70
64
|
skipFormat: true,
|
|
71
65
|
testEnvironment: 'jsdom',
|
|
72
|
-
addPlugin: options.addPlugin,
|
|
73
66
|
});
|
|
74
67
|
tasks.push(viteTask);
|
|
75
68
|
createOrEditViteConfig(host, {
|
|
@@ -120,11 +113,10 @@ async function libraryGeneratorInternal(host, schema) {
|
|
|
120
113
|
const vitestTask = await vitestGenerator(host, {
|
|
121
114
|
uiFramework: 'react',
|
|
122
115
|
project: options.name,
|
|
123
|
-
coverageProvider: '
|
|
116
|
+
coverageProvider: 'c8',
|
|
124
117
|
inSourceTests: options.inSourceTests,
|
|
125
118
|
skipFormat: true,
|
|
126
119
|
testEnvironment: 'jsdom',
|
|
127
|
-
addPlugin: options.addPlugin,
|
|
128
120
|
});
|
|
129
121
|
tasks.push(vitestTask);
|
|
130
122
|
createOrEditViteConfig(host, {
|
|
@@ -169,7 +161,7 @@ async function libraryGeneratorInternal(host, schema) {
|
|
|
169
161
|
});
|
|
170
162
|
}
|
|
171
163
|
if (!options.skipPackageJson) {
|
|
172
|
-
const installReactTask = (0, install_common_dependencies_1.installCommonDependencies)(host, options);
|
|
164
|
+
const installReactTask = await (0, install_common_dependencies_1.installCommonDependencies)(host, options);
|
|
173
165
|
tasks.push(installReactTask);
|
|
174
166
|
}
|
|
175
167
|
const routeTask = (0, update_app_routes_1.updateAppRoutes)(host, options);
|
|
@@ -178,15 +170,12 @@ async function libraryGeneratorInternal(host, schema) {
|
|
|
178
170
|
(0, create_ts_config_1.extractTsConfigBase)(host);
|
|
179
171
|
if (!options.skipTsConfig) {
|
|
180
172
|
(0, js_1.addTsConfigPath)(host, options.importPath, [
|
|
181
|
-
(0,
|
|
173
|
+
(0, devkit_1.joinPathFragments)(options.projectRoot, './src', 'index.' + (options.js ? 'js' : 'ts')),
|
|
182
174
|
]);
|
|
183
175
|
}
|
|
184
176
|
if (!options.skipFormat) {
|
|
185
177
|
await (0, devkit_1.formatFiles)(host);
|
|
186
178
|
}
|
|
187
|
-
tasks.push(() => {
|
|
188
|
-
(0, log_show_project_command_1.logShowProjectCommand)(options.name);
|
|
189
|
-
});
|
|
190
179
|
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
191
180
|
}
|
|
192
181
|
exports.libraryGeneratorInternal = libraryGeneratorInternal;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$schema": "
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
3
|
"cli": "nx",
|
|
4
4
|
"$id": "NxReactLibrary",
|
|
5
5
|
"title": "Create a React Library",
|
|
@@ -50,11 +50,11 @@
|
|
|
50
50
|
{ "value": "css", "label": "CSS" },
|
|
51
51
|
{
|
|
52
52
|
"value": "scss",
|
|
53
|
-
"label": "SASS(.scss) [
|
|
53
|
+
"label": "SASS(.scss) [ http://sass-lang.com ]"
|
|
54
54
|
},
|
|
55
55
|
{
|
|
56
56
|
"value": "less",
|
|
57
|
-
"label": "LESS [
|
|
57
|
+
"label": "LESS [ http://lesscss.org ]"
|
|
58
58
|
},
|
|
59
59
|
{
|
|
60
60
|
"value": "styled-components",
|
|
@@ -1,7 +1,7 @@
|
|
|
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 v18.
|
|
5
5
|
*/
|
|
6
6
|
project?: string;
|
|
7
7
|
directory?: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$schema": "
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
3
|
"cli": "nx",
|
|
4
4
|
"$id": "redux",
|
|
5
5
|
"title": "Create Redux state",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"$default": {
|
|
23
23
|
"$source": "projectName"
|
|
24
24
|
},
|
|
25
|
-
"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
|
|
25
|
+
"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 v18."
|
|
26
26
|
},
|
|
27
27
|
"directory": {
|
|
28
28
|
"type": "string",
|
|
@@ -3,7 +3,7 @@ import {ModuleFederationConfig} from '@nx/webpack';
|
|
|
3
3
|
const config: ModuleFederationConfig = {
|
|
4
4
|
name: '<%= projectName %>',
|
|
5
5
|
exposes: {
|
|
6
|
-
'./Module': '<%= appProjectRoot %>/src/remote-entry
|
|
6
|
+
'./Module': '<%= appProjectRoot %>/src/remote-entry.ts',
|
|
7
7
|
},
|
|
8
8
|
};
|
|
9
9
|
|
package/src/generators/remote/files/module-federation-ts/module-federation.config.ts__tmpl__
CHANGED
|
@@ -2,11 +2,8 @@ import {ModuleFederationConfig} from '@nx/webpack';
|
|
|
2
2
|
|
|
3
3
|
const config: ModuleFederationConfig = {
|
|
4
4
|
name: '<%= projectName %>',
|
|
5
|
-
<% if (dynamic) { %>
|
|
6
|
-
library: { type: 'var', name: '<%= projectName %>'},
|
|
7
|
-
<% } %>
|
|
8
5
|
exposes: {
|
|
9
|
-
'./Module': './src/remote-entry
|
|
6
|
+
'./Module': './src/remote-entry.ts',
|
|
10
7
|
},
|
|
11
8
|
};
|
|
12
9
|
|
|
@@ -18,16 +18,12 @@ async function setupSsrForRemote(tree, options, appName) {
|
|
|
18
18
|
});
|
|
19
19
|
// For hosts to use when running remotes in static mode.
|
|
20
20
|
const originalOutputPath = project.targets.build?.options?.outputPath;
|
|
21
|
-
const serverOptions = project.targets.server?.options;
|
|
22
|
-
const serverOutputPath = serverOptions?.outputPath ??
|
|
23
|
-
(0, devkit_1.joinPathFragments)(originalOutputPath, 'server');
|
|
24
|
-
const serverOutputName = serverOptions?.outputFileName ?? 'main.js';
|
|
25
21
|
project.targets['serve-static'] = {
|
|
26
22
|
dependsOn: ['build', 'server'],
|
|
27
23
|
executor: 'nx:run-commands',
|
|
28
24
|
defaultConfiguration: 'development',
|
|
29
25
|
options: {
|
|
30
|
-
command: `PORT=${options.devServerPort ?? 4200} node ${(0, devkit_1.joinPathFragments)(
|
|
26
|
+
command: `PORT=${options.devServerPort ?? 4200} node ${(0, devkit_1.joinPathFragments)(originalOutputPath, 'server', 'main.js')}`,
|
|
31
27
|
},
|
|
32
28
|
};
|
|
33
29
|
(0, devkit_1.updateProjectConfiguration)(tree, appName, project);
|
|
@@ -3,10 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.setupTspathForRemote = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const js_1 = require("@nx/js");
|
|
6
|
-
const maybe_js_1 = require("../../../utils/maybe-js");
|
|
7
6
|
function setupTspathForRemote(tree, options) {
|
|
8
7
|
const project = (0, devkit_1.readProjectConfiguration)(tree, options.name);
|
|
9
|
-
const exportPath =
|
|
8
|
+
const exportPath = `./src/remote-entry.ts`;
|
|
10
9
|
const exportName = 'Module';
|
|
11
10
|
(0, js_1.addTsConfigPath)(tree, `${options.name}/${exportName}`, [
|
|
12
11
|
(0, devkit_1.joinPathFragments)(project.root, exportPath),
|