@nx/react 0.0.0-pr-29771-5e92bcc → 0.0.0-pr-29750-cc9549c

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/react",
3
- "version": "0.0.0-pr-29771-5e92bcc",
3
+ "version": "0.0.0-pr-29750-cc9549c",
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,12 +38,12 @@
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-29771-5e92bcc",
42
- "@nx/js": "0.0.0-pr-29771-5e92bcc",
43
- "@nx/eslint": "0.0.0-pr-29771-5e92bcc",
44
- "@nx/web": "0.0.0-pr-29771-5e92bcc",
45
- "@nx/module-federation": "0.0.0-pr-29771-5e92bcc",
46
- "express": "^4.21.2",
41
+ "@nx/devkit": "0.0.0-pr-29750-cc9549c",
42
+ "@nx/js": "0.0.0-pr-29750-cc9549c",
43
+ "@nx/eslint": "0.0.0-pr-29750-cc9549c",
44
+ "@nx/web": "0.0.0-pr-29750-cc9549c",
45
+ "@nx/module-federation": "0.0.0-pr-29750-cc9549c",
46
+ "express": "^4.19.2",
47
47
  "http-proxy-middleware": "^3.0.3",
48
48
  "semver": "^7.6.3"
49
49
  },
@@ -44,11 +44,6 @@ async function applicationGeneratorInternal(tree, schema) {
44
44
  });
45
45
  tasks.push(jsInitTask);
46
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
- }
52
47
  (0, show_possible_warnings_1.showPossibleWarnings)(tree, options);
