@nx/react 0.0.0-pr-28808-a9a1b13 → 0.0.0-pr-29047-57d3073

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 (59) hide show
  1. package/migrations.json +27 -0
  2. package/module-federation.d.ts +6 -4
  3. package/module-federation.js +16 -7
  4. package/package.json +6 -7
  5. package/src/generators/application/application.js +13 -25
  6. package/src/generators/application/files/base-rspack/rspack.config.js__tmpl__ +53 -0
  7. package/src/generators/application/files/base-rspack/tsconfig.app.json__tmpl__ +4 -21
  8. package/src/generators/application/files/base-vite/tsconfig.app.json__tmpl__ +2 -19
  9. package/src/generators/application/files/base-webpack/tsconfig.app.json__tmpl__ +3 -20
  10. package/src/generators/application/files/style-css-module/src/app/__fileName__.tsx__tmpl__ +2 -2
  11. package/src/generators/application/lib/add-e2e.d.ts +1 -1
  12. package/src/generators/application/lib/add-e2e.js +15 -41
  13. package/src/generators/application/lib/add-jest.js +0 -1
  14. package/src/generators/application/lib/add-project.js +68 -15
  15. package/src/generators/application/lib/create-application-files.js +28 -3
  16. package/src/generators/application/lib/normalize-options.js +0 -2
  17. package/src/generators/application/lib/update-jest-config.js +0 -5
  18. package/src/generators/application/schema.d.ts +0 -5
  19. package/src/generators/application/schema.json +15 -19
  20. package/src/generators/component/component.js +1 -3
  21. package/src/generators/component/lib/normalize-options.js +1 -2
  22. package/src/generators/component/schema.d.ts +0 -1
  23. package/src/generators/host/files/webpack-module-federation/webpack.config.js__tmpl__ +1 -1
  24. package/src/generators/host/files/webpack-module-federation/webpack.config.prod.js__tmpl__ +1 -1
  25. package/src/generators/host/files/webpack-module-federation-ssr/webpack.server.config.js__tmpl__ +1 -1
  26. package/src/generators/host/files/webpack-module-federation-ssr-ts/webpack.server.config.ts__tmpl__ +1 -1
  27. package/src/generators/host/files/webpack-module-federation-ts/webpack.config.prod.ts__tmpl__ +1 -1
  28. package/src/generators/host/files/webpack-module-federation-ts/webpack.config.ts__tmpl__ +1 -1
  29. package/src/generators/host/host.js +2 -3
  30. package/src/generators/init/init.js +2 -0
  31. package/src/generators/library/files/common/package.json__tmpl__ +4 -0
  32. package/src/generators/library/files/vite/package.json__tmpl__ +12 -0
  33. package/src/generators/library/lib/create-files.d.ts +1 -1
  34. package/src/generators/library/lib/create-files.js +2 -22
  35. package/src/generators/library/lib/normalize-options.js +0 -22
  36. package/src/generators/library/library.js +16 -34
  37. package/src/generators/library/schema.d.ts +0 -1
  38. package/src/generators/library/schema.json +6 -6
  39. package/src/generators/remote/files/webpack-module-federation/webpack.config.js__tmpl__ +1 -1
  40. package/src/generators/remote/files/webpack-module-federation-ssr/webpack.server.config.js__tmpl__ +1 -1
  41. package/src/generators/remote/files/webpack-module-federation-ssr-ts/webpack.server.config.ts__tmpl__ +1 -1
  42. package/src/generators/remote/files/webpack-module-federation-ts/webpack.config.ts__tmpl__ +1 -1
  43. package/src/generators/remote/remote.js +2 -1
  44. package/src/migrations/update-20-2-0/migrate-with-mf-import-to-new-package.d.ts +2 -0
  45. package/src/migrations/update-20-2-0/migrate-with-mf-import-to-new-package.js +35 -0
  46. package/src/rules/update-module-federation-project.js +6 -10
  47. package/src/utils/create-ts-config.js +7 -57
  48. package/src/utils/has-rspack-plugin.d.ts +2 -0
  49. package/src/utils/has-rspack-plugin.js +10 -0
  50. package/src/utils/versions.d.ts +3 -2
  51. package/src/utils/versions.js +5 -3
  52. package/src/generators/host/lib/update-module-federation-tsconfig.d.ts +0 -3
  53. package/src/generators/host/lib/update-module-federation-tsconfig.js +0 -39
  54. package/src/module-federation/utils.d.ts +0 -12
  55. package/src/module-federation/utils.js +0 -75
  56. package/src/module-federation/with-module-federation-ssr.d.ts +0 -2
  57. package/src/module-federation/with-module-federation-ssr.js +0 -50
  58. package/src/module-federation/with-module-federation.d.ts +0 -7
  59. package/src/module-federation/with-module-federation.js +0 -63
