@nx/react 16.7.0 → 16.8.0-beta.0
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 +4 -4
- package/package.json +7 -7
- package/src/generators/application/application.d.ts +1 -0
- package/src/generators/application/application.js +9 -3
- package/src/generators/application/lib/add-e2e.js +3 -1
- package/src/generators/application/lib/normalize-options.d.ts +2 -2
- package/src/generators/application/lib/normalize-options.js +59 -44
- package/src/generators/application/schema.d.ts +4 -2
- package/src/generators/application/schema.json +6 -1
- package/src/generators/host/host.d.ts +1 -0
- package/src/generators/host/host.js +9 -3
- package/src/generators/host/schema.d.ts +4 -2
- package/src/generators/host/schema.json +6 -1
- package/src/generators/library/lib/add-rollup-build-target.js +1 -4
- package/src/generators/library/lib/normalize-options.d.ts +1 -1
- package/src/generators/library/lib/normalize-options.js +49 -46
- package/src/generators/library/lib/update-app-routes.js +1 -2
- package/src/generators/library/library.d.ts +1 -0
- package/src/generators/library/library.js +9 -3
- package/src/generators/library/schema.d.ts +3 -3
- package/src/generators/library/schema.json +6 -1
- package/src/generators/remote/remote.d.ts +1 -0
- package/src/generators/remote/remote.js +9 -3
- package/src/generators/remote/schema.d.ts +4 -3
- package/src/generators/remote/schema.json +6 -1
package/generators.json
CHANGED
|
@@ -114,7 +114,7 @@
|
|
|
114
114
|
},
|
|
115
115
|
|
|
116
116
|
"application": {
|
|
117
|
-
"factory": "./src/generators/application/application#
|
|
117
|
+
"factory": "./src/generators/application/application#applicationGeneratorInternal",
|
|
118
118
|
"schema": "./src/generators/application/schema.json",
|
|
119
119
|
"aliases": ["app"],
|
|
120
120
|
"x-type": "application",
|
|
@@ -122,7 +122,7 @@
|
|
|
122
122
|
},
|
|
123
123
|
|
|
124
124
|
"library": {
|
|
125
|
-
"factory": "./src/generators/library/library#
|
|
125
|
+
"factory": "./src/generators/library/library#libraryGeneratorInternal",
|
|
126
126
|
"schema": "./src/generators/library/schema.json",
|
|
127
127
|
"aliases": ["lib"],
|
|
128
128
|
"x-type": "library",
|
|
@@ -179,14 +179,14 @@
|
|
|
179
179
|
},
|
|
180
180
|
|
|
181
181
|
"host": {
|
|
182
|
-
"factory": "./src/generators/host/host#
|
|
182
|
+
"factory": "./src/generators/host/host#hostGeneratorInternal",
|
|
183
183
|
"schema": "./src/generators/host/schema.json",
|
|
184
184
|
"x-type": "application",
|
|
185
185
|
"description": "Generate a host react application"
|
|
186
186
|
},
|
|
187
187
|
|
|
188
188
|
"remote": {
|
|
189
|
-
"factory": "./src/generators/remote/remote#
|
|
189
|
+
"factory": "./src/generators/remote/remote#remoteGeneratorInternal",
|
|
190
190
|
"schema": "./src/generators/remote/schema.json",
|
|
191
191
|
"x-type": "application",
|
|
192
192
|
"description": "Generate a remote react application"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/react",
|
|
3
|
-
"version": "16.
|
|
3
|
+
"version": "16.8.0-beta.0",
|
|
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.
|
|
35
|
-
"@nx/devkit": "16.
|
|
36
|
-
"@nx/js": "16.
|
|
37
|
-
"@nx/linter": "16.
|
|
38
|
-
"@nx/web": "16.
|
|
34
|
+
"@nrwl/react": "16.8.0-beta.0",
|
|
35
|
+
"@nx/devkit": "16.8.0-beta.0",
|
|
36
|
+
"@nx/js": "16.8.0-beta.0",
|
|
37
|
+
"@nx/linter": "16.8.0-beta.0",
|
|
38
|
+
"@nx/web": "16.8.0-beta.0",
|
|
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": "818352404283c1d34ab303d91b3bd16474f54916"
|
|
51
51
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Schema } from './schema';
|
|
2
2
|
import { GeneratorCallback, Tree } from '@nx/devkit';
|
|
3
3
|
export declare function applicationGenerator(host: Tree, schema: Schema): Promise<GeneratorCallback>;
|
|
4
|
+
export declare function applicationGeneratorInternal(host: Tree, schema: Schema): Promise<GeneratorCallback>;
|
|
4
5
|
export default applicationGenerator;
|
|
5
6
|
export declare const applicationSchematic: (generatorOptions: Schema) => (tree: any, context: any) => Promise<any>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.applicationSchematic = exports.applicationGenerator = void 0;
|
|
3
|
+
exports.applicationSchematic = exports.applicationGeneratorInternal = exports.applicationGenerator = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const lint_1 = require("../../utils/lint");
|
|
6
6
|
const create_application_files_1 = require("./lib/create-application-files");
|
|
@@ -52,9 +52,15 @@ function addLinting(host, options) {
|
|
|
52
52
|
});
|
|
53
53
|
}
|
|
54
54
|
function applicationGenerator(host, schema) {
|
|
55
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
56
|
+
return yield applicationGeneratorInternal(host, Object.assign({ projectNameAndRootFormat: 'derived' }, schema));
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
exports.applicationGenerator = applicationGenerator;
|
|
60
|
+
function applicationGeneratorInternal(host, schema) {
|
|
55
61
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
56
62
|
const tasks = [];
|
|
57
|
-
const options = (0, normalize_options_1.normalizeOptions)(host, schema);
|
|
63
|
+
const options = yield (0, normalize_options_1.normalizeOptions)(host, schema);
|
|
58
64
|
(0, show_possible_warnings_1.showPossibleWarnings)(host, options);
|
|
59
65
|
const initTask = yield (0, init_1.default)(host, Object.assign(Object.assign({}, options), { skipFormat: true, skipHelperLibs: options.bundler === 'vite' }));
|
|
60
66
|
tasks.push(initTask);
|
|
@@ -161,6 +167,6 @@ function applicationGenerator(host, schema) {
|
|
|
161
167
|
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
162
168
|
});
|
|
163
169
|
}
|
|
164
|
-
exports.
|
|
170
|
+
exports.applicationGeneratorInternal = applicationGeneratorInternal;
|
|
165
171
|
exports.default = applicationGenerator;
|
|
166
172
|
exports.applicationSchematic = (0, devkit_1.convertNxGenerator)(applicationGenerator);
|
|
@@ -14,7 +14,9 @@ function addE2e(tree, options) {
|
|
|
14
14
|
targetName: 'serve-static',
|
|
15
15
|
});
|
|
16
16
|
const { cypressProjectGenerator } = (0, devkit_1.ensurePackage)('@nx/cypress', versions_1.nxVersion);
|
|
17
|
-
return yield cypressProjectGenerator(tree, Object.assign(Object.assign({}, options), { name: options.e2eProjectName, directory: options.
|
|
17
|
+
return yield cypressProjectGenerator(tree, Object.assign(Object.assign({}, options), { name: options.e2eProjectName, directory: options.e2eProjectRoot,
|
|
18
|
+
// the name and root are already normalized, instruct the generator to use them as is
|
|
19
|
+
projectNameAndRootFormat: 'as-provided', project: options.projectName, bundler: options.bundler === 'rspack' ? 'webpack' : options.bundler, skipFormat: true }));
|
|
18
20
|
case 'playwright':
|
|
19
21
|
const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/playwright', versions_1.nxVersion);
|
|
20
22
|
(0, devkit_1.addProjectConfiguration)(tree, options.e2eProjectName, {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { NormalizedSchema, Schema } from '../schema';
|
|
2
1
|
import { Tree } from '@nx/devkit';
|
|
2
|
+
import { NormalizedSchema, Schema } from '../schema';
|
|
3
3
|
export declare function normalizeDirectory(options: Schema): string;
|
|
4
4
|
export declare function normalizeProjectName(options: Schema): string;
|
|
5
|
-
export declare function normalizeOptions<T extends Schema = Schema>(host: Tree, options: Schema): NormalizedSchema<T
|
|
5
|
+
export declare function normalizeOptions<T extends Schema = Schema>(host: Tree, options: Schema, callingGenerator?: string): Promise<NormalizedSchema<T>>;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.normalizeOptions = exports.normalizeProjectName = exports.normalizeDirectory = void 0;
|
|
4
|
-
const
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
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
|
+
const assertion_1 = require("../../../utils/assertion");
|
|
6
8
|
const find_free_port_1 = require("./find-free-port");
|
|
7
9
|
function normalizeDirectory(options) {
|
|
8
10
|
var _a;
|
|
@@ -17,49 +19,62 @@ function normalizeProjectName(options) {
|
|
|
17
19
|
return normalizeDirectory(options).replace(new RegExp('/', 'g'), '-');
|
|
18
20
|
}
|
|
19
21
|
exports.normalizeProjectName = normalizeProjectName;
|
|
20
|
-
function normalizeOptions(host, options) {
|
|
22
|
+
function normalizeOptions(host, options, callingGenerator = '@nx/react:application') {
|
|
21
23
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
fileName
|
|
51
|
-
styledModule
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
24
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
25
|
+
const { projectName: appProjectName, projectRoot: appProjectRoot, projectNameAndRootFormat, } = yield (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
|
|
26
|
+
name: options.name,
|
|
27
|
+
projectType: 'application',
|
|
28
|
+
directory: options.directory,
|
|
29
|
+
projectNameAndRootFormat: options.projectNameAndRootFormat,
|
|
30
|
+
rootProject: options.rootProject,
|
|
31
|
+
callingGenerator,
|
|
32
|
+
});
|
|
33
|
+
options.rootProject = appProjectRoot === '.';
|
|
34
|
+
options.projectNameAndRootFormat = projectNameAndRootFormat;
|
|
35
|
+
let e2eProjectName = 'e2e';
|
|
36
|
+
let e2eProjectRoot = 'e2e';
|
|
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
|
+
}
|
|
49
|
+
const parsedTags = options.tags
|
|
50
|
+
? options.tags.split(',').map((s) => s.trim())
|
|
51
|
+
: [];
|
|
52
|
+
const fileName = options.pascalCaseFiles ? 'App' : 'app';
|
|
53
|
+
const styledModule = /^(css|scss|less|styl|none)$/.test(options.style)
|
|
54
|
+
? null
|
|
55
|
+
: options.style;
|
|
56
|
+
(0, assertion_1.assertValidStyle)(options.style);
|
|
57
|
+
if (options.bundler === 'vite') {
|
|
58
|
+
options.unitTestRunner = 'vitest';
|
|
59
|
+
}
|
|
60
|
+
const normalized = Object.assign(Object.assign({}, options), { name: (0, devkit_1.names)(options.name).fileName, projectName: appProjectName, appProjectRoot,
|
|
61
|
+
e2eProjectName,
|
|
62
|
+
e2eProjectRoot,
|
|
63
|
+
parsedTags,
|
|
64
|
+
fileName,
|
|
65
|
+
styledModule, hasStyles: options.style !== 'none' });
|
|
66
|
+
normalized.routing = (_a = normalized.routing) !== null && _a !== void 0 ? _a : false;
|
|
67
|
+
normalized.strict = (_b = normalized.strict) !== null && _b !== void 0 ? _b : true;
|
|
68
|
+
normalized.classComponent = (_c = normalized.classComponent) !== null && _c !== void 0 ? _c : false;
|
|
69
|
+
normalized.compiler = (_d = normalized.compiler) !== null && _d !== void 0 ? _d : 'babel';
|
|
70
|
+
normalized.bundler = (_e = normalized.bundler) !== null && _e !== void 0 ? _e : 'webpack';
|
|
71
|
+
normalized.unitTestRunner =
|
|
72
|
+
(_f = normalized.unitTestRunner) !== null && _f !== void 0 ? _f : (normalized.bundler === 'vite' ? 'vitest' : 'jest');
|
|
73
|
+
normalized.e2eTestRunner = (_g = normalized.e2eTestRunner) !== null && _g !== void 0 ? _g : 'cypress';
|
|
74
|
+
normalized.inSourceTests = normalized.minimal || normalized.inSourceTests;
|
|
75
|
+
(_h = normalized.devServerPort) !== null && _h !== void 0 ? _h : (normalized.devServerPort = (0, find_free_port_1.findFreePort)(host));
|
|
76
|
+
normalized.minimal = (_j = normalized.minimal) !== null && _j !== void 0 ? _j : false;
|
|
77
|
+
return normalized;
|
|
78
|
+
});
|
|
64
79
|
}
|
|
65
80
|
exports.normalizeOptions = normalizeOptions;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { ProjectNameAndRootFormat } from '@nx/devkit/src/generators/project-name-and-root-utils';
|
|
2
|
+
import type { Linter } from '@nx/linter';
|
|
3
|
+
import type { SupportedStyles } from '../../../typings/style';
|
|
3
4
|
|
|
4
5
|
export interface Schema {
|
|
5
6
|
name: string;
|
|
6
7
|
style: SupportedStyles;
|
|
7
8
|
skipFormat?: boolean;
|
|
8
9
|
directory?: string;
|
|
10
|
+
projectNameAndRootFormat?: ProjectNameAndRootFormat;
|
|
9
11
|
tags?: string;
|
|
10
12
|
unitTestRunner?: 'jest' | 'vitest' | 'none';
|
|
11
13
|
inSourceTests?: boolean;
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"index": 0
|
|
29
29
|
},
|
|
30
30
|
"x-prompt": "What name would you like to use for the application?",
|
|
31
|
-
"pattern": "^[a-zA-Z]
|
|
31
|
+
"pattern": "^[a-zA-Z][^:]*$"
|
|
32
32
|
},
|
|
33
33
|
"directory": {
|
|
34
34
|
"description": "The directory of the new application.",
|
|
@@ -36,6 +36,11 @@
|
|
|
36
36
|
"alias": "dir",
|
|
37
37
|
"x-priority": "important"
|
|
38
38
|
},
|
|
39
|
+
"projectNameAndRootFormat": {
|
|
40
|
+
"description": "Whether to generate the project name and root directory as provided (`as-provided`) or generate them composing their values and taking the configured layout into account (`derived`).",
|
|
41
|
+
"type": "string",
|
|
42
|
+
"enum": ["as-provided", "derived"]
|
|
43
|
+
},
|
|
39
44
|
"style": {
|
|
40
45
|
"description": "The file extension to be used for style files.",
|
|
41
46
|
"type": "string",
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { GeneratorCallback, Tree } from '@nx/devkit';
|
|
2
2
|
import { Schema } from './schema';
|
|
3
3
|
export declare function hostGenerator(host: Tree, schema: Schema): Promise<GeneratorCallback>;
|
|
4
|
+
export declare function hostGeneratorInternal(host: Tree, schema: Schema): Promise<GeneratorCallback>;
|
|
4
5
|
export default hostGenerator;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.hostGenerator = void 0;
|
|
3
|
+
exports.hostGeneratorInternal = exports.hostGenerator = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const devkit_1 = require("@nx/devkit");
|
|
6
6
|
const application_1 = require("../application/application");
|
|
@@ -12,9 +12,15 @@ const remote_1 = require("../remote/remote");
|
|
|
12
12
|
const setup_ssr_1 = require("../setup-ssr/setup-ssr");
|
|
13
13
|
const setup_ssr_for_host_1 = require("./lib/setup-ssr-for-host");
|
|
14
14
|
function hostGenerator(host, schema) {
|
|
15
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
16
|
+
return hostGeneratorInternal(host, Object.assign({ projectNameAndRootFormat: 'derived' }, schema));
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
exports.hostGenerator = hostGenerator;
|
|
20
|
+
function hostGeneratorInternal(host, schema) {
|
|
15
21
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
16
22
|
const tasks = [];
|
|
17
|
-
const options = (0, normalize_options_1.normalizeOptions)(host, schema);
|
|
23
|
+
const options = yield (0, normalize_options_1.normalizeOptions)(host, schema, '@nx/react:host');
|
|
18
24
|
const initTask = yield (0, application_1.default)(host, Object.assign(Object.assign({}, options), {
|
|
19
25
|
// The target use-case is loading remotes as child routes, thus always enable routing.
|
|
20
26
|
routing: true,
|
|
@@ -62,5 +68,5 @@ function hostGenerator(host, schema) {
|
|
|
62
68
|
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
63
69
|
});
|
|
64
70
|
}
|
|
65
|
-
exports.
|
|
71
|
+
exports.hostGeneratorInternal = hostGeneratorInternal;
|
|
66
72
|
exports.default = hostGenerator;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { ProjectNameAndRootFormat } from '@nx/devkit/src/generators/project-name-and-root-utils';
|
|
2
|
+
import type { Linter } from '@nx/linter';
|
|
3
|
+
import type { SupportedStyles } from '../../../typings';
|
|
3
4
|
|
|
4
5
|
export interface Schema {
|
|
5
6
|
classComponent?: boolean;
|
|
6
7
|
compiler?: 'babel' | 'swc';
|
|
7
8
|
devServerPort?: number;
|
|
8
9
|
directory?: string;
|
|
10
|
+
projectNameAndRootFormat?: ProjectNameAndRootFormat;
|
|
9
11
|
e2eTestRunner: 'cypress' | 'none';
|
|
10
12
|
globalCss?: boolean;
|
|
11
13
|
js?: boolean;
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"index": 0
|
|
15
15
|
},
|
|
16
16
|
"x-prompt": "What name would you like to use as the host application?",
|
|
17
|
-
"pattern": "^[a-zA-Z]
|
|
17
|
+
"pattern": "^[a-zA-Z][^:]*$",
|
|
18
18
|
"x-priority": "important"
|
|
19
19
|
},
|
|
20
20
|
"directory": {
|
|
@@ -23,6 +23,11 @@
|
|
|
23
23
|
"alias": "dir",
|
|
24
24
|
"x-priority": "important"
|
|
25
25
|
},
|
|
26
|
+
"projectNameAndRootFormat": {
|
|
27
|
+
"description": "Whether to generate the project name and root directory as provided (`as-provided`) or generate them composing their values and taking the configured layout into account (`derived`).",
|
|
28
|
+
"type": "string",
|
|
29
|
+
"enum": ["as-provided", "derived"]
|
|
30
|
+
},
|
|
26
31
|
"style": {
|
|
27
32
|
"description": "The file extension to be used for style files.",
|
|
28
33
|
"type": "string",
|
|
@@ -15,7 +15,6 @@ function addRollupBuildTarget(host, options) {
|
|
|
15
15
|
'@svgr/rollup': versions_1.svgrRollupVersion,
|
|
16
16
|
});
|
|
17
17
|
const { targets } = (0, devkit_1.readProjectConfiguration)(host, options.name);
|
|
18
|
-
const { libsDir } = (0, devkit_1.getWorkspaceLayout)(host);
|
|
19
18
|
const external = ['react', 'react-dom'];
|
|
20
19
|
if (options.style === '@emotion/styled') {
|
|
21
20
|
external.push('@emotion/react/jsx-runtime');
|
|
@@ -27,9 +26,7 @@ function addRollupBuildTarget(host, options) {
|
|
|
27
26
|
executor: '@nx/rollup:rollup',
|
|
28
27
|
outputs: ['{options.outputPath}'],
|
|
29
28
|
options: {
|
|
30
|
-
outputPath:
|
|
31
|
-
? `dist/${libsDir}/${options.projectDirectory}`
|
|
32
|
-
: `dist/${options.projectDirectory}`,
|
|
29
|
+
outputPath: (0, devkit_1.joinPathFragments)('dist', options.projectRoot),
|
|
33
30
|
tsConfig: `${options.projectRoot}/tsconfig.lib.json`,
|
|
34
31
|
project: `${options.projectRoot}/package.json`,
|
|
35
32
|
entryFile: (0, maybe_js_1.maybeJs)(options, `${options.projectRoot}/src/index.ts`),
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { Tree } from '@nx/devkit';
|
|
2
2
|
import { NormalizedSchema, Schema } from '../schema';
|
|
3
|
-
export declare function normalizeOptions(host: Tree, options: Schema): NormalizedSchema
|
|
3
|
+
export declare function normalizeOptions(host: Tree, options: Schema): Promise<NormalizedSchema>;
|
|
@@ -1,57 +1,60 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.normalizeOptions = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
4
5
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const
|
|
6
|
+
const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
|
|
6
7
|
const assertion_1 = require("../../../utils/assertion");
|
|
7
8
|
function normalizeOptions(host, options) {
|
|
8
9
|
var _a, _b;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
if (
|
|
26
|
-
|
|
27
|
-
|
|
10
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
11
|
+
const { projectName, names: projectNames, projectRoot, importPath, } = yield (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
|
|
12
|
+
name: options.name,
|
|
13
|
+
projectType: 'library',
|
|
14
|
+
directory: options.directory,
|
|
15
|
+
importPath: options.importPath,
|
|
16
|
+
projectNameAndRootFormat: options.projectNameAndRootFormat,
|
|
17
|
+
callingGenerator: '@nx/react:library',
|
|
18
|
+
});
|
|
19
|
+
const fileName = options.simpleName
|
|
20
|
+
? projectNames.projectSimpleName
|
|
21
|
+
: projectNames.projectFileName;
|
|
22
|
+
const parsedTags = options.tags
|
|
23
|
+
? options.tags.split(',').map((s) => s.trim())
|
|
24
|
+
: [];
|
|
25
|
+
let bundler = (_a = options.bundler) !== null && _a !== void 0 ? _a : 'none';
|
|
26
|
+
if (bundler === 'none') {
|
|
27
|
+
if (options.publishable) {
|
|
28
|
+
devkit_1.logger.warn(`Publishable libraries cannot be used with bundler: 'none'. Defaulting to 'rollup'.`);
|
|
29
|
+
bundler = 'rollup';
|
|
30
|
+
}
|
|
31
|
+
if (options.buildable) {
|
|
32
|
+
devkit_1.logger.warn(`Buildable libraries cannot be used with bundler: 'none'. Defaulting to 'rollup'.`);
|
|
33
|
+
bundler = 'rollup';
|
|
34
|
+
}
|
|
28
35
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
36
|
+
const normalized = Object.assign(Object.assign({}, options), { compiler: (_b = options.compiler) !== null && _b !== void 0 ? _b : 'babel', bundler,
|
|
37
|
+
fileName, routePath: `/${projectNames.projectSimpleName}`, name: projectName, projectRoot,
|
|
38
|
+
parsedTags,
|
|
39
|
+
importPath });
|
|
40
|
+
// Libraries with a bundler or is publishable must also be buildable.
|
|
41
|
+
normalized.buildable = Boolean(normalized.bundler !== 'none' || options.buildable || options.publishable);
|
|
42
|
+
normalized.inSourceTests === normalized.minimal || normalized.inSourceTests;
|
|
43
|
+
if (options.appProject) {
|
|
44
|
+
const appProjectConfig = (0, devkit_1.getProjects)(host).get(options.appProject);
|
|
45
|
+
if (appProjectConfig.projectType !== 'application') {
|
|
46
|
+
throw new Error(`appProject expected type of "application" but got "${appProjectConfig.projectType}"`);
|
|
47
|
+
}
|
|
48
|
+
try {
|
|
49
|
+
normalized.appMain = appProjectConfig.targets.build.options.main;
|
|
50
|
+
normalized.appSourceRoot = (0, devkit_1.normalizePath)(appProjectConfig.sourceRoot);
|
|
51
|
+
}
|
|
52
|
+
catch (e) {
|
|
53
|
+
throw new Error(`Could not locate project main for ${options.appProject}`);
|
|
54
|
+
}
|
|
32
55
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
importPath,
|
|
37
|
-
libsDir });
|
|
38
|
-
// Libraries with a bundler or is publishable must also be buildable.
|
|
39
|
-
normalized.buildable = Boolean(normalized.bundler !== 'none' || options.buildable || options.publishable);
|
|
40
|
-
normalized.inSourceTests === normalized.minimal || normalized.inSourceTests;
|
|
41
|
-
if (options.appProject) {
|
|
42
|
-
const appProjectConfig = (0, devkit_1.getProjects)(host).get(options.appProject);
|
|
43
|
-
if (appProjectConfig.projectType !== 'application') {
|
|
44
|
-
throw new Error(`appProject expected type of "application" but got "${appProjectConfig.projectType}"`);
|
|
45
|
-
}
|
|
46
|
-
try {
|
|
47
|
-
normalized.appMain = appProjectConfig.targets.build.options.main;
|
|
48
|
-
normalized.appSourceRoot = (0, devkit_1.normalizePath)(appProjectConfig.sourceRoot);
|
|
49
|
-
}
|
|
50
|
-
catch (e) {
|
|
51
|
-
throw new Error(`Could not locate project main for ${options.appProject}`);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
(0, assertion_1.assertValidStyle)(normalized.style);
|
|
55
|
-
return normalized;
|
|
56
|
+
(0, assertion_1.assertValidStyle)(normalized.style);
|
|
57
|
+
return normalized;
|
|
58
|
+
});
|
|
56
59
|
}
|
|
57
60
|
exports.normalizeOptions = normalizeOptions;
|
|
@@ -7,7 +7,6 @@ const ast_utils_2 = require("../../../utils/ast-utils");
|
|
|
7
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
|
-
const get_import_path_1 = require("@nx/js/src/utils/get-import-path");
|
|
11
10
|
let tsModule;
|
|
12
11
|
function updateAppRoutes(host, options) {
|
|
13
12
|
if (!options.appMain || !options.appSourceRoot) {
|
|
@@ -43,7 +42,7 @@ function updateAppRoutes(host, options) {
|
|
|
43
42
|
const changes = (0, devkit_1.applyChangesToString)(componentContent, (0, ast_utils_1.addRoute)(appComponentPath, componentSource, {
|
|
44
43
|
routePath: options.routePath,
|
|
45
44
|
componentName: (0, devkit_1.names)(options.name).className,
|
|
46
|
-
moduleName:
|
|
45
|
+
moduleName: options.importPath,
|
|
47
46
|
}));
|
|
48
47
|
host.write(appComponentPath, changes);
|
|
49
48
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { GeneratorCallback, Tree } from '@nx/devkit';
|
|
2
2
|
import { Schema } from './schema';
|
|
3
3
|
export declare function libraryGenerator(host: Tree, schema: Schema): Promise<GeneratorCallback>;
|
|
4
|
+
export declare function libraryGeneratorInternal(host: Tree, schema: Schema): Promise<GeneratorCallback>;
|
|
4
5
|
export default libraryGenerator;
|
|
5
6
|
export declare const librarySchematic: (generatorOptions: Schema) => (tree: any, context: any) => Promise<any>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.librarySchematic = exports.libraryGenerator = void 0;
|
|
3
|
+
exports.librarySchematic = exports.libraryGeneratorInternal = exports.libraryGenerator = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const devkit_1 = require("@nx/devkit");
|
|
6
6
|
const js_1 = require("@nx/js");
|
|
@@ -17,9 +17,15 @@ const create_ts_config_1 = require("../../utils/create-ts-config");
|
|
|
17
17
|
const install_common_dependencies_1 = require("./lib/install-common-dependencies");
|
|
18
18
|
const set_defaults_1 = require("./lib/set-defaults");
|
|
19
19
|
function libraryGenerator(host, schema) {
|
|
20
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
21
|
+
return yield libraryGeneratorInternal(host, Object.assign({ projectNameAndRootFormat: 'derived' }, schema));
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
exports.libraryGenerator = libraryGenerator;
|
|
25
|
+
function libraryGeneratorInternal(host, schema) {
|
|
20
26
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
21
27
|
const tasks = [];
|
|
22
|
-
const options = (0, normalize_options_1.normalizeOptions)(host, schema);
|
|
28
|
+
const options = yield (0, normalize_options_1.normalizeOptions)(host, schema);
|
|
23
29
|
if (options.publishable === true && !schema.importPath) {
|
|
24
30
|
throw new Error(`For publishable libs you have to provide a proper "--importPath" which needs to be a valid npm package name (e.g. my-awesome-lib or @myorg/my-lib)`);
|
|
25
31
|
}
|
|
@@ -126,6 +132,6 @@ function libraryGenerator(host, schema) {
|
|
|
126
132
|
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
127
133
|
});
|
|
128
134
|
}
|
|
129
|
-
exports.
|
|
135
|
+
exports.libraryGeneratorInternal = libraryGeneratorInternal;
|
|
130
136
|
exports.default = libraryGenerator;
|
|
131
137
|
exports.librarySchematic = (0, devkit_1.convertNxGenerator)(libraryGenerator);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import type { ProjectNameAndRootFormat } from '@nx/devkit/src/generators/project-name-and-root-utils';
|
|
1
2
|
import type { Linter } from '@nx/linter';
|
|
2
|
-
import { SupportedStyles } from '../../../typings/style';
|
|
3
|
+
import type { SupportedStyles } from '../../../typings/style';
|
|
3
4
|
|
|
4
5
|
export interface Schema {
|
|
5
6
|
appProject?: string;
|
|
@@ -8,6 +9,7 @@ export interface Schema {
|
|
|
8
9
|
compiler?: 'babel' | 'swc';
|
|
9
10
|
component?: boolean;
|
|
10
11
|
directory?: string;
|
|
12
|
+
projectNameAndRootFormat?: ProjectNameAndRootFormat;
|
|
11
13
|
globalCss?: boolean;
|
|
12
14
|
importPath?: string;
|
|
13
15
|
inSourceTests?: boolean;
|
|
@@ -35,10 +37,8 @@ export interface NormalizedSchema extends Schema {
|
|
|
35
37
|
fileName: string;
|
|
36
38
|
projectRoot: string;
|
|
37
39
|
routePath: string;
|
|
38
|
-
projectDirectory: string;
|
|
39
40
|
parsedTags: string[];
|
|
40
41
|
appMain?: string;
|
|
41
42
|
appSourceRoot?: string;
|
|
42
|
-
libsDir?: string;
|
|
43
43
|
unitTestRunner: 'jest' | 'vitest' | 'none';
|
|
44
44
|
}
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"index": 0
|
|
25
25
|
},
|
|
26
26
|
"x-prompt": "What name would you like to use for the library?",
|
|
27
|
-
"pattern": "
|
|
27
|
+
"pattern": "(?:^@[a-zA-Z0-9-*~][a-zA-Z0-9-*._~]*\\/[a-zA-Z0-9-~][a-zA-Z0-9-._~]*|^[a-zA-Z][^:]*)$",
|
|
28
28
|
"x-priority": "important"
|
|
29
29
|
},
|
|
30
30
|
"directory": {
|
|
@@ -33,6 +33,11 @@
|
|
|
33
33
|
"alias": "dir",
|
|
34
34
|
"x-priority": "important"
|
|
35
35
|
},
|
|
36
|
+
"projectNameAndRootFormat": {
|
|
37
|
+
"description": "Whether to generate the project name and root directory as provided (`as-provided`) or generate them composing their values and taking the configured layout into account (`derived`).",
|
|
38
|
+
"type": "string",
|
|
39
|
+
"enum": ["as-provided", "derived"]
|
|
40
|
+
},
|
|
36
41
|
"style": {
|
|
37
42
|
"description": "The file extension to be used for style files.",
|
|
38
43
|
"type": "string",
|
|
@@ -3,4 +3,5 @@ import { NormalizedSchema } from '../application/schema';
|
|
|
3
3
|
import { Schema } from './schema';
|
|
4
4
|
export declare function addModuleFederationFiles(host: Tree, options: NormalizedSchema): void;
|
|
5
5
|
export declare function remoteGenerator(host: Tree, schema: Schema): Promise<GeneratorCallback>;
|
|
6
|
+
export declare function remoteGeneratorInternal(host: Tree, schema: Schema): Promise<GeneratorCallback>;
|
|
6
7
|
export default remoteGenerator;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.remoteGenerator = exports.addModuleFederationFiles = void 0;
|
|
3
|
+
exports.remoteGeneratorInternal = exports.remoteGenerator = exports.addModuleFederationFiles = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const path_1 = require("path");
|
|
6
6
|
const devkit_1 = require("@nx/devkit");
|
|
@@ -16,9 +16,15 @@ function addModuleFederationFiles(host, options) {
|
|
|
16
16
|
}
|
|
17
17
|
exports.addModuleFederationFiles = addModuleFederationFiles;
|
|
18
18
|
function remoteGenerator(host, schema) {
|
|
19
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
return yield remoteGeneratorInternal(host, Object.assign({ projectNameAndRootFormat: 'derived' }, schema));
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
exports.remoteGenerator = remoteGenerator;
|
|
24
|
+
function remoteGeneratorInternal(host, schema) {
|
|
19
25
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
20
26
|
const tasks = [];
|
|
21
|
-
const options = (0, normalize_options_1.normalizeOptions)(host, schema);
|
|
27
|
+
const options = yield (0, normalize_options_1.normalizeOptions)(host, schema, '@nx/react:remote');
|
|
22
28
|
const initAppTask = yield (0, application_1.default)(host, Object.assign(Object.assign({}, options), {
|
|
23
29
|
// Only webpack works with module federation for now.
|
|
24
30
|
bundler: 'webpack', skipFormat: true }));
|
|
@@ -51,5 +57,5 @@ function remoteGenerator(host, schema) {
|
|
|
51
57
|
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
52
58
|
});
|
|
53
59
|
}
|
|
54
|
-
exports.
|
|
60
|
+
exports.remoteGeneratorInternal = remoteGeneratorInternal;
|
|
55
61
|
exports.default = remoteGenerator;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { SupportedStyles } from '../../../typings';
|
|
1
|
+
import type { ProjectNameAndRootFormat } from '@nx/devkit/src/generators/project-name-and-root-utils';
|
|
2
|
+
import type { Linter } from '@nx/linter';
|
|
3
|
+
import type { SupportedStyles } from '../../../typings';
|
|
4
4
|
|
|
5
5
|
export interface Schema {
|
|
6
6
|
classComponent?: boolean;
|
|
7
7
|
compiler?: 'babel' | 'swc';
|
|
8
8
|
devServerPort?: number;
|
|
9
9
|
directory?: string;
|
|
10
|
+
projectNameAndRootFormat?: ProjectNameAndRootFormat;
|
|
10
11
|
e2eTestRunner: 'cypress' | 'none';
|
|
11
12
|
globalCss?: boolean;
|
|
12
13
|
host?: string;
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"index": 0
|
|
15
15
|
},
|
|
16
16
|
"x-prompt": "What name would you like to use as the remote application?",
|
|
17
|
-
"pattern": "^[a-zA-Z]
|
|
17
|
+
"pattern": "^[a-zA-Z][^:]*$",
|
|
18
18
|
"x-priority": "important"
|
|
19
19
|
},
|
|
20
20
|
"directory": {
|
|
@@ -23,6 +23,11 @@
|
|
|
23
23
|
"alias": "dir",
|
|
24
24
|
"x-priority": "important"
|
|
25
25
|
},
|
|
26
|
+
"projectNameAndRootFormat": {
|
|
27
|
+
"description": "Whether to generate the project name and root directory as provided (`as-provided`) or generate them composing their values and taking the configured layout into account (`derived`).",
|
|
28
|
+
"type": "string",
|
|
29
|
+
"enum": ["as-provided", "derived"]
|
|
30
|
+
},
|
|
26
31
|
"style": {
|
|
27
32
|
"description": "The file extension to be used for style files.",
|
|
28
33
|
"type": "string",
|