53
48
  const initTask = await (0, init_1.default)(tree, {
54
49
  ...options,
@@ -132,6 +127,11 @@ async function applicationGeneratorInternal(tree, schema) {
132
127
  }, options.linter === 'eslint'
133
128
  ? ['eslint.config.js', 'eslint.config.cjs', 'eslint.config.mjs']
134
129
  : undefined);
130
+ // If we are using the new TS solution
131
+ // We need to update the workspace file (package.json or pnpm-workspaces.yaml) to include the new project
132
+ if (options.isUsingTsSolutionConfig) {
133
+ (0, ts_solution_setup_1.addProjectToTsSolutionWorkspace)(tree, options.appProjectRoot);
134
+ }
135
135
  (0, sort_fields_1.sortPackageJsonFields)(tree, options.appProjectRoot);
136
136
  if (!options.skipFormat) {
137
137
  await (0, devkit_1.formatFiles)(tree);
@@ -5,6 +5,7 @@ const devkit_1 = require("@nx/devkit");
5
5
  const has_webpack_plugin_1 = require("../../../utils/has-webpack-plugin");
6
6
  const maybe_js_1 = require("../../../utils/maybe-js");
7
7
  const has_rspack_plugin_1 = require("../../../utils/has-rspack-plugin");
8
+ const get_import_path_1 = require("@nx/js/src/utils/get-import-path");
8
9
  function addProject(host, options) {
9
10
  const project = {
10
11
  root: options.appProjectRoot,
@@ -30,14 +31,15 @@ function addProject(host, options) {
30
31
  }
31
32
  if (options.isUsingTsSolutionConfig) {
32
33
  (0, devkit_1.writeJson)(host, (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'package.json'), {
33
- name: options.projectName,
34
+ name: (0, get_import_path_1.getImportPath)(host, options.name),
34
35
  version: '0.0.1',
35
36
  private: true,
36
- nx: options.parsedTags?.length
37
- ? {
38
- tags: options.parsedTags,
39
- }
40
- : undefined,
37
+ nx: {
38
+ name: options.name,
39
+ projectType: 'application',
40
+ sourceRoot: `${options.appProjectRoot}/src`,
41
+ tags: options.parsedTags?.length ? options.parsedTags : undefined,
42
+ },
41
43
  });
42
44
  }
43
45
  if (!options.isUsingTsSolutionConfig || options.alwaysGenerateProjectJson) {
@@ -13,7 +13,7 @@ function getAppTests(options) {
13
13
  ${options.routing
14
14
  ? 'const { getByText } = render(<BrowserRouter><App /></BrowserRouter>);'
15
15
  : 'const { getByText } = render(<App />);'}
16
- expect(getByText(new RegExp('Welcome ${options.projectName}', 'gi'))).toBeTruthy();
16
+ expect(getByText(/Welcome ${options.projectName}/gi)).toBeTruthy();
17
17
  });
18
18
  `;
19
19
  }
@@ -8,7 +8,6 @@ const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project
8
8
  const assertion_1 = require("../../../utils/assertion");
9
9
  const find_free_port_1 = require("./find-free-port");
10
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
11
  function normalizeDirectory(options) {
13
12
  options.directory = options.directory?.replace(/\\{1,2}/g, '/');
14
13
  const { projectDirectory } = (0, devkit_1.extractLayoutDirectory)(options.directory);
@@ -42,13 +41,10 @@ async function normalizeOptions(host, options) {
42
41
  ? null
43
42
  : options.style;
44
43
  (0, assertion_1.assertValidStyle)(options.style);
45
- const isUsingTsSolutionConfig = (0, ts_solution_setup_1.isUsingTsSolutionSetup)(host);
46
44
  const normalized = {
47
45
  ...options,
48
- name: appProjectName,
49
- projectName: isUsingTsSolutionConfig
50
- ? (0, get_import_path_1.getImportPath)(host, appProjectName)
51
- : appProjectName,
46
+ name: (0, devkit_1.names)(options.name).fileName,
47
+ projectName: appProjectName,
52
48
  appProjectRoot,
53
49
  e2eProjectName,
54
50
  e2eProjectRoot,
@@ -56,7 +52,7 @@ async function normalizeOptions(host, options) {
56
52
  fileName,
57
53
  styledModule,
58
54
  hasStyles: options.style !== 'none',
59
- isUsingTsSolutionConfig,
55
+ isUsingTsSolutionConfig: (0, ts_solution_setup_1.isUsingTsSolutionSetup)(host),
60
56
  };
61
57
  normalized.routing = normalized.routing ?? false;
62
58
  normalized.strict = normalized.strict ?? true;
@@ -4,7 +4,6 @@ exports.normalizeOptions = normalizeOptions;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const artifact_name_and_directory_utils_1 = require("@nx/devkit/src/generators/artifact-name-and-directory-utils");
6
6
  const assertion_1 = require("../../../utils/assertion");
7
- const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
8
7
  async function normalizeOptions(tree, options) {
9
8
  (0, assertion_1.assertValidStyle)(options.style);
10
9
  const { artifactName: name, directory, fileName, filePath, fileExtension, fileExtensionType, project: projectName, } = await (0, artifact_name_and_directory_utils_1.determineArtifactNameAndDirectoryOptions)(tree, {
@@ -20,8 +19,7 @@ async function normalizeOptions(tree, options) {
20
19
  const styledModule = /^(css|scss|less|none)$/.test(options.style)
21
20
  ? null
22
21
  : options.style;
23
- if (options.export &&
24
- (0, ts_solution_setup_1.getProjectType)(tree, projectRoot, projectType) === 'application') {
22
+ if (options.export && projectType === 'application') {
25
23
  devkit_1.logger.warn(`The "--export" option should not be used with applications and will do nothing.`);
26
24
  }
27
25
  options.classComponent = options.classComponent ?? false;
@@ -7,7 +7,6 @@ const artifact_name_and_directory_utils_1 = require("@nx/devkit/src/generators/a
7
7
  const ensure_typescript_1 = require("@nx/js/src/utils/typescript/ensure-typescript");
8
8
  const path_1 = require("path");
9
9
  const ast_utils_1 = require("../../utils/ast-utils");
10
- const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
11
10
  async function hookGenerator(host, schema) {
12
11
  const options = await normalizeOptions(host, schema);
13
12
  createFiles(host, options);
@@ -62,9 +61,8 @@ async function normalizeOptions(host, options) {
62
61
  : `use${className}`;
63
62
  const hookTypeName = (0, devkit_1.names)(hookName).className;
64
63
  const project = (0, devkit_1.getProjects)(host).get(projectName);
65
- const { root, sourceRoot: projectSourceRoot, projectType } = project;
66
- if (options.export &&
67
- (0, ts_solution_setup_1.getProjectType)(host, root, projectType) === 'application') {
64
+ const { sourceRoot: projectSourceRoot, projectType } = project;
65
+ if (options.export && projectType === 'application') {
68
66
  devkit_1.logger.warn(`The "--export" option should not be used with applications and will do nothing.`);
69
67
  }
70
68
  return {
@@ -43,7 +43,7 @@ async function hostGenerator(host, schema) {
43
43
  const initTask = await (0, application_1.default)(host, {
44
44
  ...options,
45
45
  directory: options.appProjectRoot,
46
- name: options.name,
46
+ name: options.projectName,
47
47
  // The target use-case is loading remotes as child routes, thus always enable routing.
48
48
  routing: true,
49
49
  skipFormat: true,
@@ -1,3 +1,3 @@
1
1
  import { GeneratorCallback, Tree } from '@nx/devkit';
2
2
  import { NormalizedSchema } from '../schema';
3
- export declare function installCommonDependencies(host: Tree, options: NormalizedSchema): Promise<GeneratorCallback>;
3
+ export declare function installCommonDependencies(host: Tree, options: NormalizedSchema): GeneratorCallback;
@@ -3,16 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.installCommonDependencies = installCommonDependencies;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const add_swc_dependencies_1 = require("@nx/js/src/utils/swc/add-swc-dependencies");
6
- const version_utils_1 = require("../../../utils/version-utils");
7
6
  const versions_1 = require("../../../utils/versions");
8
- async function installCommonDependencies(host, options) {
7
+ function installCommonDependencies(host, options) {
9
8
  const tasks = [];
10
- const reactVersions = await (0, version_utils_1.getReactDependenciesVersionsToInstall)(host);
11
9
  const dependencies = {};
12
10
  const devDependencies = {
13
11
  '@types/node': versions_1.typesNodeVersion,
14
- '@types/react': reactVersions['@types/react'],
15
- '@types/react-dom': reactVersions['@types/react-dom'],
12
+ '@types/react': versions_1.typesReactVersion,
13
+ '@types/react-dom': versions_1.typesReactDomVersion,
16
14
  };
17
15
  if (options.bundler !== 'vite') {
18
16
  dependencies['tslib'] = versions_1.tsLibVersion;
@@ -41,7 +41,7 @@ async function normalizeOptions(host, options) {
41
41
  bundler,
42
42
  fileName,
43
43
  routePath: `/${projectNames.projectSimpleName}`,
44
- name: isUsingTsSolutionConfig ? importPath : projectName,
44
+ name: projectName,
45
45
  projectRoot,
46
46
  parsedTags,
47
47
  importPath,
@@ -37,9 +37,6 @@ async function libraryGeneratorInternal(host, schema) {
37
37
  });
38
38
  tasks.push(jsInitTask);
39
39
  const options = await (0, normalize_options_1.normalizeOptions)(host, schema);
40
- if (options.isUsingTsSolutionConfig) {
41
- (0, ts_solution_setup_1.addProjectToTsSolutionWorkspace)(host, options.projectRoot);
42
- }
43
40
  if (options.publishable === true && !schema.importPath) {
44
41
  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)`);
45
42
  }
@@ -56,11 +53,12 @@ async function libraryGeneratorInternal(host, schema) {
56
53
  name: options.importPath,
57
54
  version: '0.0.1',
58
55
  ...(0, determine_entry_fields_1.determineEntryFields)(options),
59
- nx: options.parsedTags?.length
60
- ? {
61
- tags: options.parsedTags,
62
- }
63
- : undefined,
56
+ nx: {
57
+ name: options.importPath === options.name ? undefined : options.name,
58
+ projectType: 'library',
59
+ sourceRoot: `${options.projectRoot}/src`,
60
+ tags: options.parsedTags?.length ? options.parsedTags : undefined,
61
+ },
64
62
  files: options.publishable ? ['dist', '!**/*.tsbuildinfo'] : undefined,
65
63
  });
66
64
  }
