@nx/react 16.8.0-beta.0 → 16.8.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/package.json +7 -7
- package/src/generators/application/application.js +4 -1
- package/src/generators/application/lib/create-application-files.js +28 -24
- package/src/generators/application/lib/normalize-options.js +2 -14
- package/src/generators/host/host.js +8 -5
- package/src/generators/host/lib/add-module-federation-files.js +1 -3
- package/src/generators/host/lib/normalize-remote.d.ts +4 -0
- package/src/generators/host/lib/normalize-remote.js +31 -0
- package/src/generators/host/lib/setup-ssr-for-host.js +1 -3
- package/src/generators/library/lib/add-linting.js +4 -2
- package/src/generators/remote/schema.json +0 -1
- package/src/utils/lint.d.ts +5 -2
- package/src/utils/lint.js +3 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/react",
|
|
3
|
-
"version": "16.8.0-beta.
|
|
3
|
+
"version": "16.8.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": {
|
|
@@ -31,11 +31,11 @@
|
|
|
31
31
|
"migrations": "./migrations.json"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@nrwl/react": "16.8.0-beta.
|
|
35
|
-
"@nx/devkit": "16.8.0-beta.
|
|
36
|
-
"@nx/js": "16.8.0-beta.
|
|
37
|
-
"@nx/linter": "16.8.0-beta.
|
|
38
|
-
"@nx/web": "16.8.0-beta.
|
|
34
|
+
"@nrwl/react": "16.8.0-beta.2",
|
|
35
|
+
"@nx/devkit": "16.8.0-beta.2",
|
|
36
|
+
"@nx/js": "16.8.0-beta.2",
|
|
37
|
+
"@nx/linter": "16.8.0-beta.2",
|
|
38
|
+
"@nx/web": "16.8.0-beta.2",
|
|
39
39
|
"@phenomnomnominal/tsquery": "~5.0.1",
|
|
40
40
|
"@svgr/webpack": "^8.0.1",
|
|
41
41
|
"chalk": "^4.1.0",
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"access": "public"
|
|
48
48
|
},
|
|
49
49
|
"type": "commonjs",
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "9bcc04742f9e1516d8c1ddbfb1907770c347876f"
|
|
51
51
|
}
|
|
@@ -22,6 +22,7 @@ const add_swc_dependencies_1 = require("@nx/js/src/utils/swc/add-swc-dependencie
|
|
|
22
22
|
const chalk = require("chalk");
|
|
23
23
|
const show_possible_warnings_1 = require("./lib/show-possible-warnings");
|
|
24
24
|
const add_e2e_1 = require("./lib/add-e2e");
|
|
25
|
+
const eslint_file_1 = require("@nx/linter/src/generators/utils/eslint-file");
|
|
25
26
|
function addLinting(host, options) {
|
|
26
27
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
27
28
|
const tasks = [];
|
|
@@ -41,7 +42,9 @@ function addLinting(host, options) {
|
|
|
41
42
|
skipPackageJson: options.skipPackageJson,
|
|
42
43
|
});
|
|
43
44
|
tasks.push(lintTask);
|
|
44
|
-
|
|
45
|
+
if ((0, eslint_file_1.isEslintConfigSupported)(host)) {
|
|
46
|
+
(0, eslint_file_1.addExtendsToLintConfig)(host, options.appProjectRoot, 'plugin:@nx/react');
|
|
47
|
+
}
|
|
45
48
|
if (!options.skipPackageJson) {
|
|
46
49
|
const installTask = (0, devkit_1.addDependenciesToPackageJson)(host, lint_1.extraEslintDependencies.dependencies, lint_1.extraEslintDependencies.devDependencies);
|
|
47
50
|
const addSwcTask = (0, add_swc_dependencies_1.addSwcDependencies)(host);
|
|
@@ -56,32 +56,36 @@ function createApplicationFiles(host, options) {
|
|
|
56
56
|
].filter(Boolean),
|
|
57
57
|
});
|
|
58
58
|
}
|
|
59
|
-
else if (options.
|
|
60
|
-
|
|
61
|
-
options.style === 'styled-jsx') {
|
|
62
|
-
(0, devkit_1.writeJson)(host, `${options.appProjectRoot}/.swcrc`, {
|
|
59
|
+
else if (options.compiler === 'swc') {
|
|
60
|
+
const swcrc = {
|
|
63
61
|
jsc: {
|
|
64
|
-
|
|
65
|
-
plugins: [
|
|
66
|
-
options.style === 'styled-components'
|
|
67
|
-
? [
|
|
68
|
-
'@swc/plugin-styled-components',
|
|
69
|
-
{
|
|
70
|
-
displayName: true,
|
|
71
|
-
ssr: true,
|
|
72
|
-
},
|
|
73
|
-
]
|
|
74
|
-
: undefined,
|
|
75
|
-
options.style === 'styled-jsx'
|
|
76
|
-
? ['@swc/plugin-styled-jsx', {}]
|
|
77
|
-
: undefined,
|
|
78
|
-
options.style === '@emotion/styled'
|
|
79
|
-
? ['@swc/plugin-emotion', {}]
|
|
80
|
-
: undefined,
|
|
81
|
-
].filter(Boolean),
|
|
82
|
-
},
|
|
62
|
+
target: 'es2016',
|
|
83
63
|
},
|
|
84
|
-
}
|
|
64
|
+
};
|
|
65
|
+
if (options.style === 'styled-components') {
|
|
66
|
+
swcrc.jsc.experimental = {
|
|
67
|
+
plugins: [
|
|
68
|
+
[
|
|
69
|
+
'@swc/plugin-styled-components',
|
|
70
|
+
{
|
|
71
|
+
displayName: true,
|
|
72
|
+
ssr: true,
|
|
73
|
+
},
|
|
74
|
+
],
|
|
75
|
+
],
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
else if (options.style === '@emotion/styled') {
|
|
79
|
+
swcrc.jsc.experimental = {
|
|
80
|
+
plugins: [['@swc/plugin-emotion', {}]],
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
else if (options.style === 'styled-jsx') {
|
|
84
|
+
swcrc.jsc.experimental = {
|
|
85
|
+
plugins: [['@swc/plugin-styled-jsx', {}]],
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
(0, devkit_1.writeJson)(host, `${options.appProjectRoot}/.swcrc`, swcrc);
|
|
85
89
|
}
|
|
86
90
|
}
|
|
87
91
|
else if (options.bundler === 'rspack') {
|
|
@@ -32,20 +32,8 @@ function normalizeOptions(host, options, callingGenerator = '@nx/react:applicati
|
|
|
32
32
|
});
|
|
33
33
|
options.rootProject = appProjectRoot === '.';
|
|
34
34
|
options.projectNameAndRootFormat = projectNameAndRootFormat;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
if (!options.rootProject) {
|
|
38
|
-
const projectNameAndRoot = yield (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
|
|
39
|
-
name: `${options.name}-e2e`,
|
|
40
|
-
projectType: 'application',
|
|
41
|
-
directory: options.directory,
|
|
42
|
-
projectNameAndRootFormat: options.projectNameAndRootFormat,
|
|
43
|
-
rootProject: options.rootProject,
|
|
44
|
-
callingGenerator,
|
|
45
|
-
});
|
|
46
|
-
e2eProjectName = projectNameAndRoot.projectName;
|
|
47
|
-
e2eProjectRoot = projectNameAndRoot.projectRoot;
|
|
48
|
-
}
|
|
35
|
+
const e2eProjectName = options.rootProject ? 'e2e' : `${appProjectName}-e2e`;
|
|
36
|
+
const e2eProjectRoot = options.rootProject ? 'e2e' : `${appProjectRoot}-e2e`;
|
|
49
37
|
const parsedTags = options.tags
|
|
50
38
|
? options.tags.split(',').map((s) => s.trim())
|
|
51
39
|
: [];
|
|
@@ -3,14 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.hostGeneratorInternal = exports.hostGenerator = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const devkit_1 = require("@nx/devkit");
|
|
6
|
+
const update_module_federation_project_1 = require("../../rules/update-module-federation-project");
|
|
6
7
|
const application_1 = require("../application/application");
|
|
7
8
|
const normalize_options_1 = require("../application/lib/normalize-options");
|
|
8
|
-
const update_module_federation_project_1 = require("../../rules/update-module-federation-project");
|
|
9
|
-
const add_module_federation_files_1 = require("./lib/add-module-federation-files");
|
|
10
|
-
const update_module_federation_e2e_project_1 = require("./lib/update-module-federation-e2e-project");
|
|
11
9
|
const remote_1 = require("../remote/remote");
|
|
12
10
|
const setup_ssr_1 = require("../setup-ssr/setup-ssr");
|
|
11
|
+
const add_module_federation_files_1 = require("./lib/add-module-federation-files");
|
|
12
|
+
const normalize_remote_1 = require("./lib/normalize-remote");
|
|
13
13
|
const setup_ssr_for_host_1 = require("./lib/setup-ssr-for-host");
|
|
14
|
+
const update_module_federation_e2e_project_1 = require("./lib/update-module-federation-e2e-project");
|
|
14
15
|
function hostGenerator(host, schema) {
|
|
15
16
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
16
17
|
return hostGeneratorInternal(host, Object.assign({ projectNameAndRootFormat: 'derived' }, schema));
|
|
@@ -31,10 +32,11 @@ function hostGeneratorInternal(host, schema) {
|
|
|
31
32
|
if (schema.remotes) {
|
|
32
33
|
let remotePort = options.devServerPort + 1;
|
|
33
34
|
for (const remote of schema.remotes) {
|
|
34
|
-
|
|
35
|
+
const remoteName = yield (0, normalize_remote_1.normalizeRemoteName)(host, remote, options);
|
|
36
|
+
remotesWithPorts.push({ name: remoteName, port: remotePort });
|
|
35
37
|
yield (0, remote_1.default)(host, {
|
|
36
38
|
name: remote,
|
|
37
|
-
directory:
|
|
39
|
+
directory: (0, normalize_remote_1.normalizeRemoteDirectory)(remote, options),
|
|
38
40
|
style: options.style,
|
|
39
41
|
unitTestRunner: options.unitTestRunner,
|
|
40
42
|
e2eTestRunner: options.e2eTestRunner,
|
|
@@ -42,6 +44,7 @@ function hostGeneratorInternal(host, schema) {
|
|
|
42
44
|
devServerPort: remotePort,
|
|
43
45
|
ssr: options.ssr,
|
|
44
46
|
skipFormat: true,
|
|
47
|
+
projectNameAndRootFormat: options.projectNameAndRootFormat,
|
|
45
48
|
});
|
|
46
49
|
remotePort++;
|
|
47
50
|
}
|
|
@@ -3,11 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.addModuleFederationFiles = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const path_1 = require("path");
|
|
6
|
-
const normalize_options_1 = require("../../application/lib/normalize-options");
|
|
7
6
|
function addModuleFederationFiles(host, options, defaultRemoteManifest) {
|
|
8
7
|
const templateVariables = Object.assign(Object.assign(Object.assign({}, (0, devkit_1.names)(options.name)), options), { tmpl: '', remotes: defaultRemoteManifest.map(({ name, port }) => {
|
|
9
|
-
|
|
10
|
-
return Object.assign(Object.assign({}, (0, devkit_1.names)(remote)), { port });
|
|
8
|
+
return Object.assign(Object.assign({}, (0, devkit_1.names)(name)), { port });
|
|
11
9
|
}) });
|
|
12
10
|
// Module federation requires bootstrap code to be dynamically imported.
|
|
13
11
|
// Renaming original entry file so we can use `import(./bootstrap)` in
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Tree } from '@nx/devkit';
|
|
2
|
+
import { NormalizedSchema } from '../schema';
|
|
3
|
+
export declare function normalizeRemoteName(tree: Tree, remote: string, options: NormalizedSchema): Promise<string>;
|
|
4
|
+
export declare function normalizeRemoteDirectory(remote: string, options: NormalizedSchema): string;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.normalizeRemoteDirectory = exports.normalizeRemoteName = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const devkit_1 = require("@nx/devkit");
|
|
6
|
+
const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
|
|
7
|
+
function normalizeRemoteName(tree, remote, options) {
|
|
8
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
9
|
+
const { projectName: remoteName } = yield (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(tree, {
|
|
10
|
+
name: remote,
|
|
11
|
+
projectType: 'application',
|
|
12
|
+
directory: options.directory,
|
|
13
|
+
projectNameAndRootFormat: options.projectNameAndRootFormat,
|
|
14
|
+
callingGenerator: '@nx/react:host',
|
|
15
|
+
});
|
|
16
|
+
return remoteName;
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
exports.normalizeRemoteName = normalizeRemoteName;
|
|
20
|
+
function normalizeRemoteDirectory(remote, options) {
|
|
21
|
+
if (options.projectNameAndRootFormat === 'derived' || !options.directory) {
|
|
22
|
+
return options.directory;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* With the `as-provided` format, the provided directory would be the root
|
|
26
|
+
* of the host application. Append the remote name to the host parent
|
|
27
|
+
* directory to get the remote directory.
|
|
28
|
+
*/
|
|
29
|
+
return (0, devkit_1.joinPathFragments)(options.directory, '..', remote);
|
|
30
|
+
}
|
|
31
|
+
exports.normalizeRemoteDirectory = normalizeRemoteDirectory;
|
|
@@ -4,7 +4,6 @@ exports.setupSsrForHost = void 0;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const devkit_1 = require("@nx/devkit");
|
|
6
6
|
const versions_1 = require("../../../utils/versions");
|
|
7
|
-
const normalize_options_1 = require("../../application/lib/normalize-options");
|
|
8
7
|
function setupSsrForHost(tree, options, appName, defaultRemoteManifest) {
|
|
9
8
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
10
9
|
const tasks = [];
|
|
@@ -12,8 +11,7 @@ function setupSsrForHost(tree, options, appName, defaultRemoteManifest) {
|
|
|
12
11
|
project.targets.serve.executor = '@nx/react:module-federation-ssr-dev-server';
|
|
13
12
|
(0, devkit_1.updateProjectConfiguration)(tree, appName, project);
|
|
14
13
|
(0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, '../files/module-federation-ssr'), project.root, Object.assign(Object.assign({}, options), { remotes: defaultRemoteManifest.map(({ name, port }) => {
|
|
15
|
-
|
|
16
|
-
return Object.assign(Object.assign({}, (0, devkit_1.names)(remote)), { port });
|
|
14
|
+
return Object.assign(Object.assign({}, (0, devkit_1.names)(name)), { port });
|
|
17
15
|
}), appName, tmpl: '', browserBuildOutputPath: project.targets.build.options.outputPath }));
|
|
18
16
|
const installTask = (0, devkit_1.addDependenciesToPackageJson)(tree, {
|
|
19
17
|
'@module-federation/node': versions_1.moduleFederationNodeVersion,
|
|
@@ -4,9 +4,9 @@ exports.addLinting = void 0;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const linter_1 = require("@nx/linter");
|
|
6
6
|
const path_1 = require("nx/src/utils/path");
|
|
7
|
-
const json_1 = require("nx/src/generators/utils/json");
|
|
8
7
|
const devkit_1 = require("@nx/devkit");
|
|
9
8
|
const lint_1 = require("../../../utils/lint");
|
|
9
|
+
const eslint_file_1 = require("@nx/linter/src/generators/utils/eslint-file");
|
|
10
10
|
function addLinting(host, options) {
|
|
11
11
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
12
12
|
if (options.linter === linter_1.Linter.EsLint) {
|
|
@@ -22,7 +22,9 @@ function addLinting(host, options) {
|
|
|
22
22
|
skipPackageJson: options.skipPackageJson,
|
|
23
23
|
setParserOptionsProject: options.setParserOptionsProject,
|
|
24
24
|
});
|
|
25
|
-
|
|
25
|
+
if ((0, eslint_file_1.isEslintConfigSupported)(host)) {
|
|
26
|
+
(0, eslint_file_1.addExtendsToLintConfig)(host, options.projectRoot, 'plugin:@nx/react');
|
|
27
|
+
}
|
|
26
28
|
let installTask = () => { };
|
|
27
29
|
if (!options.skipPackageJson) {
|
|
28
30
|
installTask = yield (0, devkit_1.addDependenciesToPackageJson)(host, lint_1.extraEslintDependencies.dependencies, lint_1.extraEslintDependencies.devDependencies);
|
package/src/utils/lint.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Linter } from 'eslint';
|
|
2
2
|
export declare const extraEslintDependencies: {
|
|
3
3
|
dependencies: {};
|
|
4
4
|
devDependencies: {
|
|
@@ -8,6 +8,9 @@ export declare const extraEslintDependencies: {
|
|
|
8
8
|
'eslint-plugin-react-hooks': string;
|
|
9
9
|
};
|
|
10
10
|
};
|
|
11
|
+
/**
|
|
12
|
+
* @deprecated Use `addExtendsToLintConfig` from `@nx/linter` instead.
|
|
13
|
+
*/
|
|
11
14
|
export declare const extendReactEslintJson: (json: Linter.Config) => {
|
|
12
15
|
ignorePatterns?: string | string[];
|
|
13
16
|
root?: boolean;
|
|
@@ -16,7 +19,7 @@ export declare const extendReactEslintJson: (json: Linter.Config) => {
|
|
|
16
19
|
[name: string]: boolean;
|
|
17
20
|
};
|
|
18
21
|
globals?: {
|
|
19
|
-
[name: string]: boolean | "readonly" | "readable" | "writable" | "writeable";
|
|
22
|
+
[name: string]: boolean | "off" | "readonly" | "readable" | "writable" | "writeable";
|
|
20
23
|
};
|
|
21
24
|
noInlineConfig?: boolean;
|
|
22
25
|
overrides?: Linter.ConfigOverride<Linter.RulesRecord>[];
|
package/src/utils/lint.js
CHANGED
|
@@ -12,6 +12,9 @@ exports.extraEslintDependencies = {
|
|
|
12
12
|
'eslint-plugin-react-hooks': versions_1.eslintPluginReactHooksVersion,
|
|
13
13
|
},
|
|
14
14
|
};
|
|
15
|
+
/**
|
|
16
|
+
* @deprecated Use `addExtendsToLintConfig` from `@nx/linter` instead.
|
|
17
|
+
*/
|
|
15
18
|
const extendReactEslintJson = (json) => {
|
|
16
19
|
const { extends: pluginExtends } = json, config = tslib_1.__rest(json, ["extends"]);
|
|
17
20
|
return Object.assign({ extends: ['plugin:@nx/react', ...(pluginExtends || [])] }, config);
|