@nx/react 0.0.0-pr-28859-d05a640 → 0.0.0-pr-28808-ca32248

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.
Files changed (26) hide show
  1. package/package.json +5 -5
  2. package/src/generators/application/application.js +11 -5
  3. package/src/generators/application/files/base-rspack/tsconfig.app.json__tmpl__ +21 -4
  4. package/src/generators/application/files/base-vite/tsconfig.app.json__tmpl__ +19 -2
  5. package/src/generators/application/files/base-webpack/tsconfig.app.json__tmpl__ +20 -3
  6. package/src/generators/application/files/style-css-module/src/app/__fileName__.tsx__tmpl__ +2 -2
  7. package/src/generators/application/lib/add-e2e.d.ts +1 -1
  8. package/src/generators/application/lib/add-jest.js +1 -0
  9. package/src/generators/application/lib/add-project.js +17 -3
  10. package/src/generators/application/lib/create-application-files.js +2 -0
  11. package/src/generators/application/lib/normalize-options.js +2 -0
  12. package/src/generators/application/lib/update-jest-config.js +5 -0
  13. package/src/generators/application/schema.d.ts +3 -0
  14. package/src/generators/application/schema.json +11 -8
  15. package/src/generators/host/host.js +0 -2
  16. package/src/generators/init/init.js +0 -2
  17. package/src/generators/library/lib/create-files.d.ts +1 -1
  18. package/src/generators/library/lib/create-files.js +19 -7
  19. package/src/generators/library/lib/normalize-options.js +2 -0
  20. package/src/generators/library/library.js +24 -16
  21. package/src/generators/library/schema.d.ts +1 -0
  22. package/src/generators/library/schema.json +6 -3
  23. package/src/generators/remote/remote.js +0 -2
  24. package/src/utils/create-ts-config.js +57 -7
  25. package/src/utils/versions.d.ts +0 -1
  26. package/src/utils/versions.js +1 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/react",
3
- "version": "0.0.0-pr-28859-d05a640",
3
+ "version": "0.0.0-pr-28808-ca32248",
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": {
@@ -39,10 +39,10 @@
39
39
  "picocolors": "^1.1.0",
40
40
  "tslib": "^2.3.0",
41
41
  "@module-federation/enhanced": "0.6.9",
42
- "@nx/devkit": "0.0.0-pr-28859-d05a640",
43
- "@nx/js": "0.0.0-pr-28859-d05a640",
44
- "@nx/eslint": "0.0.0-pr-28859-d05a640",
45
- "@nx/web": "0.0.0-pr-28859-d05a640",
42
+ "@nx/devkit": "0.0.0-pr-28808-ca32248",
43
+ "@nx/js": "0.0.0-pr-28808-ca32248",
44
+ "@nx/eslint": "0.0.0-pr-28808-ca32248",
45
+ "@nx/web": "0.0.0-pr-28808-ca32248",
46
46
  "express": "^4.19.2",
47
47
  "http-proxy-middleware": "^3.0.3"
48
48
  },
@@ -27,8 +27,8 @@ const js_1 = require("@nx/js");
27
27
  const log_show_project_command_1 = require("@nx/devkit/src/utils/log-show-project-command");
28
28
  const setup_tailwind_1 = require("../setup-tailwind/setup-tailwind");
29
29
  const flat_config_1 = require("@nx/eslint/src/utils/flat-config");
30
- const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
31
30
  const add_project_root_to_rspack_plugin_excludes_1 = require("./lib/add-project-root-to-rspack-plugin-excludes");
31
+ const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
32
32
  async function addLinting(host, options) {
33
33
  const tasks = [];
34
34
  if (options.linter === eslint_1.Linter.EsLint) {
@@ -74,16 +74,16 @@ async function applicationGenerator(host, schema) {
74
74
  });
75
75
  }