@@ -190,7 +188,7 @@ async function libraryGeneratorInternal(host, schema) {
190
188
  });
191
189
  }
192
190
  if (!options.skipPackageJson) {
193
- const installReactTask = await (0, install_common_dependencies_1.installCommonDependencies)(host, options);
191
+ const installReactTask = (0, install_common_dependencies_1.installCommonDependencies)(host, options);
194
192
  tasks.push(installReactTask);
195
193
  }
196
194
  const routeTask = (0, update_app_routes_1.updateAppRoutes)(host, options);
@@ -209,6 +207,9 @@ async function libraryGeneratorInternal(host, schema) {
209
207
  }, options.linter === 'eslint'
210
208
  ? ['eslint.config.js', 'eslint.config.cjs', 'eslint.config.mjs']
211
209
  : undefined);
210
+ if (options.isUsingTsSolutionConfig) {
211
+ (0, ts_solution_setup_1.addProjectToTsSolutionWorkspace)(host, options.projectRoot);
212
+ }
212
213
  (0, sort_fields_1.sortPackageJsonFields)(host, options.projectRoot);
213
214
  if (!options.skipFormat) {
214
215
  await (0, devkit_1.formatFiles)(host);
@@ -8,7 +8,6 @@ const devkit_1 = require("@nx/devkit");
8
8
  const js_1 = require("@nx/js");
9
9
  const ensure_typescript_1 = require("@nx/js/src/utils/typescript/ensure-typescript");
10
10
  const artifact_name_and_directory_utils_1 = require("@nx/devkit/src/generators/artifact-name-and-directory-utils");
11
- const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
12
11
  let tsModule;
13
12
  async function reduxGenerator(host, schema) {
14
13
  const options = await normalizeOptions(host, schema);
@@ -89,12 +88,12 @@ async function normalizeOptions(host, options) {
89
88
  const extraNames = (0, devkit_1.names)(name);
90
89
  const projects = (0, devkit_1.getProjects)(host);
91
90
  const project = projects.get(projectName);
92
- const { root, sourceRoot, projectType } = project;
91
+ const { sourceRoot, projectType } = project;
93
92
  const tsConfigJson = (0, devkit_1.readJson)(host, (0, js_1.getRootTsConfigPathInTree)(host));
94
93
  const tsPaths = tsConfigJson.compilerOptions
95
94
  ? tsConfigJson.compilerOptions.paths || {}
96
95
  : {};
97
- const modulePath = (0, ts_solution_setup_1.getProjectType)(host, root, projectType) === 'application'
96
+ const modulePath = projectType === 'application'
98
97
  ? options.path
99
98
  ? `./app/${options.path}/${extraNames.fileName}.slice`
100
99
  : `./app/${extraNames.fileName}.slice`
@@ -62,29 +62,29 @@ async function remoteGenerator(host, schema) {
62
62
  if (options.dynamic) {
63
63
  // Dynamic remotes generate with library { type: 'var' } by default.
64
64
  // We need to ensure that the remote name is a valid variable name.
65
- const isValidRemote = (0, js_1.isValidVariable)(options.name);
65
+ const isValidRemote = (0, js_1.isValidVariable)(options.projectName);
66
66
  if (!isValidRemote.isValid) {
67
- throw new Error(`Invalid remote name provided: ${options.name}. ${isValidRemote.message}`);
67
+ throw new Error(`Invalid remote name provided: ${options.projectName}. ${isValidRemote.message}`);
68
68
  }
69
69
  }
70
70
  await (0, project_name_and_root_utils_1.ensureProjectName)(host, options, 'application');
71
71
  const REMOTE_NAME_REGEX = '^[a-zA-Z_$][a-zA-Z_$0-9]*$';
72
72
  const remoteNameRegex = new RegExp(REMOTE_NAME_REGEX);
73
- if (!remoteNameRegex.test(options.name)) {
74
- throw new Error((0, devkit_1.stripIndents) `Invalid remote name: ${options.name}. Remote project names must:
73
+ if (!remoteNameRegex.test(options.projectName)) {
74
+ throw new Error((0, devkit_1.stripIndents) `Invalid remote name: ${options.projectName}. Remote project names must:
75
75
  - Start with a letter, dollar sign ($) or underscore (_)
76
76
  - Followed by any valid character (letters, digits, underscores, or dollar signs)
77
77
  The regular expression used is ${REMOTE_NAME_REGEX}.`);
78
78
  }
79
79
  const initAppTask = await (0, application_1.default)(host, {
80
80
  ...options,
81
- name: options.name,
81
+ name: options.projectName,
82
82
  skipFormat: true,
83
83
  alwaysGenerateProjectJson: true,
84
84
  });
85
85
  tasks.push(initAppTask);
86
- if (options.host) {
87
- (0, update_host_with_remote_1.updateHostWithRemote)(host, options.host, options.name);
86
+ if (schema.host) {
87
+ (0, update_host_with_remote_1.updateHostWithRemote)(host, schema.host, options.projectName);
88
88
  }
89
89
  // Module federation requires bootstrap code to be dynamically imported.
90
90
  // Renaming original entry file so we can use `import(./bootstrap)` in
@@ -11,11 +11,10 @@ const path_1 = require("path");
11
11
  const minimatch_1 = require("minimatch");
12
12
  const ensure_typescript_1 = require("@nx/js/src/utils/typescript/ensure-typescript");
13
13
  const versions_1 = require("../../utils/versions");
14
- const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
15
14
  let tsModule;
16
15
  async function projectRootPath(tree, config) {
17
16
  let projectDir;
18
- if ((0, ts_solution_setup_1.getProjectType)(tree, config.root, config.projectType) === 'application') {
17
+ if (config.projectType === 'application') {
19
18
  const isNextJs = await isNextJsProject(tree, config);
20
19
  if (isNextJs) {
21
20
  // Next.js apps
@@ -37,8 +37,8 @@ export declare const tsLibVersion = "^2.3.0";
37
37
  export declare const postcssVersion = "8.4.38";
38
38
  export declare const tailwindcssVersion = "3.4.3";
39
39
  export declare const autoprefixerVersion = "10.4.13";
40
- export declare const expressVersion = "^4.21.2";
41
- export declare const typesExpressVersion = "^4.17.21";
40
+ export declare const expressVersion = "~4.18.2";
41
+ export declare const typesExpressVersion = "4.17.17";
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";
@@ -43,8 +43,8 @@ exports.postcssVersion = '8.4.38';
43
43
  exports.tailwindcssVersion = '3.4.3';
44
44
  exports.autoprefixerVersion = '10.4.13';
45
45
  // SSR and Module Federation
46
- exports.expressVersion = '^4.21.2';
47
- exports.typesExpressVersion = '^4.17.21';
46
+ exports.expressVersion = '~4.18.2';
47
+ exports.typesExpressVersion = '4.17.17';
48
48
  exports.isbotVersion = '^3.6.5';
49
49
  exports.corsVersion = '~2.8.5';
50
50
  exports.typesCorsVersion = '~2.8.12';