@nx/react 0.0.0-pr-29860-d639246 → 0.0.0-pr-3-e51e28c
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +6 -6
- package/src/generators/application/application.js +5 -6
- package/src/generators/application/lib/add-e2e.js +22 -25
- package/src/generators/application/lib/add-project.js +15 -20
- package/src/generators/application/lib/create-application-files.js +1 -1
- package/src/generators/application/lib/normalize-options.d.ts +2 -0
- package/src/generators/application/lib/normalize-options.js +20 -8
- package/src/generators/application/schema.d.ts +1 -4
- package/src/generators/application/schema.json +0 -4
- package/src/generators/host/host.js +3 -6
- package/src/generators/library/lib/add-rollup-build-target.d.ts +1 -3
- package/src/generators/library/lib/add-rollup-build-target.js +7 -6
- package/src/generators/library/lib/create-files.js +1 -2
- package/src/generators/library/lib/normalize-options.js +5 -8
- package/src/generators/library/library.js +13 -19
- package/src/generators/library/schema.d.ts +0 -2
- package/src/generators/library/schema.json +0 -4
- package/src/generators/remote/remote.js +9 -12
- package/src/utils/versions.d.ts +2 -2
- package/src/utils/versions.js +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/react",
|
|
3
|
-
"version": "0.0.0-pr-
|
|
3
|
+
"version": "0.0.0-pr-3-e51e28c",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The React plugin for Nx contains executors and generators for managing React applications and libraries within an Nx workspace. It provides:\n\n\n- Integration with libraries such as Jest, Vitest, Playwright, Cypress, and Storybook.\n\n- Generators for applications, libraries, components, hooks, and more.\n\n- Library build support for publishing packages to npm or other registries.\n\n- Utilities for automatic workspace refactoring.",
|
|
6
6
|
"repository": {
|
|
@@ -38,11 +38,11 @@
|
|
|
38
38
|
"minimatch": "9.0.3",
|
|
39
39
|
"picocolors": "^1.1.0",
|
|
40
40
|
"tslib": "^2.3.0",
|
|
41
|
-
"@nx/devkit": "0.0.0-pr-
|
|
42
|
-
"@nx/js": "0.0.0-pr-
|
|
43
|
-
"@nx/eslint": "0.0.0-pr-
|
|
44
|
-
"@nx/web": "0.0.0-pr-
|
|
45
|
-
"@nx/module-federation": "0.0.0-pr-
|
|
41
|
+
"@nx/devkit": "0.0.0-pr-3-e51e28c",
|
|
42
|
+
"@nx/js": "0.0.0-pr-3-e51e28c",
|
|
43
|
+
"@nx/eslint": "0.0.0-pr-3-e51e28c",
|
|
44
|
+
"@nx/web": "0.0.0-pr-3-e51e28c",
|
|
45
|
+
"@nx/module-federation": "0.0.0-pr-3-e51e28c",
|
|
46
46
|
"express": "^4.21.2",
|
|
47
47
|
"http-proxy-middleware": "^3.0.3",
|
|
48
48
|
"semver": "^7.6.3"
|
|
@@ -29,7 +29,6 @@ const sort_fields_1 = require("@nx/js/src/utils/package-json/sort-fields");
|
|
|
29
29
|
async function applicationGenerator(tree, schema) {
|
|
30
30
|
return await applicationGeneratorInternal(tree, {
|
|
31
31
|
addPlugin: false,
|
|
32
|
-
useProjectJson: true,
|
|
33
32
|
...schema,
|
|
34
33
|
});
|
|
35
34
|
}
|
|
@@ -45,6 +44,11 @@ async function applicationGeneratorInternal(tree, schema) {
|
|
|
45
44
|
});
|
|
46
45
|
tasks.push(jsInitTask);
|
|
47
46
|
const options = await (0, normalize_options_1.normalizeOptions)(tree, schema);
|
|
47
|
+
// If we are using the new TS solution
|
|
48
|
+
// We need to update the workspace file (package.json or pnpm-workspaces.yaml) to include the new project
|
|
49
|
+
if (options.isUsingTsSolutionConfig) {
|
|
50
|
+
(0, ts_solution_setup_1.addProjectToTsSolutionWorkspace)(tree, options.appProjectRoot);
|
|
51
|
+
}
|
|
48
52
|
(0, show_possible_warnings_1.showPossibleWarnings)(tree, options);
|
|
49
53
|
const initTask = await (0, init_1.default)(tree, {
|
|
50
54
|
...options,
|
|
@@ -79,11 +83,6 @@ async function applicationGeneratorInternal(tree, schema) {
|
|
|
79
83
|
}
|
|
80
84
|
await (0, create_application_files_1.createApplicationFiles)(tree, options);
|
|
81
85
|
(0, add_project_1.addProject)(tree, options);
|
|
82
|
-
// If we are using the new TS solution
|
|
83
|
-
// We need to update the workspace file (package.json or pnpm-workspaces.yaml) to include the new project
|
|
84
|
-
if (options.isUsingTsSolutionConfig) {
|
|
85
|
-
await (0, ts_solution_setup_1.addProjectToTsSolutionWorkspace)(tree, options.appProjectRoot);
|
|
86
|
-
}
|
|
87
86
|
if (options.style === 'tailwind') {
|
|
88
87
|
const twTask = await (0, setup_tailwind_1.setupTailwindGenerator)(tree, {
|
|
89
88
|
project: options.projectName,
|
|
@@ -46,15 +46,17 @@ async function addE2e(tree, options) {
|
|
|
46
46
|
switch (options.e2eTestRunner) {
|
|
47
47
|
case 'cypress': {
|
|
48
48
|
const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/cypress', versions_1.nxVersion);
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
49
|
+
if (options.isUsingTsSolutionConfig) {
|
|
50
|
+
(0, devkit_1.writeJson)(tree, (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'package.json'), {
|
|
51
|
+
name: options.e2eProjectName,
|
|
52
|
+
version: '0.0.1',
|
|
53
|
+
private: true,
|
|
54
|
+
nx: {
|
|
55
|
+
projectType: 'application',
|
|
56
|
+
sourceRoot: (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'src'),
|
|
57
|
+
implicitDependencies: [options.projectName],
|
|
58
|
+
},
|
|
59
|
+
});
|
|
58
60
|
}
|
|
59
61
|
else {
|
|
60
62
|
(0, devkit_1.addProjectConfiguration)(tree, options.e2eProjectName, {
|
|
@@ -66,9 +68,6 @@ async function addE2e(tree, options) {
|
|
|
66
68
|
tags: [],
|
|
67
69
|
});
|
|
68
70
|
}
|
|
69
|
-
if (!options.useProjectJson || options.isUsingTsSolutionConfig) {
|
|
70
|
-
(0, devkit_1.writeJson)(tree, (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'package.json'), packageJson);
|
|
71
|
-
}
|
|
72
71
|
const e2eTask = await configurationGenerator(tree, {
|
|
73
72
|
...options,
|
|
74
73
|
project: options.e2eProjectName,
|
|
@@ -117,15 +116,17 @@ async function addE2e(tree, options) {
|
|
|
117
116
|
}
|
|
118
117
|
case 'playwright': {
|
|
119
118
|
const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/playwright', versions_1.nxVersion);
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
119
|
+
if (options.isUsingTsSolutionConfig) {
|
|
120
|
+
(0, devkit_1.writeJson)(tree, (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'package.json'), {
|
|
121
|
+
name: options.e2eProjectName,
|
|
122
|
+
version: '0.0.1',
|
|
123
|
+
private: true,
|
|
124
|
+
nx: {
|
|
125
|
+
projectType: 'application',
|
|
126
|
+
sourceRoot: (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'src'),
|
|
127
|
+
implicitDependencies: [options.projectName],
|
|
128
|
+
},
|
|
129
|
+
});
|
|
129
130
|
}
|
|
130
131
|
else {
|
|
131
132
|
(0, devkit_1.addProjectConfiguration)(tree, options.e2eProjectName, {
|
|
@@ -134,12 +135,8 @@ async function addE2e(tree, options) {
|
|
|
134
135
|
sourceRoot: (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'src'),
|
|
135
136
|
targets: {},
|
|
136
137
|
implicitDependencies: [options.projectName],
|
|
137
|
-
tags: [],
|
|
138
138
|
});
|
|
139
139
|
}
|
|
140
|
-
if (!options.useProjectJson || options.isUsingTsSolutionConfig) {
|
|
141
|
-
(0, devkit_1.writeJson)(tree, (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'package.json'), packageJson);
|
|
142
|
-
}
|
|
143
140
|
const e2eTask = await configurationGenerator(tree, {
|
|
144
141
|
project: options.e2eProjectName,
|
|
145
142
|
skipFormat: true,
|
|
@@ -28,31 +28,26 @@ function addProject(host, options) {
|
|
|
28
28
|
serve: createRspackServeTarget(options),
|
|
29
29
|
};
|
|
30
30
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
if (options.projectName !== options.importPath) {
|
|
38
|
-
packageJson.nx = { name: options.projectName };
|
|
39
|
-
}
|
|
40
|
-
if (Object.keys(project.targets).length) {
|
|
41
|
-
packageJson.nx ??= {};
|
|
42
|
-
packageJson.nx.targets = project.targets;
|
|
43
|
-
}
|
|
44
|
-
if (options.parsedTags?.length) {
|
|
45
|
-
packageJson.nx ??= {};
|
|
46
|
-
packageJson.nx.tags = options.parsedTags;
|
|
47
|
-
}
|
|
31
|
+
if (options.isUsingTsSolutionConfig) {
|
|
32
|
+
(0, devkit_1.writeJson)(host, (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'package.json'), {
|
|
33
|
+
name: options.projectName,
|
|
34
|
+
version: '0.0.1',
|
|
35
|
+
private: true,
|
|
36
|
+
});
|
|
48
37
|
}
|
|
49
|
-
|
|
38
|
+
if (!options.isUsingTsSolutionConfig || options.alwaysGenerateProjectJson) {
|
|
50
39
|
(0, devkit_1.addProjectConfiguration)(host, options.projectName, {
|
|
51
40
|
...project,
|
|
52
41
|
});
|
|
53
42
|
}
|
|
54
|
-
if (
|
|
55
|
-
|
|
43
|
+
else if (options.parsedTags?.length ||
|
|
44
|
+
Object.keys(project.targets).length) {
|
|
45
|
+
const updatedProject = {
|
|
46
|
+
root: options.appProjectRoot,
|
|
47
|
+
targets: project.targets,
|
|
48
|
+
tags: options.parsedTags?.length ? options.parsedTags : undefined,
|
|
49
|
+
};
|
|
50
|
+
(0, devkit_1.updateProjectConfiguration)(host, options.projectName, updatedProject);
|
|
56
51
|
}
|
|
57
52
|
}
|
|
58
53
|
function createRspackBuildTarget(options) {
|
|
@@ -39,7 +39,7 @@ async function createApplicationFiles(host, options) {
|
|
|
39
39
|
const relativePathToRootTsConfig = (0, js_1.getRelativePathToRootTsConfig)(host, options.appProjectRoot);
|
|
40
40
|
const appTests = (0, get_app_tests_1.getAppTests)(options);
|
|
41
41
|
const templateVariables = {
|
|
42
|
-
...options.
|
|
42
|
+
...(0, devkit_1.names)(options.name),
|
|
43
43
|
...options,
|
|
44
44
|
js: !!options.js, // Ensure this is defined in template
|
|
45
45
|
tmpl: '',
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import { Tree } from '@nx/devkit';
|
|
2
2
|
import { NormalizedSchema, Schema } from '../schema';
|
|
3
|
+
export declare function normalizeDirectory(options: Schema): string;
|
|
4
|
+
export declare function normalizeProjectName(options: Schema): string;
|
|
3
5
|
export declare function normalizeOptions<T extends Schema = Schema>(host: Tree, options: Schema): Promise<NormalizedSchema<T>>;
|
|
@@ -1,14 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.normalizeDirectory = normalizeDirectory;
|
|
4
|
+
exports.normalizeProjectName = normalizeProjectName;
|
|
3
5
|
exports.normalizeOptions = normalizeOptions;
|
|
4
6
|
const devkit_1 = require("@nx/devkit");
|
|
5
7
|
const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
|
|
6
8
|
const assertion_1 = require("../../../utils/assertion");
|
|
7
9
|
const find_free_port_1 = require("./find-free-port");
|
|
8
10
|
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
11
|
+
const get_import_path_1 = require("@nx/js/src/utils/get-import-path");
|
|
12
|
+
function normalizeDirectory(options) {
|
|
13
|
+
options.directory = options.directory?.replace(/\\{1,2}/g, '/');
|
|
14
|
+
const { projectDirectory } = (0, devkit_1.extractLayoutDirectory)(options.directory);
|
|
15
|
+
return projectDirectory
|
|
16
|
+
? `${(0, devkit_1.names)(projectDirectory).fileName}/${(0, devkit_1.names)(options.name).fileName}`
|
|
17
|
+
: (0, devkit_1.names)(options.name).fileName;
|
|
18
|
+
}
|
|
19
|
+
function normalizeProjectName(options) {
|
|
20
|
+
return normalizeDirectory(options).replace(new RegExp('/', 'g'), '-');
|
|
21
|
+
}
|
|
9
22
|
async function normalizeOptions(host, options) {
|
|
10
|
-
await (0, project_name_and_root_utils_1.
|
|
11
|
-
const { projectName
|
|
23
|
+
await (0, project_name_and_root_utils_1.ensureProjectName)(host, options, 'application');
|
|
24
|
+
const { projectName: appProjectName, projectRoot: appProjectRoot } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
|
|
12
25
|
name: options.name,
|
|
13
26
|
projectType: 'application',
|
|
14
27
|
directory: options.directory,
|
|
@@ -19,8 +32,6 @@ async function normalizeOptions(host, options) {
|
|
|
19
32
|
nxJson.useInferencePlugins !== false;
|
|
20
33
|
options.addPlugin ??= addPlugin;
|
|
21
34
|
options.rootProject = appProjectRoot === '.';
|
|
22
|
-
const isUsingTsSolutionConfig = (0, ts_solution_setup_1.isUsingTsSolutionSetup)(host);
|
|
23
|
-
const appProjectName = !isUsingTsSolutionConfig || options.name ? projectName : importPath;
|
|
24
35
|
const e2eProjectName = options.rootProject ? 'e2e' : `${appProjectName}-e2e`;
|
|
25
36
|
const e2eProjectRoot = options.rootProject ? 'e2e' : `${appProjectRoot}-e2e`;
|
|
26
37
|
const parsedTags = options.tags
|
|
@@ -31,20 +42,21 @@ async function normalizeOptions(host, options) {
|
|
|
31
42
|
? null
|
|
32
43
|
: options.style;
|
|
33
44
|
(0, assertion_1.assertValidStyle)(options.style);
|
|
45
|
+
const isUsingTsSolutionConfig = (0, ts_solution_setup_1.isUsingTsSolutionSetup)(host);
|
|
34
46
|
const normalized = {
|
|
35
47
|
...options,
|
|
36
|
-
|
|
48
|
+
name: appProjectName,
|
|
49
|
+
projectName: isUsingTsSolutionConfig
|
|
50
|
+
? (0, get_import_path_1.getImportPath)(host, appProjectName)
|
|
51
|
+
: appProjectName,
|
|
37
52
|
appProjectRoot,
|
|
38
|
-
importPath,
|
|
39
53
|
e2eProjectName,
|
|
40
54
|
e2eProjectRoot,
|
|
41
55
|
parsedTags,
|
|
42
56
|
fileName,
|
|
43
57
|
styledModule,
|
|
44
58
|
hasStyles: options.style !== 'none',
|
|
45
|
-
names: (0, devkit_1.names)(projectNames.projectSimpleName),
|
|
46
59
|
isUsingTsSolutionConfig,
|
|
47
|
-
useProjectJson: options.useProjectJson ?? !isUsingTsSolutionConfig,
|
|
48
60
|
};
|
|
49
61
|
normalized.routing = normalized.routing ?? false;
|
|
50
62
|
normalized.strict = normalized.strict ?? true;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { names } from '@nx/devkit';
|
|
2
1
|
import type { Linter, LinterType } from '@nx/eslint';
|
|
3
2
|
import type { SupportedStyles } from '../../../typings/style';
|
|
4
3
|
|
|
@@ -31,7 +30,7 @@ export interface Schema {
|
|
|
31
30
|
nxCloudToken?: string;
|
|
32
31
|
useTsSolution?: boolean;
|
|
33
32
|
formatter?: 'prettier' | 'none';
|
|
34
|
-
|
|
33
|
+
alwaysGenerateProjectJson?: boolean; // this is needed for MF currently
|
|
35
34
|
}
|
|
36
35
|
|
|
37
36
|
export interface NormalizedSchema<T extends Schema = Schema> extends T {
|
|
@@ -39,13 +38,11 @@ export interface NormalizedSchema<T extends Schema = Schema> extends T {
|
|
|
39
38
|
appProjectRoot: string;
|
|
40
39
|
e2eProjectName: string;
|
|
41
40
|
e2eProjectRoot: string;
|
|
42
|
-
importPath: string;
|
|
43
41
|
parsedTags: string[];
|
|
44
42
|
fileName: string;
|
|
45
43
|
styledModule: null | SupportedStyles;
|
|
46
44
|
hasStyles: boolean;
|
|
47
45
|
unitTestRunner: 'jest' | 'vitest' | 'none';
|
|
48
46
|
addPlugin?: boolean;
|
|
49
|
-
names: ReturnType<typeof names>;
|
|
50
47
|
isUsingTsSolutionConfig?: boolean;
|
|
51
48
|
}
|
|
@@ -187,10 +187,6 @@
|
|
|
187
187
|
"description": "Generate a React app with a minimal setup, no separate test files.",
|
|
188
188
|
"type": "boolean",
|
|
189
189
|
"default": false
|
|
190
|
-
},
|
|
191
|
-
"useProjectJson": {
|
|
192
|
-
"type": "boolean",
|
|
193
|
-
"description": "Use a `project.json` configuration file instead of inlining the Nx configuration in the `package.json` file."
|
|
194
190
|
}
|
|
195
191
|
},
|
|
196
192
|
"required": ["directory"],
|
|
@@ -19,10 +19,7 @@ const update_module_federation_tsconfig_1 = require("./lib/update-module-federat
|
|
|
19
19
|
async function hostGenerator(host, schema) {
|
|
20
20
|
const tasks = [];
|
|
21
21
|
const options = {
|
|
22
|
-
...(await (0, normalize_options_1.normalizeOptions)(host,
|
|
23
|
-
...schema,
|
|
24
|
-
useProjectJson: true,
|
|
25
|
-
})),
|
|
22
|
+
...(await (0, normalize_options_1.normalizeOptions)(host, schema)),
|
|
26
23
|
js: schema.js ?? false,
|
|
27
24
|
typescriptConfiguration: schema.js
|
|
28
25
|
? false
|
|
@@ -42,7 +39,7 @@ async function hostGenerator(host, schema) {
|
|
|
42
39
|
}
|
|
43
40
|
});
|
|
44
41
|
}
|
|
45
|
-
await (0, project_name_and_root_utils_1.
|
|
42
|
+
await (0, project_name_and_root_utils_1.ensureProjectName)(host, options, 'application');
|
|
46
43
|
const initTask = await (0, application_1.default)(host, {
|
|
47
44
|
...options,
|
|
48
45
|
directory: options.appProjectRoot,
|
|
@@ -50,7 +47,7 @@ async function hostGenerator(host, schema) {
|
|
|
50
47
|
// The target use-case is loading remotes as child routes, thus always enable routing.
|
|
51
48
|
routing: true,
|
|
52
49
|
skipFormat: true,
|
|
53
|
-
|
|
50
|
+
alwaysGenerateProjectJson: true,
|
|
54
51
|
});
|
|
55
52
|
tasks.push(initTask);
|
|
56
53
|
const remotesWithPorts = [];
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import { Tree } from 'nx/src/generators/tree';
|
|
2
2
|
import { GeneratorCallback } from '@nx/devkit';
|
|
3
3
|
import { NormalizedSchema } from '../schema';
|
|
4
|
-
export declare function addRollupBuildTarget(host: Tree, options: NormalizedSchema
|
|
5
|
-
format?: Array<'esm' | 'cjs'>;
|
|
6
|
-
}, external?: Set<String>): Promise<GeneratorCallback>;
|
|
4
|
+
export declare function addRollupBuildTarget(host: Tree, options: NormalizedSchema): Promise<GeneratorCallback>;
|
|
@@ -4,7 +4,7 @@ exports.addRollupBuildTarget = addRollupBuildTarget;
|
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const maybe_js_1 = require("../../../utils/maybe-js");
|
|
6
6
|
const versions_1 = require("../../../utils/versions");
|
|
7
|
-
async function addRollupBuildTarget(host, options
|
|
7
|
+
async function addRollupBuildTarget(host, options) {
|
|
8
8
|
const tasks = [];
|
|
9
9
|
const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/rollup', versions_1.nxVersion);
|
|
10
10
|
tasks.push(await configurationGenerator(host, {
|
|
@@ -19,11 +19,12 @@ async function addRollupBuildTarget(host, options, external = new Set(['react',
|
|
|
19
19
|
'@svgr/rollup': versions_1.svgrRollupVersion,
|
|
20
20
|
}));
|
|
21
21
|
}
|
|
22
|
+
const external = ['react', 'react-dom'];
|
|
22
23
|
if (options.style === '@emotion/styled') {
|
|
23
|
-
external.
|
|
24
|
+
external.push('@emotion/react/jsx-runtime');
|
|
24
25
|
}
|
|
25
26
|
else {
|
|
26
|
-
external.
|
|
27
|
+
external.push('react/jsx-runtime');
|
|
27
28
|
}
|
|
28
29
|
const nxJson = (0, devkit_1.readNxJson)(host);
|
|
29
30
|
const hasRollupPlugin = !!nxJson.plugins?.some((p) => typeof p === 'string'
|
|
@@ -43,8 +44,8 @@ module.exports = withNx(
|
|
|
43
44
|
: (0, devkit_1.joinPathFragments)((0, devkit_1.offsetFromRoot)(options.projectRoot), 'dist', options.projectRoot)}',
|
|
44
45
|
tsConfig: './tsconfig.lib.json',
|
|
45
46
|
compiler: '${options.compiler ?? 'babel'}',
|
|
46
|
-
external: ${JSON.stringify(
|
|
47
|
-
format:
|
|
47
|
+
external: ${JSON.stringify(external)},
|
|
48
|
+
format: ['esm'],
|
|
48
49
|
assets:[{ input: '.', output: '.', glob: 'README.md'}],
|
|
49
50
|
}, {
|
|
50
51
|
// Provide additional rollup configuration here. See: https://rollupjs.org/configuration-options
|
|
@@ -73,7 +74,7 @@ module.exports = withNx(
|
|
|
73
74
|
tsConfig: `${options.projectRoot}/tsconfig.lib.json`,
|
|
74
75
|
project: `${options.projectRoot}/package.json`,
|
|
75
76
|
entryFile: (0, maybe_js_1.maybeJs)(options, `${options.projectRoot}/src/index.ts`),
|
|
76
|
-
external
|
|
77
|
+
external,
|
|
77
78
|
rollupConfig: `@nx/react/plugins/bundle-rollup`,
|
|
78
79
|
compiler: options.compiler ?? 'babel',
|
|
79
80
|
assets: [
|
|
@@ -43,8 +43,7 @@ function createFiles(host, options) {
|
|
|
43
43
|
});
|
|
44
44
|
}
|
|
45
45
|
if ((options.publishable || options.buildable) &&
|
|
46
|
-
!options.isUsingTsSolutionConfig
|
|
47
|
-
options.useProjectJson) {
|
|
46
|
+
!options.isUsingTsSolutionConfig) {
|
|
48
47
|
if (options.bundler === 'vite') {
|
|
49
48
|
(0, devkit_1.writeJson)(host, `${options.projectRoot}/package.json`, {
|
|
50
49
|
name: options.importPath,
|
|
@@ -7,7 +7,7 @@ const assertion_1 = require("../../../utils/assertion");
|
|
|
7
7
|
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
8
8
|
async function normalizeOptions(host, options) {
|
|
9
9
|
const isUsingTsSolutionConfig = (0, ts_solution_setup_1.isUsingTsSolutionSetup)(host);
|
|
10
|
-
await (0, project_name_and_root_utils_1.
|
|
10
|
+
await (0, project_name_and_root_utils_1.ensureProjectName)(host, options, 'library');
|
|
11
11
|
const { projectName, names: projectNames, projectRoot, importPath, } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
|
|
12
12
|
name: options.name,
|
|
13
13
|
projectType: 'library',
|
|
@@ -41,26 +41,23 @@ async function normalizeOptions(host, options) {
|
|
|
41
41
|
bundler,
|
|
42
42
|
fileName,
|
|
43
43
|
routePath: `/${projectNames.projectSimpleName}`,
|
|
44
|
-
name: isUsingTsSolutionConfig
|
|
44
|
+
name: isUsingTsSolutionConfig ? importPath : projectName,
|
|
45
45
|
projectRoot,
|
|
46
46
|
parsedTags,
|
|
47
47
|
importPath,
|
|
48
|
-
useProjectJson: options.useProjectJson ?? !isUsingTsSolutionConfig,
|
|
49
48
|
};
|
|
50
49
|
// Libraries with a bundler or is publishable must also be buildable.
|
|
51
50
|
normalized.buildable = Boolean(normalized.bundler !== 'none' || options.buildable || options.publishable);
|
|
52
51
|
normalized.inSourceTests === normalized.minimal || normalized.inSourceTests;
|
|
53
52
|
if (options.appProject) {
|
|
54
53
|
const appProjectConfig = (0, devkit_1.getProjects)(host).get(options.appProject);
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
throw new Error(`appProject expected type of "application" but got "${appProjectType}"`);
|
|
54
|
+
if (appProjectConfig.projectType !== 'application') {
|
|
55
|
+
throw new Error(`appProject expected type of "application" but got "${appProjectConfig.projectType}"`);
|
|
58
56
|
}
|
|
59
|
-
const appSourceRoot = (0, ts_solution_setup_1.getProjectSourceRoot)(host, appProjectConfig.sourceRoot, appProjectConfig.root);
|
|
60
57
|
normalized.appMain =
|
|
61
58
|
appProjectConfig.targets.build?.options?.main ??
|
|
62
59
|
findMainEntry(host, appProjectConfig.root);
|
|
63
|
-
normalized.appSourceRoot = (0, devkit_1.normalizePath)(
|
|
60
|
+
normalized.appSourceRoot = (0, devkit_1.normalizePath)(appProjectConfig.sourceRoot);
|
|
64
61
|
// TODO(jack): We should use appEntryFile instead of appProject so users can directly set it rather than us inferring it.
|
|
65
62
|
if (!normalized.appMain) {
|
|
66
63
|
throw new Error(`Could not locate project main for ${options.appProject}`);
|
|
@@ -27,7 +27,6 @@ const add_release_config_1 = require("@nx/js/src/generators/library/utils/add-re
|
|
|
27
27
|
async function libraryGenerator(host, schema) {
|
|
28
28
|
return await libraryGeneratorInternal(host, {
|
|
29
29
|
addPlugin: false,
|
|
30
|
-
useProjectJson: true,
|
|
31
30
|
...schema,
|
|
32
31
|
});
|
|
33
32
|
}
|
|
@@ -40,7 +39,7 @@ async function libraryGeneratorInternal(host, schema) {
|
|
|
40
39
|
tasks.push(jsInitTask);
|
|
41
40
|
const options = await (0, normalize_options_1.normalizeOptions)(host, schema);
|
|
42
41
|
if (options.isUsingTsSolutionConfig) {
|
|
43
|
-
|
|
42
|
+
(0, ts_solution_setup_1.addProjectToTsSolutionWorkspace)(host, options.projectRoot);
|
|
44
43
|
}
|
|
45
44
|
if (options.publishable === true && !schema.importPath) {
|
|
46
45
|
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)`);
|
|
@@ -53,20 +52,18 @@ async function libraryGeneratorInternal(host, schema) {
|
|
|
53
52
|
skipFormat: true,
|
|
54
53
|
});
|
|
55
54
|
tasks.push(initTask);
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
packageJson.nx.tags = options.parsedTags;
|
|
69
|
-
}
|
|
55
|
+
if (options.isUsingTsSolutionConfig) {
|
|
56
|
+
(0, devkit_1.writeJson)(host, `${options.projectRoot}/package.json`, {
|
|
57
|
+
name: options.importPath ?? options.name,
|
|
58
|
+
version: '0.0.1',
|
|
59
|
+
...(0, determine_entry_fields_1.determineEntryFields)(options),
|
|
60
|
+
nx: options.parsedTags?.length
|
|
61
|
+
? {
|
|
62
|
+
tags: options.parsedTags,
|
|
63
|
+
}
|
|
64
|
+
: undefined,
|
|
65
|
+
files: options.publishable ? ['dist', '!**/*.tsbuildinfo'] : undefined,
|
|
66
|
+
});
|
|
70
67
|
}
|
|
71
68
|
else {
|
|
72
69
|
(0, devkit_1.addProjectConfiguration)(host, options.name, {
|
|
@@ -77,9 +74,6 @@ async function libraryGeneratorInternal(host, schema) {
|
|
|
77
74
|
targets: {},
|
|
78
75
|
});
|
|
79
76
|
}
|
|
80
|
-
if (!options.useProjectJson || options.isUsingTsSolutionConfig) {
|
|
81
|
-
(0, devkit_1.writeJson)(host, `${options.projectRoot}/package.json`, packageJson);
|
|
82
|
-
}
|
|
83
77
|
(0, create_files_1.createFiles)(host, options);
|
|
84
78
|
const lintTask = await (0, add_linting_1.addLinting)(host, options);
|
|
85
79
|
tasks.push(lintTask);
|
|
@@ -27,7 +27,6 @@ export interface Schema {
|
|
|
27
27
|
minimal?: boolean;
|
|
28
28
|
simpleName?: boolean;
|
|
29
29
|
addPlugin?: boolean;
|
|
30
|
-
useProjectJson?: boolean;
|
|
31
30
|
}
|
|
32
31
|
|
|
33
32
|
export interface NormalizedSchema extends Schema {
|
|
@@ -37,7 +36,6 @@ export interface NormalizedSchema extends Schema {
|
|
|
37
36
|
projectRoot: string;
|
|
38
37
|
routePath: string;
|
|
39
38
|
parsedTags: string[];
|
|
40
|
-
importPath: string;
|
|
41
39
|
appMain?: string;
|
|
42
40
|
appSourceRoot?: string;
|
|
43
41
|
unitTestRunner: 'jest' | 'vitest' | 'none';
|
|
@@ -190,10 +190,6 @@
|
|
|
190
190
|
"description": "Don't include the directory in the name of the module of the library.",
|
|
191
191
|
"type": "boolean",
|
|
192
192
|
"default": false
|
|
193
|
-
},
|
|
194
|
-
"useProjectJson": {
|
|
195
|
-
"type": "boolean",
|
|
196
|
-
"description": "Use a `project.json` configuration file instead of inlining the Nx configuration in the `package.json` file."
|
|
197
193
|
}
|
|
198
194
|
},
|
|
199
195
|
"required": ["directory"]
|
|
@@ -48,10 +48,7 @@ function addModuleFederationFiles(host, options) {
|
|
|
48
48
|
async function remoteGenerator(host, schema) {
|
|
49
49
|
const tasks = [];
|
|
50
50
|
const options = {
|
|
51
|
-
...(await (0, normalize_options_1.normalizeOptions)(host,
|
|
52
|
-
...schema,
|
|
53
|
-
useProjectJson: true,
|
|
54
|
-
})),
|
|
51
|
+
...(await (0, normalize_options_1.normalizeOptions)(host, schema)),
|
|
55
52
|
// when js is set to true, we want to use the js configuration
|
|
56
53
|
js: schema.js ?? false,
|
|
57
54
|
typescriptConfiguration: schema.js
|
|
@@ -65,29 +62,29 @@ async function remoteGenerator(host, schema) {
|
|
|
65
62
|
if (options.dynamic) {
|
|
66
63
|
// Dynamic remotes generate with library { type: 'var' } by default.
|
|
67
64
|
// We need to ensure that the remote name is a valid variable name.
|
|
68
|
-
const isValidRemote = (0, js_1.isValidVariable)(options.
|
|
65
|
+
const isValidRemote = (0, js_1.isValidVariable)(options.name);
|
|
69
66
|
if (!isValidRemote.isValid) {
|
|
70
|
-
throw new Error(`Invalid remote name provided: ${options.
|
|
67
|
+
throw new Error(`Invalid remote name provided: ${options.name}. ${isValidRemote.message}`);
|
|
71
68
|
}
|
|
72
69
|
}
|
|
73
|
-
await (0, project_name_and_root_utils_1.
|
|
70
|
+
await (0, project_name_and_root_utils_1.ensureProjectName)(host, options, 'application');
|
|
74
71
|
const REMOTE_NAME_REGEX = '^[a-zA-Z_$][a-zA-Z_$0-9]*$';
|
|
75
72
|
const remoteNameRegex = new RegExp(REMOTE_NAME_REGEX);
|
|
76
|
-
if (!remoteNameRegex.test(options.
|
|
77
|
-
throw new Error((0, devkit_1.stripIndents) `Invalid remote name: ${options.
|
|
73
|
+
if (!remoteNameRegex.test(options.name)) {
|
|
74
|
+
throw new Error((0, devkit_1.stripIndents) `Invalid remote name: ${options.name}. Remote project names must:
|
|
78
75
|
- Start with a letter, dollar sign ($) or underscore (_)
|
|
79
76
|
- Followed by any valid character (letters, digits, underscores, or dollar signs)
|
|
80
77
|
The regular expression used is ${REMOTE_NAME_REGEX}.`);
|
|
81
78
|
}
|
|
82
79
|
const initAppTask = await (0, application_1.default)(host, {
|
|
83
80
|
...options,
|
|
84
|
-
name: options.
|
|
81
|
+
name: options.name,
|
|
85
82
|
skipFormat: true,
|
|
86
|
-
|
|
83
|
+
alwaysGenerateProjectJson: true,
|
|
87
84
|
});
|
|
88
85
|
tasks.push(initAppTask);
|
|
89
86
|
if (options.host) {
|
|
90
|
-
(0, update_host_with_remote_1.updateHostWithRemote)(host, options.host, options.
|
|
87
|
+
(0, update_host_with_remote_1.updateHostWithRemote)(host, options.host, options.name);
|
|
91
88
|
}
|
|
92
89
|
// Module federation requires bootstrap code to be dynamically imported.
|
|
93
90
|
// Renaming original entry file so we can use `import(./bootstrap)` in
|
package/src/utils/versions.d.ts
CHANGED
|
@@ -42,8 +42,8 @@ export declare const typesExpressVersion = "^4.17.21";
|
|
|
42
42
|
export declare const isbotVersion = "^3.6.5";
|
|
43
43
|
export declare const corsVersion = "~2.8.5";
|
|
44
44
|
export declare const typesCorsVersion = "~2.8.12";
|
|
45
|
-
export declare const moduleFederationNodeVersion = "^2.6.
|
|
46
|
-
export declare const moduleFederationEnhancedVersion = "^0.
|
|
45
|
+
export declare const moduleFederationNodeVersion = "^2.6.21";
|
|
46
|
+
export declare const moduleFederationEnhancedVersion = "^0.8.8";
|
|
47
47
|
export declare const lessVersion = "3.12.2";
|
|
48
48
|
export declare const sassVersion = "^1.55.0";
|
|
49
49
|
export declare const rollupPluginUrlVersion = "^8.0.2";
|
package/src/utils/versions.js
CHANGED
|
@@ -48,8 +48,8 @@ exports.typesExpressVersion = '^4.17.21';
|
|
|
48
48
|
exports.isbotVersion = '^3.6.5';
|
|
49
49
|
exports.corsVersion = '~2.8.5';
|
|
50
50
|
exports.typesCorsVersion = '~2.8.12';
|
|
51
|
-
exports.moduleFederationNodeVersion = '^2.6.
|
|
52
|
-
exports.moduleFederationEnhancedVersion = '^0.
|
|
51
|
+
exports.moduleFederationNodeVersion = '^2.6.21';
|
|
52
|
+
exports.moduleFederationEnhancedVersion = '^0.8.8';
|
|
53
53
|
// style preprocessors
|
|
54
54
|
exports.lessVersion = '3.12.2';
|
|
55
55
|
exports.sassVersion = '^1.55.0';
|