@@ -25,12 +25,8 @@ export interface Schema {
25
25
  rootProject?: boolean;
26
26
  bundler?: 'webpack' | 'vite' | 'rspack';
27
27
  minimal?: boolean;
28
- // Internal options
29
28
  addPlugin?: boolean;
30
29
  nxCloudToken?: string;
31
- useTsSolution?: boolean;
32
- formatter?: 'prettier' | 'none';
33
- alwaysGenerateProjectJson?: boolean; // this is needed for MF currently
34
30
  }
35
31
 
36
32
  export interface NormalizedSchema<T extends Schema = Schema> extends T {
@@ -44,5 +40,4 @@ export interface NormalizedSchema<T extends Schema = Schema> extends T {
44
40
  hasStyles: boolean;
45
41
  unitTestRunner: 'jest' | 'vitest' | 'none';
46
42
  addPlugin?: boolean;
47
- isUsingTsSolutionConfig?: boolean;
48
43
  }
@@ -80,6 +80,12 @@
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
+ },
83
89
  "routing": {
84
90
  "type": "boolean",
85
91
  "description": "Generate application with routes.",
@@ -98,29 +104,11 @@
98
104
  "default": false,
99
105
  "x-priority": "internal"
100
106
  },
101
- "bundler": {
102
- "description": "The bundler to use.",
103
- "type": "string",
104
- "enum": ["vite", "webpack", "rspack"],
105
- "x-prompt": "Which bundler do you want to use to build the application?",
106
- "default": "vite",
107
- "x-priority": "important"
108
- },
109
- "linter": {
110
- "description": "The tool to use for running lint checks.",
111
- "type": "string",
112
- "enum": ["eslint", "none"],
113
- "default": "eslint",
114
- "x-prompt": "Which linter would you like to use?",
115
- "x-priority": "important"
116
- },
117
107
  "unitTestRunner": {
118
108
  "type": "string",
119
109
  "enum": ["vitest", "jest", "none"],
120
110
  "description": "Test runner to use for unit tests.",
121
- "default": "vitest",
122
- "x-prompt": "What unit test runner should be used?",
123
- "x-priority": "important"
111
+ "default": "vitest"
124
112
  },
125
113
  "inSourceTests": {
126
114
  "type": "boolean",
@@ -183,6 +171,14 @@
183
171
  "default": false,
184
172
  "hidden": true
185
173
  },