76
76
  async function applicationGeneratorInternal(host, schema) {
77
- (0, ts_solution_setup_1.assertNotUsingTsSolutionSetup)(host, 'react', 'application');
78
77
  const tasks = [];
79
- const options = await (0, normalize_options_1.normalizeOptions)(host, schema);
80
- (0, show_possible_warnings_1.showPossibleWarnings)(host, options);
81
78
  const jsInitTask = await (0, js_1.initGenerator)(host, {
82
79
  ...schema,
83
80
  tsConfigName: schema.rootProject ? 'tsconfig.json' : 'tsconfig.base.json',
84
81
  skipFormat: true,
82
+ addTsPlugin: schema.useTsSolution,
85
83
  });
86
84
  tasks.push(jsInitTask);
85
+ const options = await (0, normalize_options_1.normalizeOptions)(host, schema);
86
+ (0, show_possible_warnings_1.showPossibleWarnings)(host, options);
87
87
  const initTask = await (0, init_1.default)(host, {
88
88
  ...options,
89
89
  skipFormat: true,
@@ -143,6 +143,7 @@ async function applicationGeneratorInternal(host, schema) {
143
143
  compiler: options.compiler,
144
144
  skipFormat: true,
145
145
  addPlugin: options.addPlugin,
146
+ projectType: 'application',
146
147
  });
147
148
  tasks.push(viteTask);
148
149
  createOrEditViteConfig(host, {
@@ -164,7 +165,7 @@ async function applicationGeneratorInternal(host, schema) {
164
165
  }, false);
165
166
  }
166
167
  else if (options.bundler === 'rspack') {
167
- const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/rspack', versions_1.nxRspackVersion);
168
+ const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/rspack', versions_1.nxVersion);
168
169
  const rspackTask = await configurationGenerator(host, {
169
170
  project: options.projectName,
170
171
  main: (0, devkit_1.joinPathFragments)(options.appProjectRoot, (0, maybe_js_1.maybeJs)({
@@ -251,6 +252,11 @@ async function applicationGeneratorInternal(host, schema) {
251
252
  });
252
253
  `);
253
254
  }
255
+ (0, ts_solution_setup_1.updateTsconfigFiles)(host, options.appProjectRoot, 'tsconfig.app.json', {
256
+ jsx: 'react-jsx',
257
+ module: 'esnext',
258
+ moduleResolution: 'bundler',
259
+ });
254
260
  if (!options.skipFormat) {
255
261
  await (0, devkit_1.formatFiles)(host);
256
262
  }
@@ -1,14 +1,31 @@
1
- {
1
+ <% if (isUsingTsSolutionSetup) { %>{
2
+ "extends": "<%= offsetFromRoot%>tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "outDir": "dist",
5
+ "tsBuildInfoFile": "dist/tsconfig.lib.tsbuildinfo",
6
+ "jsx": "react-jsx",
7
+ "lib": ["dom"],
8
+ "types": [
9
+ "node",
10
+ <%_ if (style === 'styled-jsx') { _%>"@nx/react/typings/styled-jsx.d.ts",<%_ } _%>
11
+ "@nx/react/typings/cssmodule.d.ts",
12
+ "@nx/react/typings/image.d.ts"
13
+ ]
14
+ },
15
+ "exclude": ["src/**/*.spec.ts", "src/**/*.test.ts", "src/**/*.spec.tsx", "src/**/*.test.tsx", "src/**/*.spec.js", "src/**/*.test.js", "src/**/*.spec.jsx", "src/**/*.test.jsx"],
16
+ "include": ["src/**/*.js", "src/**/*.jsx", "src/**/*.ts", "src/**/*.tsx"]
17
+ }<% } else { %>{
2
18
  "extends": "./tsconfig.json",
3
19
  "compilerOptions": {
4
20
  "outDir": "<%= offsetFromRoot %>dist/out-tsc",
5
21
  "types": [
6
22
  "node",
7
- <%_ if (style === 'styled-jsx') { %>"@nx/react/typings/styled-jsx.d.ts",<% } _%>
23
+ <%_ if (style === 'styled-jsx') { _%>"@nx/react/typings/styled-jsx.d.ts",<%_ } _%>
8
24
  "@nx/react/typings/cssmodule.d.ts",
9
25
  "@nx/react/typings/image.d.ts"
10
- ]
26
+ ]
11
27
  },
12
- "exclude": ["jest.config.ts","src/**/*.spec.ts", "src/**/*.test.ts", "src/**/*.spec.tsx", "src/**/*.test.tsx", "src/**/*.spec.js", "src/**/*.test.js", "src/**/*.spec.jsx", "src/**/*.test.jsx"],
28
+ "exclude": ["src/**/*.spec.ts", "src/**/*.test.ts", "src/**/*.spec.tsx", "src/**/*.test.tsx", "src/**/*.spec.js", "src/**/*.test.js", "src/**/*.spec.jsx", "src/**/*.test.jsx"],
13
29
  "include": ["src/**/*.js", "src/**/*.jsx", "src/**/*.ts", "src/**/*.tsx"]
14
30
  }
31
+ <% } %>
@@ -1,4 +1,20 @@
1
- {
1
+ <% if (isUsingTsSolutionSetup) { %>{
2
+ "extends": "<%= offsetFromRoot%>tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "outDir": "dist",
5
+ "tsBuildInfoFile": "dist/tsconfig.lib.tsbuildinfo",
6
+ "jsx": "react-jsx",
7
+ "lib": ["dom"],
8
+ "types": [
9
+ "node",
10
+ <%_ if (style === 'styled-jsx') { _%>"@nx/react/typings/styled-jsx.d.ts",<%_ } _%>
11
+ "@nx/react/typings/cssmodule.d.ts",
12
+ "@nx/react/typings/image.d.ts"
13
+ ]
14
+ },
15
+ "exclude": ["src/**/*.spec.ts", "src/**/*.test.ts", "src/**/*.spec.tsx", "src/**/*.test.tsx", "src/**/*.spec.js", "src/**/*.test.js", "src/**/*.spec.jsx", "src/**/*.test.jsx"],
16
+ "include": ["src/**/*.js", "src/**/*.jsx", "src/**/*.ts", "src/**/*.tsx"]
17
+ }<% } else { %>{
2
18
  "extends": "./tsconfig.json",
3
19
  "compilerOptions": {
4
20
  "outDir": "<%= offsetFromRoot %>dist/out-tsc",
@@ -7,8 +23,9 @@
7
23
  <%_ if (style === 'styled-jsx') { _%>"@nx/react/typings/styled-jsx.d.ts",<%_ } _%>
8
24
  "@nx/react/typings/cssmodule.d.ts",
9
25
  "@nx/react/typings/image.d.ts"
10
- ]
26
+ ]
11
27
  },
12
28
  "exclude": ["src/**/*.spec.ts", "src/**/*.test.ts", "src/**/*.spec.tsx", "src/**/*.test.tsx", "src/**/*.spec.js", "src/**/*.test.js", "src/**/*.spec.jsx", "src/**/*.test.jsx"],
13
29
  "include": ["src/**/*.js", "src/**/*.jsx", "src/**/*.ts", "src/**/*.tsx"]
14
30
  }
31
+ <% } %>
@@ -1,4 +1,20 @@
1
- {
1
+ <% if (isUsingTsSolutionSetup) { %>{
2
+ "extends": "<%= offsetFromRoot%>tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "outDir": "dist",
5
+ "tsBuildInfoFile": "dist/tsconfig.lib.tsbuildinfo",
6
+ "jsx": "react-jsx",
7
+ "lib": ["dom"],
8
+ "types": [
9
+ "node",
10
+ <%_ if (style === 'styled-jsx') { _%>"@nx/react/typings/styled-jsx.d.ts",<%_ } _%>
11
+ "@nx/react/typings/cssmodule.d.ts",
12
+ "@nx/react/typings/image.d.ts"
13
+ ]
14
+ },
15
+ "exclude": ["src/**/*.spec.ts", "src/**/*.test.ts", "src/**/*.spec.tsx", "src/**/*.test.tsx", "src/**/*.spec.js", "src/**/*.test.js", "src/**/*.spec.jsx", "src/**/*.test.jsx"],
16
+ "include": ["src/**/*.js", "src/**/*.jsx", "src/**/*.ts", "src/**/*.tsx"]
17
+ }<% } else { %>{
2
18
  "extends": "./tsconfig.json",
3
19
  "compilerOptions": {
4
20
  "outDir": "<%= offsetFromRoot %>dist/out-tsc",
@@ -7,8 +23,9 @@
7
23
  <%_ if (style === 'styled-jsx') { _%>"@nx/react/typings/styled-jsx.d.ts",<%_ } _%>
8
24
  "@nx/react/typings/cssmodule.d.ts",
9
25
  "@nx/react/typings/image.d.ts"
10
- ]
26
+ ]
11
27
  },
12
- "exclude": ["jest.config.ts","src/**/*.spec.ts", "src/**/*.test.ts", "src/**/*.spec.tsx", "src/**/*.test.tsx", "src/**/*.spec.js", "src/**/*.test.js", "src/**/*.spec.jsx", "src/**/*.test.jsx"],
28
+ "exclude": ["src/**/*.spec.ts", "src/**/*.test.ts", "src/**/*.spec.tsx", "src/**/*.test.tsx", "src/**/*.spec.js", "src/**/*.test.js", "src/**/*.spec.jsx", "src/**/*.test.jsx"],
13
29
  "include": ["src/**/*.js", "src/**/*.jsx", "src/**/*.ts", "src/**/*.tsx"]
14
30
  }
31
+ <% } %>
@@ -1,8 +1,8 @@
1
1
  <% if (classComponent) { %>
2
2
  import { Component } from 'react';
3
3
  <%_ } _%>
4
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
5
- import styles from './<%= fileName %>.module.<%= style %>';
4
+ // Uncomment this line to use CSS modules
5
+ // import styles from './<%= fileName %>.module.<%= style %>';
6
6
  <%_ if (!minimal) { _%>
7
7
  import NxWelcome from "./nx-welcome";
8
8
  <%_ } _%>
@@ -1,3 +1,3 @@
1
- import type { GeneratorCallback, Tree } from '@nx/devkit';
1
+ import { GeneratorCallback, Tree } from '@nx/devkit';
2
2
  import { NormalizedSchema } from '../schema';
3
3
  export declare function addE2e(tree: Tree, options: NormalizedSchema): Promise<GeneratorCallback>;
@@ -16,5 +16,6 @@ async function addJest(host, options) {
16
16
  setupFile: 'none',
17
17
  compiler: options.compiler,
18
18
  skipFormat: true,
19
+ runtimeTsconfigFileName: 'tsconfig.app.json',
19
20
  });
20
21
  }
@@ -4,6 +4,8 @@ exports.addProject = addProject;
4
4
  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
+ const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
8
+ const get_import_path_1 = require("@nx/js/src/utils/get-import-path");
7
9
  function addProject(host, options) {
8
10
  const project = {
9
11
  root: options.appProjectRoot,
@@ -20,9 +22,21 @@ function addProject(host, options) {
20
22
  };
21
23
  }
22
24
  }
23
- (0, devkit_1.addProjectConfiguration)(host, options.projectName, {
24
- ...project,
25
- });
25
+ if ((0, ts_solution_setup_1.isUsingTsSolutionSetup)(host)) {
26
+ (0, devkit_1.writeJson)(host, (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'package.json'), {
27
+ name: (0, get_import_path_1.getImportPath)(host, options.name),
28
+ version: '0.0.1',
29
+ private: true,
30
+ nx: {
31
+ name: options.name,
32
+ },
33
+ });
34
+ }
35
+ else {
36
+ (0, devkit_1.addProjectConfiguration)(host, options.projectName, {
37
+ ...project,
38
+ });
39
+ }
26
40
  }
27
41
  function createBuildTarget(options) {
28
42
  return {
@@ -10,6 +10,7 @@ const maybe_js_1 = require("../../../utils/maybe-js");
10
10
  const has_webpack_plugin_1 = require("../../../utils/has-webpack-plugin");
11
11
  const get_app_tests_1 = require("./get-app-tests");
12
12
  const onboarding_1 = require("nx/src/nx-cloud/utilities/onboarding");
13
+ const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
13
14
  async function createApplicationFiles(host, options) {
14
15
  let styleSolutionSpecificAppFiles;
15
16
  if (options.styledModule && options.style !== 'styled-jsx') {
@@ -46,6 +47,7 @@ async function createApplicationFiles(host, options) {
46
47
  inSourceVitestTests: (0, get_in_source_vitest_tests_template_1.getInSourceVitestTestsTemplate)(appTests),
47
48
  style: options.style === 'tailwind' ? 'css' : options.style,
48
49
  hasStyleFile,
50
+ isUsingTsSolutionSetup: (0, ts_solution_setup_1.isUsingTsSolutionSetup)(host),
49
51
  };
50
52
  if (options.bundler === 'vite') {
51
53
  (0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, '../files/base-vite'), options.appProjectRoot, templateVariables);
@@ -7,6 +7,7 @@ const devkit_1 = require("@nx/devkit");
7
7
  const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
8
8
  const assertion_1 = require("../../../utils/assertion");
9
9
  const find_free_port_1 = require("./find-free-port");
10
+ const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
10
11
  function normalizeDirectory(options) {
11
12
  options.directory = options.directory?.replace(/\\{1,2}/g, '/');
12
13
  const { projectDirectory } = (0, devkit_1.extractLayoutDirectory)(options.directory);
@@ -51,6 +52,7 @@ async function normalizeOptions(host, options) {
51
52
  fileName,
52
53
  styledModule,
53
54
  hasStyles: options.style !== 'none',
55
+ isUsingTsSolutionConfig: (0, ts_solution_setup_1.isUsingTsSolutionSetup)(host),
54
56
  };
55
57
  normalized.routing = normalized.routing ?? false;
56
58
  normalized.strict = normalized.strict ?? true;
@@ -17,6 +17,11 @@ function updateSpecConfig(host, options) {
17
17
  types.push('@nx/react/typings/cssmodule.d.ts', '@nx/react/typings/image.d.ts');
18
18
  compilerOptions.types = types;
19
19
  json.compilerOptions = compilerOptions;
20
+ if (options.isUsingTsSolutionConfig) {
21
+ // add project reference to the runtime tsconfig.app.json file
22
+ json.references ??= [];
23
+ json.references.push({ path: './tsconfig.app.json' });
24
+ }
20
25
  return json;
21
26
  });
22
27
  if (options.unitTestRunner !== 'jest') {
@@ -25,8 +25,10 @@ export interface Schema {
25
25
  rootProject?: boolean;
26
26
  bundler?: 'webpack' | 'vite' | 'rspack';
27
27
  minimal?: boolean;
28
+ // Internal options
28
29
  addPlugin?: boolean;
29
30
  nxCloudToken?: string;
31
+ useTsSolution?: boolean;
30
32
  }
31
33
 
32
34
  export interface NormalizedSchema<T extends Schema = Schema> extends T {
@@ -40,4 +42,5 @@ export interface NormalizedSchema<T extends Schema = Schema> extends T {
40
42
  hasStyles: boolean;
41
43
  unitTestRunner: 'jest' | 'vitest' | 'none';
42
44
  addPlugin?: boolean;
45
+ isUsingTsSolutionConfig?: boolean;
43
46
  }
@@ -80,12 +80,6 @@
80
80
  ]
81
81
  }
82
82
  },
83
- "linter": {
84
- "description": "The tool to use for running lint checks.",
85
- "type": "string",
86
- "enum": ["eslint", "none"],
87
- "default": "eslint"
88
- },
89
83
  "routing": {
90
84
  "type": "boolean",
91
85
  "description": "Generate application with routes.",
@@ -104,11 +98,20 @@
104
98
  "default": false,
105
99
  "x-priority": "internal"
106
100
  },
101
+ "linter": {
102
+ "description": "The tool to use for running lint checks.",
103
+ "type": "string",
104
+ "enum": ["eslint", "none"],
105
+ "default": "none",
106
+ "x-prompt": "Which linter would you like to use?",
107
+ "x-priority": "important"
108
+ },
107
109
  "unitTestRunner": {
108
110
  "type": "string",
109
111
  "enum": ["vitest", "jest", "none"],
110
112
  "description": "Test runner to use for unit tests.",
111
- "default": "vitest"
113
+ "default": "none",
114
+ "x-priority": "important"
112
115
  },
113
116
  "inSourceTests": {
114
117
  "type": "boolean",
@@ -120,7 +123,7 @@
120
123
  "enum": ["playwright", "cypress", "none"],
121
124
  "description": "Test runner to use for end to end (E2E) tests.",
122
125
  "x-prompt": "Which E2E test runner would you like to use?",
123
- "default": "playwright"
126
+ "default": "none"
124
127
  },
125
128
  "tags": {
126
129
  "type": "string",
@@ -15,9 +15,7 @@ const add_mf_env_to_inputs_1 = require("../../utils/add-mf-env-to-inputs");
15
15
  const js_1 = require("@nx/js");
16
16
  const versions_1 = require("../../utils/versions");
17
17
  const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
18
- const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
19
18
  async function hostGenerator(host, schema) {
20
- (0, ts_solution_setup_1.assertNotUsingTsSolutionSetup)(host, 'react', 'host');
21
19
  const tasks = [];
22
20
  const options = {
23
21
  ...(await (0, normalize_options_1.normalizeOptions)(host, schema)),
@@ -2,10 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.reactInitGenerator = reactInitGenerator;
4
4
  const devkit_1 = require("@nx/devkit");
5
- const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
6
5
  const versions_1 = require("../../utils/versions");
7
6
  async function reactInitGenerator(host, schema) {
8
- (0, ts_solution_setup_1.assertNotUsingTsSolutionSetup)(host, 'react', 'init');
9
7
  const tasks = [];
10
8
  if (!schema.skipPackageJson) {
11
9
  tasks.push((0, devkit_1.removeDependenciesFromPackageJson)(host, ['@nx/react'], []));
@@ -1,3 +1,3 @@
1
- import type { Tree } from '@nx/devkit';
1
+ import { Tree } from '@nx/devkit';
2
2
  import { NormalizedSchema } from '../schema';
3
3
  export declare function createFiles(host: Tree, options: NormalizedSchema): void;
@@ -2,23 +2,24 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createFiles = createFiles;
4
4
  const devkit_1 = require("@nx/devkit");
5
+ const devkit_2 = require("@nx/devkit");
5
6
  const js_1 = require("@nx/js");
6
7
  const create_ts_config_1 = require("../../../utils/create-ts-config");
7
8
  function createFiles(host, options) {
8
9
  const relativePathToRootTsConfig = (0, js_1.getRelativePathToRootTsConfig)(host, options.projectRoot);
9
10
  const substitutions = {
10
11
  ...options,
11
- ...(0, devkit_1.names)(options.name),
12
+ ...(0, devkit_2.names)(options.name),
12
13
  tmpl: '',
13
- offsetFromRoot: (0, devkit_1.offsetFromRoot)(options.projectRoot),
14
+ offsetFromRoot: (0, devkit_2.offsetFromRoot)(options.projectRoot),
14
15
  fileName: options.fileName,
15
16
  };
16
- (0, devkit_1.generateFiles)(host, (0, devkit_1.joinPathFragments)(__dirname, '../files/common'), options.projectRoot, substitutions);
17
+ (0, devkit_2.generateFiles)(host, (0, devkit_2.joinPathFragments)(__dirname, '../files/common'), options.projectRoot, substitutions);
17
18
  if (options.bundler === 'vite' || options.unitTestRunner === 'vitest') {
18
- (0, devkit_1.generateFiles)(host, (0, devkit_1.joinPathFragments)(__dirname, '../files/vite'), options.projectRoot, substitutions);
19
+ (0, devkit_2.generateFiles)(host, (0, devkit_2.joinPathFragments)(__dirname, '../files/vite'), options.projectRoot, substitutions);
19
20
  }
20
21
  if (options.compiler === 'babel') {
21
- (0, devkit_1.writeJson)(host, (0, devkit_1.joinPathFragments)(options.projectRoot, '.babelrc'), {
22
+ (0, devkit_2.writeJson)(host, (0, devkit_2.joinPathFragments)(options.projectRoot, '.babelrc'), {
22
23
  presets: [
23
24
  [
24
25
  '@nx/react/babel',
@@ -42,11 +43,22 @@ function createFiles(host, options) {
42
43
  ].filter(Boolean),
43
44
  });
44
45
  }
45
- if (!options.publishable && !options.buildable) {
46
+ if (!options.publishable &&
47
+ !options.buildable &&
48
+ !options.isUsingTsSolutionConfig) {
46
49
  host.delete(`${options.projectRoot}/package.json`);
47
50
  }
51
+ if (options.isUsingTsSolutionConfig) {
52
+ (0, devkit_1.updateJson)(host, `${options.projectRoot}/package.json`, (json) => {
53
+ json.name = options.importPath;
54
+ json.nx = {
55
+ name: options.name,
56
+ };
57
+ return json;
58
+ });
59
+ }
48
60
  if (options.js) {
49
- (0, devkit_1.toJS)(host);
61
+ (0, devkit_2.toJS)(host);
50
62
  }
51
63
  (0, create_ts_config_1.createTsConfig)(host, options.projectRoot, 'lib', options, relativePathToRootTsConfig);
52
64
  }
@@ -4,6 +4,7 @@ exports.normalizeOptions = normalizeOptions;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
6
6
  const assertion_1 = require("../../../utils/assertion");
7
+ const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
7
8
  async function normalizeOptions(host, options) {
8
9
  await (0, project_name_and_root_utils_1.ensureProjectName)(host, options, 'library');
9
10
  const { projectName, names: projectNames, projectRoot, importPath, } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
@@ -62,6 +63,7 @@ async function normalizeOptions(host, options) {
62
63
  }
63
64
  }
64
65
  (0, assertion_1.assertValidStyle)(normalized.style);
66
+ normalized.isUsingTsSolutionConfig = (0, ts_solution_setup_1.isUsingTsSolutionSetup)(host);
65
67
  return normalized;
66
68
  }
67
69
  function findMainEntry(tree, projectRoot) {
@@ -7,7 +7,6 @@ const devkit_1 = require("@nx/devkit");
7
7
  const artifact_name_and_directory_utils_1 = require("@nx/devkit/src/generators/artifact-name-and-directory-utils");
8
8
  const log_show_project_command_1 = require("@nx/devkit/src/utils/log-show-project-command");
9
9
  const js_1 = require("@nx/js");
10
- const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
11
10
  const versions_1 = require("../../utils/versions");
12
11
  const maybe_js_1 = require("../../utils/maybe-js");
13
12
  const component_1 = require("../component/component");
@@ -21,6 +20,7 @@ const create_files_1 = require("./lib/create-files");
21
20
  const create_ts_config_1 = require("../../utils/create-ts-config");
22
21
  const install_common_dependencies_1 = require("./lib/install-common-dependencies");
23
22
  const set_defaults_1 = require("./lib/set-defaults");
23
+ const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
24
24
  async function libraryGenerator(host, schema) {
25
25
  return await libraryGeneratorInternal(host, {
26
26
  addPlugin: false,
@@ -28,8 +28,12 @@ async function libraryGenerator(host, schema) {
28
28
  });
29
29
  }
30
30
  async function libraryGeneratorInternal(host, schema) {
31
- (0, ts_solution_setup_1.assertNotUsingTsSolutionSetup)(host, 'react', 'library');
32
31
  const tasks = [];
32
+ const jsInitTask = await (0, js_1.initGenerator)(host, {
33
+ ...schema,
34
+ skipFormat: true,
35
+ });
36
+ tasks.push(jsInitTask);
33
37
  const options = await (0, normalize_options_1.normalizeOptions)(host, schema);
34
38
  if (options.publishable === true && !schema.importPath) {
35
39
  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)`);
@@ -37,26 +41,23 @@ async function libraryGeneratorInternal(host, schema) {
37
41
  if (!options.component) {
38
42
  options.style = 'none';
39
43
  }
40
- const jsInitTask = await (0, js_1.initGenerator)(host, {
41
- ...schema,
42
- skipFormat: true,
43
- });
44
- tasks.push(jsInitTask);
45
44
  const initTask = await (0, init_1.default)(host, {
46
45
  ...options,
47
46
  skipFormat: true,
48
47
  });
49
48
  tasks.push(initTask);
50
- (0, devkit_1.addProjectConfiguration)(host, options.name, {
51
- root: options.projectRoot,
52
- sourceRoot: (0, devkit_1.joinPathFragments)(options.projectRoot, 'src'),
53
- projectType: 'library',
54
- tags: options.parsedTags,
55
- targets: {},
56
- });
49
+ if (!options.isUsingTsSolutionConfig) {
50
+ (0, devkit_1.addProjectConfiguration)(host, options.name, {
51
+ root: options.projectRoot,
52
+ sourceRoot: (0, devkit_1.joinPathFragments)(options.projectRoot, 'src'),
53
+ projectType: 'library',
54
+ tags: options.parsedTags,
55
+ targets: {},
56
+ });
57
+ }
58
+ (0, create_files_1.createFiles)(host, options);
57
59
  const lintTask = await (0, add_linting_1.addLinting)(host, options);
58
60
  tasks.push(lintTask);
59
- (0, create_files_1.createFiles)(host, options);
60
61
  // Set up build target
61
62
  if (options.buildable && options.bundler === 'vite') {
62
63
  const { viteConfigurationGenerator, createOrEditViteConfig } = (0, devkit_1.ensurePackage)('@nx/vite', versions_1.nxVersion);
@@ -178,11 +179,18 @@ async function libraryGeneratorInternal(host, schema) {
178
179
  tasks.push(routeTask);
179
180
  (0, set_defaults_1.setDefaults)(host, options);
180
181
  (0, create_ts_config_1.extractTsConfigBase)(host);
181
- if (!options.skipTsConfig) {
182
+ if (!options.skipTsConfig && !options.isUsingTsSolutionConfig) {
182
183
  (0, js_1.addTsConfigPath)(host, options.importPath, [
183
184
  (0, maybe_js_1.maybeJs)(options, (0, devkit_1.joinPathFragments)(options.projectRoot, './src/index.ts')),
184
185
  ]);
185
186
  }
187
+ (0, ts_solution_setup_1.updateTsconfigFiles)(host, options.projectRoot, 'tsconfig.lib.json', {
188
+ jsx: 'react-jsx',
189
+ module: 'esnext',
190
+ moduleResolution: 'bundler',
191
+ }, options.linter === 'eslint'
192
+ ? ['eslint.config.js', 'eslint.config.cjs', 'eslint.config.mjs']
193
+ : undefined);
186
194
  if (!options.skipFormat) {
187
195
  await (0, devkit_1.formatFiles)(host);
188
196
  }
@@ -39,4 +39,5 @@ export interface NormalizedSchema extends Schema {
39
39
  appMain?: string;
40
40
  appSourceRoot?: string;
41
41
  unitTestRunner: 'jest' | 'vitest' | 'none';
42
+ isUsingTsSolutionConfig?: boolean;
42
43
  }
@@ -75,14 +75,17 @@
75
75
  "description": "The tool to use for running lint checks.",
76
76
  "type": "string",
77
77
  "enum": ["eslint", "none"],
78
- "default": "eslint"
78
+ "default": "none",
79
+ "x-prompt": "Which linter would you like to use?",
80
+ "x-priority": "important"
79
81
  },
80
82
  "unitTestRunner": {
81
83
  "type": "string",
82
84
  "enum": ["vitest", "jest", "none"],
83
- "default": "vitest",
85
+ "default": "none",
84
86
  "description": "Test runner to use for unit tests.",
85
- "x-prompt": "What unit test runner should be used?"
87
+ "x-prompt": "What unit test runner should be used?",
88
+ "x-priority": "important"
86
89
  },
87
90
  "inSourceTests": {
88
91
  "type": "boolean",
@@ -17,7 +17,6 @@ const maybe_js_1 = require("../../utils/maybe-js");
17
17
  const js_1 = require("@nx/js");
18
18
  const versions_1 = require("../../utils/versions");
19
19
  const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
20
- const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
21
20
  function addModuleFederationFiles(host, options) {
22
21
  const templateVariables = {
23
22
  ...(0, devkit_1.names)(options.projectName),
@@ -47,7 +46,6 @@ function addModuleFederationFiles(host, options) {
47
46
  }
48
47
  }
49
48
  async function remoteGenerator(host, schema) {
50
- (0, ts_solution_setup_1.assertNotUsingTsSolutionSetup)(host, 'react', 'remote');
51
49
  const tasks = [];
52
50
  const options = {
53
51
  ...(await (0, normalize_options_1.normalizeOptions)(host, schema)),
@@ -4,7 +4,64 @@ exports.createTsConfig = createTsConfig;
4
4
  exports.extractTsConfigBase = extractTsConfigBase;
5
5
  const shared = require("@nx/js/src/utils/typescript/create-ts-config");
6
6
  const json_1 = require("nx/src/generators/utils/json");
7
+ const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
7
8
  function createTsConfig(host, projectRoot, type, options, relativePathToRootTsConfig) {
9
+ if ((0, ts_solution_setup_1.isUsingTsSolutionSetup)(host)) {
10
+ createTsConfigForTsSolution(host, projectRoot, type, options, relativePathToRootTsConfig);
11
+ }
12
+ else {
13
+ createTsConfigForNonTsSolution(host, projectRoot, type, options, relativePathToRootTsConfig);
14
+ }
15
+ }
16
+ function extractTsConfigBase(host) {
17
+ shared.extractTsConfigBase(host);
18
+ if (host.exists('vite.config.ts')) {
19
+ const vite = host.read('vite.config.ts').toString();
20
+ host.write('vite.config.ts', vite.replace(`projects: []`, `projects: ['tsconfig.base.json']`));
21
+ }
22
+ }
23
+ function createTsConfigForTsSolution(host, projectRoot, type, options, relativePathToRootTsConfig) {
24
+ const json = {
25
+ files: [],
26
+ include: [],
27
+ references: [
28
+ {
29
+ path: type === 'app' ? './tsconfig.app.json' : './tsconfig.lib.json',
30
+ },
31
+ ],
32
+ };
33
+ // inline tsconfig.base.json into the project
34
+ if (options.rootProject) {
35
+ json.compileOnSave = false;
36
+ json.compilerOptions = {
37
+ ...shared.tsConfigBaseOptions,
38
+ ...json.compilerOptions,
39
+ };
40
+ json.exclude = ['node_modules', 'tmp'];
41
+ }
42
+ else {
43
+ json.extends = relativePathToRootTsConfig;
44
+ }
45
+ (0, json_1.writeJson)(host, `${projectRoot}/tsconfig.json`, json);
46
+ const tsconfigProjectPath = `${projectRoot}/tsconfig.${type}.json`;
47
+ if (host.exists(tsconfigProjectPath)) {
48
+ (0, json_1.updateJson)(host, tsconfigProjectPath, (json) => {
49
+ if (options.bundler === 'vite') {
50
+ json.compilerOptions ??= {};
51
+ const types = new Set(json.compilerOptions.types ?? []);
52
+ types.add('node');
53
+ types.add('vite/client');
54
+ json.compilerOptions.types = Array.from(types);
55
+ }
56
+ if (options.style === '@emotion/styled') {
57
+ json.compilerOptions ??= {};
58
+ json.compilerOptions.jsxImportSource = '@emotion/react';
59
+ }
60
+ return json;
61
+ });
62
+ }
63
+ }
64
+ function createTsConfigForNonTsSolution(host, projectRoot, type, options, relativePathToRootTsConfig) {
8
65
  const json = {
9
66
  compilerOptions: {
10
67
  jsx: 'react-jsx',
@@ -55,10 +112,3 @@ function createTsConfig(host, projectRoot, type, options, relativePathToRootTsCo
55
112
  });
56
113
  }
57
114
  }
58
- function extractTsConfigBase(host) {
59
- shared.extractTsConfigBase(host);
60
- if (host.exists('vite.config.ts')) {
61
- const vite = host.read('vite.config.ts').toString();
62
- host.write('vite.config.ts', vite.replace(`projects: []`, `projects: ['tsconfig.base.json']`));
63
- }
64
- }
@@ -1,5 +1,4 @@
1
1
  export declare const nxVersion: any;
2
- export declare const nxRspackVersion = "*";
3
2
  export declare const reactVersion = "18.3.1";
4
3
  export declare const reactDomVersion = "18.3.1";
5
4
  export declare const reactIsVersion = "18.3.1";
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.swcPluginStyledComponentsVersion = exports.swcPluginEmotionVersion = exports.swcPluginStyledJsxVersion = exports.svgrRollupVersion = exports.rollupPluginUrlVersion = exports.sassVersion = exports.lessVersion = exports.moduleFederationEnhancedVersion = exports.moduleFederationNodeVersion = exports.typesCorsVersion = exports.corsVersion = exports.isbotVersion = exports.typesExpressVersion = exports.expressVersion = exports.autoprefixerVersion = exports.tailwindcssVersion = exports.postcssVersion = exports.tsLibVersion = exports.babelPluginStyledComponentsVersion = exports.eslintPluginReactHooksVersion = exports.eslintPluginReactVersion = exports.eslintPluginJsxA11yVersion = exports.eslintPluginImportVersion = exports.reactReduxVersion = exports.reduxjsToolkitVersion = exports.testingLibraryReactVersion = exports.reactRouterDomVersion = exports.styledJsxVersion = exports.emotionBabelPlugin = exports.emotionReactVersion = exports.emotionStyledVersion = exports.typesStyledComponentsVersion = exports.styledComponentsVersion = exports.babelCoreVersion = exports.babelPresetReactVersion = exports.typesNodeVersion = exports.reactViteVersion = exports.typesReactIsVersion = exports.typesReactDomVersion = exports.typesReactVersion = exports.babelLoaderVersion = exports.swcLoaderVersion = exports.reactIsVersion = exports.reactDomVersion = exports.reactVersion = exports.nxRspackVersion = exports.nxVersion = void 0;
3
+ exports.swcPluginStyledComponentsVersion = exports.swcPluginEmotionVersion = exports.swcPluginStyledJsxVersion = exports.svgrRollupVersion = exports.rollupPluginUrlVersion = exports.sassVersion = exports.lessVersion = exports.moduleFederationEnhancedVersion = exports.moduleFederationNodeVersion = exports.typesCorsVersion = exports.corsVersion = exports.isbotVersion = exports.typesExpressVersion = exports.expressVersion = exports.autoprefixerVersion = exports.tailwindcssVersion = exports.postcssVersion = exports.tsLibVersion = exports.babelPluginStyledComponentsVersion = exports.eslintPluginReactHooksVersion = exports.eslintPluginReactVersion = exports.eslintPluginJsxA11yVersion = exports.eslintPluginImportVersion = exports.reactReduxVersion = exports.reduxjsToolkitVersion = exports.testingLibraryReactVersion = exports.reactRouterDomVersion = exports.styledJsxVersion = exports.emotionBabelPlugin = exports.emotionReactVersion = exports.emotionStyledVersion = exports.typesStyledComponentsVersion = exports.styledComponentsVersion = exports.babelCoreVersion = exports.babelPresetReactVersion = exports.typesNodeVersion = exports.reactViteVersion = exports.typesReactIsVersion = exports.typesReactDomVersion = exports.typesReactVersion = exports.babelLoaderVersion = exports.swcLoaderVersion = exports.reactIsVersion = exports.reactDomVersion = exports.reactVersion = exports.nxVersion = void 0;
4
4
  exports.nxVersion = require('../../package.json').version;
5
- // Always pull the latest version until we merge rspack plugin into the repo.
6
- exports.nxRspackVersion = '*';
7
5
  exports.reactVersion = '18.3.1';
8
6
  exports.reactDomVersion = '18.3.1';
9
7
  exports.reactIsVersion = '18.3.1';