174
+ "bundler": {
175
+ "description": "The bundler to use.",
176
+ "type": "string",
177
+ "enum": ["vite", "webpack", "rspack"],
178
+ "x-prompt": "Which bundler do you want to use to build the application?",
179
+ "default": "vite",
180
+ "x-priority": "important"
181
+ },
186
182
  "minimal": {
187
183
  "description": "Generate a React app with a minimal setup, no separate test files.",
188
184
  "type": "boolean",
@@ -67,9 +67,7 @@ function addExportsToBarrel(host, options) {
67
67
  const workspace = (0, devkit_1.getProjects)(host);
68
68
  const isApp = workspace.get(options.projectName).projectType === 'application';
69
69
  if (options.export && !isApp) {
70
- const indexFilePath = options.projectSourceRoot
71
- ? (0, devkit_1.joinPathFragments)(options.projectSourceRoot, options.js ? 'index.js' : 'index.ts')
72
- : (0, devkit_1.joinPathFragments)(options.projectRoot, 'src', options.js ? 'index.js' : 'index.ts');
70
+ const indexFilePath = (0, devkit_1.joinPathFragments)(options.projectSourceRoot, options.js ? 'index.js' : 'index.ts');
73
71
  const indexSource = host.read(indexFilePath, 'utf-8');
74
72
  if (indexSource !== null) {
75
73
  const indexSourceFile = tsModule.createSourceFile(indexFilePath, indexSource, tsModule.ScriptTarget.Latest, true);
@@ -36,7 +36,6 @@ async function normalizeOptions(tree, options) {
36
36
  className,
37
37
  fileName,
38
38
  filePath,
39
- projectRoot,
40
- projectSourceRoot: projectSourceRoot,
39
+ projectSourceRoot: projectSourceRoot ?? projectRoot,
41
40
  };
42
41
  }
@@ -20,7 +20,6 @@ export interface Schema {
20
20
 
21
21
  export interface NormalizedSchema extends Schema {
22
22
  directory: string;
23
- projectRoot: string;
24
23
  projectSourceRoot: string;
25
24
  projectName: string;
26
25
  fileName: string;
@@ -1,6 +1,6 @@
1
1
  const { composePlugins, withNx } = require('@nx/webpack');
2
2
  const { withReact } = require('@nx/react');
3
- const { withModuleFederation } = require('@nx/react/module-federation');
3
+ const { withModuleFederation } = require('@nx/module-federation/webpack');
4
4
 
5
5
  const baseConfig = require('./module-federation.config');
6
6
 
@@ -1,6 +1,6 @@
1
1
  const { composePlugins, withNx } = require('@nx/webpack');
2
2
  const { withReact } = require('@nx/react');
3
- const { withModuleFederation } = require('@nx/react/module-federation');
3
+ const { withModuleFederation } = require('@nx/module-federation/webpack');
4
4
 
5
5
  const baseConfig = require('./module-federation.config');
6
6
 
@@ -1,6 +1,6 @@
1
1
  const {composePlugins, withNx} = require('@nx/webpack');
2
2
  const {withReact} = require('@nx/react');
3
- const {withModuleFederationForSSR} = require('@nx/react/module-federation');
3
+ const {withModuleFederationForSSR} = require('@nx/module-federation/webpack');
4
4
 
5
5
  const baseConfig = require('./module-federation.config');
6
6
 
@@ -1,6 +1,6 @@
1
1
  import {composePlugins, withNx} from '@nx/webpack';
2
2
  import {withReact} from '@nx/react';
3
- import {withModuleFederationForSSR} from '@nx/react/module-federation';
3
+ import {withModuleFederationForSSR} from '@nx/module-federation/webpack';
4
4
 
5
5
  import baseConfig from './module-federation.config';
6
6
 
@@ -1,6 +1,6 @@
1
1
  import { composePlugins, withNx } from '@nx/webpack';
2
2
  import { withReact } from '@nx/react';
3
- import { withModuleFederation } from '@nx/react/module-federation';
3
+ import { withModuleFederation } from '@nx/module-federation/webpack';
4
4
  import { ModuleFederationConfig } from '@nx/module-federation';
5
5
 
6
6
  import baseConfig from './module-federation.config';
@@ -1,6 +1,6 @@
1
1
  import {composePlugins, withNx} from '@nx/webpack';
2
2
  import {withReact} from '@nx/react';
3
- import {withModuleFederation} from '@nx/react/module-federation';
3
+ import {withModuleFederation} from '@nx/module-federation/webpack';
4
4
  import { ModuleFederationConfig } from '@nx/module-federation';
5
5
 
6
6
  import baseConfig from './module-federation.config';
@@ -15,8 +15,9 @@ 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 update_module_federation_tsconfig_1 = require("./lib/update-module-federation-tsconfig");
18
+ const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
19
19
  async function hostGenerator(host, schema) {
20
+ (0, ts_solution_setup_1.assertNotUsingTsSolutionSetup)(host, 'react', 'host');
20
21
  const tasks = [];
21
22
  const options = {
22
23
  ...(await (0, normalize_options_1.normalizeOptions)(host, schema)),
@@ -47,7 +48,6 @@ async function hostGenerator(host, schema) {
47
48
  // The target use-case is loading remotes as child routes, thus always enable routing.
48
49
  routing: true,
49
50
  skipFormat: true,
50
- alwaysGenerateProjectJson: true,
51
51
  });
52
52
  tasks.push(initTask);
53
53
  const remotesWithPorts = [];
@@ -80,7 +80,6 @@ async function hostGenerator(host, schema) {
80
80
  (0, add_module_federation_files_1.addModuleFederationFiles)(host, options, remotesWithPorts);
81
81
  (0, update_module_federation_project_1.updateModuleFederationProject)(host, options);
82
82
  (0, update_module_federation_e2e_project_1.updateModuleFederationE2eProject)(host, options);
83
- (0, update_module_federation_tsconfig_1.updateModuleFederationTsconfig)(host, options);
84
83
  if (options.ssr) {
85
84
  const setupSsrTask = await (0, setup_ssr_1.default)(host, {
86
85
  project: options.projectName,
@@ -2,8 +2,10 @@
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");
5
6
  const versions_1 = require("../../utils/versions");
6
7
  async function reactInitGenerator(host, schema) {
8
+ (0, ts_solution_setup_1.assertNotUsingTsSolutionSetup)(host, 'react', 'init');
7
9
  const tasks = [];
8
10
  if (!schema.skipPackageJson) {
9
11
  tasks.push((0, devkit_1.removeDependenciesFromPackageJson)(host, ['@nx/react'], []));
@@ -0,0 +1,4 @@
1
+ {
2
+ "name": "<%= name %>",
3
+ "version": "0.0.1"
4
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "<%= name %>",
3
+ "version": "0.0.1",
4
+ "main": "./index.js",
5
+ "types": "./index.d.ts",
6
+ "exports": {
7
+ ".": {
8
+ "import": "./index.mjs",
9
+ "require": "./index.js"
10
+ }
11
+ }
12
+ }
@@ -1,3 +1,3 @@
1
- import { Tree } from '@nx/devkit';
1
+ import type { Tree } from '@nx/devkit';
2
2
  import { NormalizedSchema } from '../schema';
3
3
  export declare function createFiles(host: Tree, options: NormalizedSchema): void;
@@ -42,28 +42,8 @@ function createFiles(host, options) {
42
42
  ].filter(Boolean),
43
43
  });
44
44
  }
45
- if ((options.publishable || options.buildable) &&
46
- !options.isUsingTsSolutionConfig) {
47
- if (options.bundler === 'vite') {
48
- (0, devkit_1.writeJson)(host, `${options.projectRoot}/package.json`, {
49
- name: options.importPath,
50
- version: '0.0.1',
51
- main: './index.js',
52
- types: './index.d.ts',
53
- exports: {
54
- '.': {
55
- import: './index.mjs',
56
- require: './index.js',
57
- },
58
- },
59
- });
60
- }
61
- else {
62
- (0, devkit_1.writeJson)(host, `${options.projectRoot}/package.json`, {
63
- name: options.importPath,
64
- version: '0.0.1',
65
- });
66
- }
45
+ if (!options.publishable && !options.buildable) {
46
+ host.delete(`${options.projectRoot}/package.json`);
67
47
  }
68
48
  if (options.js) {
69
49
  (0, devkit_1.toJS)(host);
@@ -4,28 +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");
8
- const prompt_1 = require("@nx/devkit/src/generators/prompt");
9
7
  async function normalizeOptions(host, options) {
10
- const isUsingTsSolutionConfig = (0, ts_solution_setup_1.isUsingTsSolutionSetup)(host);
11
- if (isUsingTsSolutionConfig) {
12
- options.bundler ??= await (0, prompt_1.promptWhenInteractive)({
13
- type: 'autocomplete',
14
- name: 'bundler',
15
- message: `Which bundler would you like to use to build the library? Choose 'none' to skip build setup.`,
16
- choices: [{ name: 'vite' }, { name: 'rollup' }, { name: 'none' }],
17
- initial: 0,
18
- }, { bundler: 'none' }).then(({ bundler }) => bundler);
19
- }
20
- else {
21
- options.bundler ??= await (0, prompt_1.promptWhenInteractive)({
22
- type: 'autocomplete',
23
- name: 'bundler',
24
- message: `Which bundler would you like to use to build the library? Choose 'none' to skip build setup.`,
25
- choices: [{ name: 'none' }, { name: 'vite' }, { name: 'rollup' }],
26
- initial: 0,
27
- }, { bundler: undefined }).then(({ bundler }) => bundler);
28
- }
29
8
  await (0, project_name_and_root_utils_1.ensureProjectName)(host, options, 'library');
30
9
  const { projectName, names: projectNames, projectRoot, importPath, } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
31
10
  name: options.name,
@@ -83,7 +62,6 @@ async function normalizeOptions(host, options) {
83
62
  }
84
63
  }
85
64
  (0, assertion_1.assertValidStyle)(normalized.style);
86
- normalized.isUsingTsSolutionConfig = isUsingTsSolutionConfig;
87
65
  return normalized;
88
66
  }
89
67
  function findMainEntry(tree, projectRoot) {
@@ -7,6 +7,7 @@ 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");
10
11
  const versions_1 = require("../../utils/versions");
11
12
  const maybe_js_1 = require("../../utils/maybe-js");
12
13
  const component_1 = require("../component/component");
@@ -20,7 +21,6 @@ const create_files_1 = require("./lib/create-files");
20
21
  const create_ts_config_1 = require("../../utils/create-ts-config");
21
22
  const install_common_dependencies_1 = require("./lib/install-common-dependencies");
22
23
  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,12 +28,8 @@ 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');
31
32
  const tasks = [];
32
- const jsInitTask = await (0, js_1.initGenerator)(host, {
33
- ...schema,
34
- skipFormat: true,
35
- });
36
- tasks.push(jsInitTask);
37
33
  const options = await (0, normalize_options_1.normalizeOptions)(host, schema);
38
34
  if (options.publishable === true && !schema.importPath) {
39
35
  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)`);
@@ -41,33 +37,26 @@ async function libraryGeneratorInternal(host, schema) {
41
37
  if (!options.component) {
42
38
  options.style = 'none';
43
39
  }
40
+ const jsInitTask = await (0, js_1.initGenerator)(host, {
41
+ ...schema,
42
+ skipFormat: true,
43
+ });
44
+ tasks.push(jsInitTask);
44
45
  const initTask = await (0, init_1.default)(host, {
45
46
  ...options,
46
47
  skipFormat: true,
47
48
  });
48
49
  tasks.push(initTask);
49
- if (options.isUsingTsSolutionConfig) {
50
- (0, devkit_1.writeJson)(host, `${options.projectRoot}/package.json`, {
51
- name: options.importPath,
52
- nx: {
53
- name: options.importPath === options.name ? undefined : options.name,
54
- projectType: 'library',
55
- tags: options.parsedTags?.length ? options.parsedTags : undefined,
56
- },
57
- });
58
- }
59
- else {
60
- (0, devkit_1.addProjectConfiguration)(host, options.name, {
61
- root: options.projectRoot,
62
- sourceRoot: (0, devkit_1.joinPathFragments)(options.projectRoot, 'src'),
63
- projectType: 'library',
64
- tags: options.parsedTags,
65
- targets: {},
66
- });
67
- }
68
- (0, create_files_1.createFiles)(host, options);
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
+ });
69
57
  const lintTask = await (0, add_linting_1.addLinting)(host, options);
70
58
  tasks.push(lintTask);
59
+ (0, create_files_1.createFiles)(host, options);
71
60
  // Set up build target
72
61
  if (options.buildable && options.bundler === 'vite') {
73
62
  const { viteConfigurationGenerator, createOrEditViteConfig } = (0, devkit_1.ensurePackage)('@nx/vite', versions_1.nxVersion);
@@ -189,18 +178,11 @@ async function libraryGeneratorInternal(host, schema) {
189
178
  tasks.push(routeTask);
190
179
  (0, set_defaults_1.setDefaults)(host, options);
191
180
  (0, create_ts_config_1.extractTsConfigBase)(host);
192
- if (!options.skipTsConfig && !options.isUsingTsSolutionConfig) {
181
+ if (!options.skipTsConfig) {
193
182
  (0, js_1.addTsConfigPath)(host, options.importPath, [
194
183
  (0, maybe_js_1.maybeJs)(options, (0, devkit_1.joinPathFragments)(options.projectRoot, './src/index.ts')),
195
184
  ]);
196
185
  }
197
- (0, ts_solution_setup_1.updateTsconfigFiles)(host, options.projectRoot, 'tsconfig.lib.json', {
198
- jsx: 'react-jsx',
199
- module: 'esnext',
200
- moduleResolution: 'bundler',
201
- }, options.linter === 'eslint'
202
- ? ['eslint.config.js', 'eslint.config.cjs', 'eslint.config.mjs']
203
- : undefined);
204
186
  if (!options.skipFormat) {
205
187
  await (0, devkit_1.formatFiles)(host);
206
188
  }
@@ -39,5 +39,4 @@ export interface NormalizedSchema extends Schema {
39
39
  appMain?: string;
40
40
  appSourceRoot?: string;
41
41
  unitTestRunner: 'jest' | 'vitest' | 'none';
42
- isUsingTsSolutionConfig?: boolean;
43
42
  }
@@ -75,17 +75,14 @@
75
75
  "description": "The tool to use for running lint checks.",
76
76
  "type": "string",
77
77
  "enum": ["eslint", "none"],
78
- "default": "eslint",
79
- "x-prompt": "Which linter would you like to use?",
80
- "x-priority": "important"
78
+ "default": "eslint"
81
79
  },
82
80
  "unitTestRunner": {
83
81
  "type": "string",
84
82
  "enum": ["vitest", "jest", "none"],
85
83
  "default": "vitest",
86
84
  "description": "Test runner to use for unit tests.",
87
- "x-prompt": "What unit test runner should be used?",
88
- "x-priority": "important"
85
+ "x-prompt": "What unit test runner should be used?"
89
86
  },
90
87
  "inSourceTests": {
91
88
  "type": "boolean",
@@ -160,7 +157,10 @@
160
157
  "bundler": {
161
158
  "type": "string",
162
159
  "description": "The bundler to use. Choosing 'none' means this library is not buildable.",
163
- "enum": ["none", "vite", "rollup"]
160
+ "enum": ["none", "vite", "rollup"],
161
+ "default": "none",
162
+ "x-prompt": "Which bundler would you like to use to build the library? Choose 'none' to skip build setup.",
163
+ "x-priority": "important"
164
164
  },
165
165
  "compiler": {
166
166
  "type": "string",
@@ -1,6 +1,6 @@
1
1
  const { composePlugins, withNx } = require('@nx/webpack');
2
2
  const { withReact } = require('@nx/react');
3
- const { withModuleFederation } = require('@nx/react/module-federation');
3
+ const { withModuleFederation } = require('@nx/module-federation/webpack');
4
4
 
5
5
  const baseConfig = require('./module-federation.config');
6
6
 
@@ -1,6 +1,6 @@
1
1
  const {composePlugins, withNx} = require('@nx/webpack');
2
2
  const {withReact} = require('@nx/react');
3
- const {withModuleFederationForSSR} = require('@nx/react/module-federation');
3
+ const {withModuleFederationForSSR} = require('@nx/module-federation/webpack');
4
4
 
5
5
  const baseConfig = require("./module-federation.server.config");
6
6
 
@@ -1,6 +1,6 @@
1
1
  import {composePlugins, withNx} from '@nx/webpack';
2
2
  import {withReact} from '@nx/react';
3
- import {withModuleFederationForSSR} from '@nx/react/module-federation';
3
+ import {withModuleFederationForSSR} from '@nx/module-federation/webpack';
4
4
 
5
5
  import baseConfig from "./module-federation.server.config";
6
6
 
@@ -1,6 +1,6 @@
1
1
  import {composePlugins, withNx} from '@nx/webpack';
2
2
  import {withReact} from '@nx/react';
3
- import {withModuleFederation} from '@nx/react/module-federation';
3
+ import {withModuleFederation} from '@nx/module-federation/webpack';
4
4
 
5
5
  import baseConfig from './module-federation.config';
6
6
 
@@ -17,6 +17,7 @@ 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");
20
21
  function addModuleFederationFiles(host, options) {
21
22
  const templateVariables = {
22
23
  ...(0, devkit_1.names)(options.projectName),
@@ -46,6 +47,7 @@ function addModuleFederationFiles(host, options) {
46
47
  }
47
48
  }
48
49
  async function remoteGenerator(host, schema) {
50
+ (0, ts_solution_setup_1.assertNotUsingTsSolutionSetup)(host, 'react', 'remote');
49
51
  const tasks = [];
50
52
  const options = {
51
53
  ...(await (0, normalize_options_1.normalizeOptions)(host, schema)),
@@ -80,7 +82,6 @@ async function remoteGenerator(host, schema) {
80
82
  ...options,
81
83
  name: options.projectName,
82
84
  skipFormat: true,
83
- alwaysGenerateProjectJson: true,
84
85
  });
85
86
  tasks.push(initAppTask);
86
87
  if (schema.host) {
@@ -0,0 +1,2 @@
1
+ import { type Tree } from '@nx/devkit';
2
+ export default function migrateWithMfImport(tree: Tree): Promise<void>;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = migrateWithMfImport;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils");
6
+ const tsquery_1 = require("@phenomnomnominal/tsquery");
7
+ const NX_ANGULAR_MODULE_FEDERATION_IMPORT_SELECTOR = 'ImportDeclaration > StringLiteral[value=@nx/react/module-federation], VariableStatement CallExpression:has(Identifier[name=require]) > StringLiteral[value=@nx/react/module-federation]';
8
+ const NEW_IMPORT_PATH = `'@nx/module-federation/webpack'`;
9
+ async function migrateWithMfImport(tree) {
10
+ const projects = new Set();
11
+ (0, executor_options_utils_1.forEachExecutorOptions)(tree, '@nx/react:module-federation-dev-server', (options, project, target) => {
12
+ const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, project);
13
+ projects.add(projectConfig.root);
14
+ });
15
+ for (const projectRoot of projects) {
16
+ (0, devkit_1.visitNotIgnoredFiles)(tree, projectRoot, (filePath) => {
17
+ if (!filePath.endsWith('.ts') && !filePath.endsWith('.js')) {
18
+ return;
19
+ }
20
+ let contents = tree.read(filePath, 'utf-8');
21
+ if (!contents.includes('@nx/react/module-federation')) {
22
+ return;
23
+ }
24
+ const ast = tsquery_1.tsquery.ast(contents);
25
+ const importNodes = (0, tsquery_1.tsquery)(ast, NX_ANGULAR_MODULE_FEDERATION_IMPORT_SELECTOR);
26
+ if (importNodes.length === 0) {
27
+ return;
28
+ }
29
+ const importPathNode = importNodes[0];
30
+ contents = `${contents.slice(0, importPathNode.getStart())}${NEW_IMPORT_PATH}${contents.slice(importPathNode.getEnd())}`;
31
+ tree.write(filePath, contents);
32
+ });
33
+ }
34
+ await (0, devkit_1.formatFiles)(tree);
35
+ }
@@ -3,30 +3,31 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.updateModuleFederationProject = updateModuleFederationProject;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const maybe_js_1 = require("../utils/maybe-js");
6
- const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
7
6
  function updateModuleFederationProject(host, options) {
8
7
  const projectConfig = (0, devkit_1.readProjectConfiguration)(host, options.projectName);
9
8
  if (options.bundler === 'rspack') {
10
9
  projectConfig.targets.build.executor = '@nx/rspack:rspack';
11
10
  projectConfig.targets.build.options = {
12
- ...projectConfig.targets.build.options,
11
+ ...(projectConfig.targets.build.options ?? {}),
13
12
  main: (0, maybe_js_1.maybeJs)({ js: options.js, useJsx: true }, `${options.appProjectRoot}/src/main.ts`),
14
13
  rspackConfig: `${options.appProjectRoot}/rspack.config.${options.typescriptConfiguration && !options.js ? 'ts' : 'js'}`,
15
14
  target: 'web',
16
15
  };
16
+ projectConfig.targets.build.configurations ??= {};
17
17
  projectConfig.targets.build.configurations.production = {
18
- ...projectConfig.targets.build.configurations.production,
18
+ ...(projectConfig.targets.build.configurations?.production ?? {}),
19
19
  rspackConfig: `${options.appProjectRoot}/rspack.config.prod.${options.typescriptConfiguration && !options.js ? 'ts' : 'js'}`,
20
20
  };
21
21
  }
22
22
  else {
23
23
  projectConfig.targets.build.options = {
24
- ...projectConfig.targets.build.options,
24
+ ...(projectConfig.targets.build.options ?? {}),
25
25
  main: (0, maybe_js_1.maybeJs)(options, `${options.appProjectRoot}/src/main.ts`),
26
26
  webpackConfig: `${options.appProjectRoot}/webpack.config.${options.typescriptConfiguration && !options.js ? 'ts' : 'js'}`,
27
27
  };
28
+ projectConfig.targets.build.configurations ??= {};
28
29
  projectConfig.targets.build.configurations.production = {
29
- ...projectConfig.targets.build.configurations.production,
30
+ ...(projectConfig.targets.build.configurations?.production ?? {}),
30
31
  webpackConfig: `${options.appProjectRoot}/webpack.config.prod.${options.typescriptConfiguration && !options.js ? 'ts' : 'js'}`,
31
32
  };
32
33
  }
@@ -77,10 +78,5 @@ function updateModuleFederationProject(host, options) {
77
78
  },
78
79
  },
79
80
  };
80
- // Typechecks must be performed first before build and serve to generate remote d.ts files.
81
- if ((0, ts_solution_setup_1.isUsingTsSolutionSetup)(host)) {
82
- projectConfig.targets.build.dependsOn = ['^build', 'typecheck'];
83
- projectConfig.targets.serve.dependsOn = ['typecheck'];
84
- }
85
81
  (0, devkit_1.updateProjectConfiguration)(host, options.projectName, projectConfig);
86
82
  }