@nx/react 20.0.0-beta.4 → 20.0.0-beta.6

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 (52) hide show
  1. package/migrations.json +0 -112
  2. package/package.json +8 -9
  3. package/plugins/storybook/index.js +1 -2
  4. package/src/generators/application/application.js +4 -2
  5. package/src/generators/application/lib/normalize-options.js +2 -3
  6. package/src/generators/application/lib/show-possible-warnings.js +2 -2
  7. package/src/generators/application/schema.d.ts +2 -4
  8. package/src/generators/application/schema.json +13 -18
  9. package/src/generators/component/lib/normalize-options.js +2 -3
  10. package/src/generators/component/schema.d.ts +3 -3
  11. package/src/generators/component/schema.json +9 -14
  12. package/src/generators/cypress-component-configuration/cypress-component-configuration.js +0 -2
  13. package/src/generators/federate-module/federate-module.js +10 -19
  14. package/src/generators/federate-module/schema.d.ts +0 -1
  15. package/src/generators/federate-module/schema.json +0 -5
  16. package/src/generators/hook/hook.js +1 -2
  17. package/src/generators/hook/schema.d.ts +2 -3
  18. package/src/generators/hook/schema.json +10 -4
  19. package/src/generators/host/host.js +4 -1
  20. package/src/generators/host/lib/normalize-remote.js +0 -1
  21. package/src/generators/host/schema.d.ts +2 -4
  22. package/src/generators/host/schema.json +8 -14
  23. package/src/generators/init/init.js +2 -0
  24. package/src/generators/library/lib/normalize-options.js +1 -1
  25. package/src/generators/library/library.js +5 -3
  26. package/src/generators/library/schema.d.ts +2 -4
  27. package/src/generators/library/schema.json +13 -16
  28. package/src/generators/redux/redux.js +8 -9
  29. package/src/generators/redux/schema.d.ts +3 -5
  30. package/src/generators/redux/schema.json +6 -12
  31. package/src/generators/remote/remote.js +4 -0
  32. package/src/generators/remote/schema.d.ts +2 -4
  33. package/src/generators/remote/schema.json +8 -14
  34. package/src/generators/setup-ssr/setup-ssr.js +6 -0
  35. package/src/generators/setup-tailwind/lib/update-project.js +1 -2
  36. package/src/generators/storybook-configuration/configuration.js +0 -1
  37. package/src/module-federation/with-module-federation-ssr.js +1 -1
  38. package/src/module-federation/with-module-federation.js +1 -1
  39. package/src/utils/ct-utils.js +2 -7
  40. package/src/utils/testing-generators.js +1 -2
  41. package/src/utils/versions.d.ts +1 -1
  42. package/src/utils/versions.js +1 -1
  43. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.d.ts +0 -2
  44. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +0 -9
  45. package/src/migrations/update-16-2-0-remove-package/update-16-2-0-remove-package.d.ts +0 -2
  46. package/src/migrations/update-16-2-0-remove-package/update-16-2-0-remove-package.js +0 -8
  47. package/src/migrations/update-16-3-0/remove-types-react-router-dom-package.d.ts +0 -2
  48. package/src/migrations/update-16-3-0/remove-types-react-router-dom-package.js +0 -8
  49. package/src/migrations/update-16-7-0/add-babel-core.d.ts +0 -2
  50. package/src/migrations/update-16-7-0/add-babel-core.js +0 -14
  51. package/src/migrations/update-16-7-0-add-typings/update-16-7-0-add-typings.d.ts +0 -2
  52. package/src/migrations/update-16-7-0-add-typings/update-16-7-0-add-typings.js +0 -57
@@ -6,28 +6,22 @@
6
6
  "description": "Create Module Federation configuration files for given React Host Application.",
7
7
  "type": "object",
8
8
  "properties": {
9
- "name": {
9
+ "directory": {
10
+ "description": "The directory of the new application.",
10
11
  "type": "string",
11
- "description": "The name of the host application to generate the Module Federation configuration",
12
+ "alias": "dir",
12
13
  "$default": {
13
14
  "$source": "argv",
14
15
  "index": 0
15
16
  },
16
- "x-prompt": "What name would you like to use as the host application?",
17
- "pattern": "^[a-zA-Z][^:]*$",
18
- "x-priority": "important"
17
+ "x-prompt": "Which directory do you want to create the application in?"
19
18
  },
20
- "directory": {
21
- "description": "The directory of the new application.",
19
+ "name": {
22
20
  "type": "string",
23
- "alias": "dir",
21
+ "description": "The name of the host application to generate the Module Federation configuration",
22
+ "pattern": "^[a-zA-Z][^:]*$",
24
23
  "x-priority": "important"
25
24
  },
26
- "projectNameAndRootFormat": {
27
- "description": "Whether to generate the project name and root directory as provided (`as-provided`) or generate them composing their values and taking the configured layout into account (`derived`).",
28
- "type": "string",
29
- "enum": ["as-provided", "derived"]
30
- },
31
25
  "style": {
32
26
  "description": "The file extension to be used for style files.",
33
27
  "type": "string",
@@ -187,6 +181,6 @@
187
181
  "x-priority": "important"
188
182
  }
189
183
  },
190
- "required": ["name"],
184
+ "required": ["directory"],
191
185
  "additionalProperties": false
192
186
  }
@@ -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'], []));
@@ -5,12 +5,12 @@ 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
7
  async function normalizeOptions(host, options) {
8
+ await (0, project_name_and_root_utils_1.ensureProjectName)(host, options, 'library');
8
9
  const { projectName, names: projectNames, projectRoot, importPath, } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
9
10
  name: options.name,
10
11
  projectType: 'library',
11
12
  directory: options.directory,
12
13
  importPath: options.importPath,
13
- projectNameAndRootFormat: options.projectNameAndRootFormat,
14
14
  });
15
15
  const nxJson = (0, devkit_1.readNxJson)(host);
16
16
  const addPlugin = process.env.NX_ADD_PLUGINS !== 'false' &&
@@ -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");
@@ -27,6 +28,7 @@ async function libraryGenerator(host, schema) {
27
28
  });
28
29
  }
29
30
  async function libraryGeneratorInternal(host, schema) {
31
+ (0, ts_solution_setup_1.assertNotUsingTsSolutionSetup)(host, 'react', 'library');
30
32
  const tasks = [];
31
33
  const options = await (0, normalize_options_1.normalizeOptions)(host, schema);
32
34
  if (options.publishable === true && !schema.importPath) {
@@ -124,6 +126,7 @@ async function libraryGeneratorInternal(host, schema) {
124
126
  skipFormat: true,
125
127
  testEnvironment: 'jsdom',
126
128
  addPlugin: options.addPlugin,
129
+ compiler: options.compiler,
127
130
  });
128
131
  tasks.push(vitestTask);
129
132
  createOrEditViteConfig(host, {
@@ -146,10 +149,9 @@ async function libraryGeneratorInternal(host, schema) {
146
149
  }
147
150
  if (options.component) {
148
151
  const relativeCwd = (0, artifact_name_and_directory_utils_1.getRelativeCwd)();
149
- const name = (0, devkit_1.joinPathFragments)(options.projectRoot, 'src/lib', options.fileName);
152
+ const path = (0, devkit_1.joinPathFragments)(options.projectRoot, 'src/lib', options.fileName);
150
153
  const componentTask = await (0, component_1.default)(host, {
151
- nameAndDirectoryFormat: 'as-provided',
152
- name: relativeCwd ? (0, path_1.relative)(relativeCwd, name) : name,
154
+ path: relativeCwd ? (0, path_1.relative)(relativeCwd, path) : path,
153
155
  style: options.style,
154
156
  skipTests: options.unitTestRunner === 'none' ||
155
157
  (options.unitTestRunner === 'vitest' && options.inSourceTests == true),
@@ -1,4 +1,3 @@
1
- import type { ProjectNameAndRootFormat } from '@nx/devkit/src/generators/project-name-and-root-utils';
2
1
  import type { Linter, LinterType } from '@nx/eslint';
3
2
  import type { SupportedStyles } from '../../../typings/style';
4
3
 
@@ -8,14 +7,13 @@ export interface Schema {
8
7
  bundler?: 'none' | 'rollup' | 'vite';
9
8
  compiler?: 'babel' | 'swc';
10
9
  component?: boolean;
11
- directory?: string;
12
- projectNameAndRootFormat?: ProjectNameAndRootFormat;
10
+ directory: string;
13
11
  globalCss?: boolean;
14
12
  importPath?: string;
15
13
  inSourceTests?: boolean;
16
14
  js?: boolean;
17
15
  linter: Linter | LinterType;
18
- name: string;
16
+ name?: string;
19
17
  publishable?: boolean;
20
18
  routing?: boolean;
21
19
  setParserOptionsProject?: boolean;
@@ -16,28 +16,21 @@
16
16
  }
17
17
  ],
18
18
  "properties": {
19
- "name": {
19
+ "directory": {
20
20
  "type": "string",
21
- "description": "Library name",
21
+ "description": "A directory where the lib is placed.",
22
+ "alias": "dir",
22
23
  "$default": {
23
24
  "$source": "argv",
24
25
  "index": 0
25
26
  },
26
- "x-prompt": "What name would you like to use for the library?",
27
- "pattern": "(?:^@[a-zA-Z0-9-*~][a-zA-Z0-9-*._~]*\\/[a-zA-Z0-9-~][a-zA-Z0-9-._~]*|^[a-zA-Z][^:]*)$",
28
- "x-priority": "important"
27
+ "x-prompt": "Which directory do you want to create the library in?"
29
28
  },
30
- "directory": {
29
+ "name": {
31
30
  "type": "string",
32
- "description": "A directory where the lib is placed.",
33
- "alias": "dir",
31
+ "description": "Library name",
34
32
  "x-priority": "important"
35
33
  },
36
- "projectNameAndRootFormat": {
37
- "description": "Whether to generate the project name and root directory as provided (`as-provided`) or generate them composing their values and taking the configured layout into account (`derived`).",
38
- "type": "string",
39
- "enum": ["as-provided", "derived"]
40
- },
41
34
  "style": {
42
35
  "description": "The file extension to be used for style files.",
43
36
  "type": "string",
@@ -47,7 +40,10 @@
47
40
  "message": "Which stylesheet format would you like to use?",
48
41
  "type": "list",
49
42
  "items": [
50
- { "value": "css", "label": "CSS" },
43
+ {
44
+ "value": "css",
45
+ "label": "CSS"
46
+ },
51
47
  {
52
48
  "value": "scss",
53
49
  "label": "SASS(.scss) [ https://sass-lang.com ]"
@@ -83,7 +79,8 @@
83
79
  },
84
80
  "unitTestRunner": {
85
81
  "type": "string",
86
- "enum": ["jest", "vitest", "none"],
82
+ "enum": ["vitest", "jest", "none"],
83
+ "default": "vitest",
87
84
  "description": "Test runner to use for unit tests.",
88
85
  "x-prompt": "What unit test runner should be used?"
89
86
  },
@@ -188,5 +185,5 @@
188
185
  "default": false
189
186
  }
190
187
  },
191
- "required": ["name"]
188
+ "required": ["directory"]
192
189
  }
@@ -20,7 +20,7 @@ async function reduxGenerator(host, schema) {
20
20
  return installTask;
21
21
  }
22
22
  function generateReduxFiles(host, options) {
23
- (0, devkit_1.generateFiles)(host, (0, devkit_1.joinPathFragments)(__dirname, './files'), options.directory, {
23
+ (0, devkit_1.generateFiles)(host, (0, devkit_1.joinPathFragments)(__dirname, './files'), options.projectDirectory, {
24
24
  ...options,
25
25
  tmpl: '',
26
26
  });
@@ -42,8 +42,8 @@ function addExportsToBarrel(host, options) {
42
42
  const indexSource = host.read(indexFilePath, 'utf-8');
43
43
  if (indexSource !== null) {
44
44
  const indexSourceFile = tsModule.createSourceFile(indexFilePath, indexSource, tsModule.ScriptTarget.Latest, true);
45
- const statePath = options.directory
46
- ? `./lib/${options.directory}/${options.fileName}`
45
+ const statePath = options.path
46
+ ? `./lib/${options.path}/${options.fileName}`
47
47
  : `./lib/${options.fileName}`;
48
48
  const changes = (0, devkit_1.applyChangesToString)(indexSource, (0, ast_utils_1.addImport)(indexSourceFile, `export * from '${statePath}.slice';`));
49
49
  host.write(indexFilePath, changes);
@@ -78,9 +78,8 @@ function updateReducerConfiguration(host, options) {
78
78
  }
79
79
  async function normalizeOptions(host, options) {
80
80
  const { artifactName: name, directory, fileName, project: projectName, } = await (0, artifact_name_and_directory_utils_1.determineArtifactNameAndDirectoryOptions)(host, {
81
+ path: options.path,
81
82
  name: options.name,
82
- directory: options.directory,
83
- nameAndDirectoryFormat: options.nameAndDirectoryFormat,
84
83
  fileExtension: 'tsx',
85
84
  });
86
85
  let appProjectSourcePath;
@@ -94,8 +93,8 @@ async function normalizeOptions(host, options) {
94
93
  ? tsConfigJson.compilerOptions.paths || {}
95
94
  : {};
96
95
  const modulePath = projectType === 'application'
97
- ? options.directory
98
- ? `./app/${options.directory}/${extraNames.fileName}.slice`
96
+ ? options.path
97
+ ? `./app/${options.path}/${extraNames.fileName}.slice`
99
98
  : `./app/${extraNames.fileName}.slice`
100
99
  : Object.keys(tsPaths).find((k) => tsPaths[k].some((s) => s.includes(sourceRoot)));
101
100
  // If --project is set to an app, automatically configure store
@@ -118,8 +117,8 @@ async function normalizeOptions(host, options) {
118
117
  ...options,
119
118
  ...extraNames,
120
119
  fileName,
121
- constantName: (0, devkit_1.names)(options.name).constantName.toUpperCase(),
122
- directory,
120
+ constantName: (0, devkit_1.names)(name).constantName.toUpperCase(),
121
+ projectDirectory: directory,
123
122
  projectType,
124
123
  projectSourcePath: sourceRoot,
125
124
  projectModulePath: modulePath,
@@ -1,15 +1,13 @@
1
- import type { NameAndDirectoryFormat } from '@nx/devkit/src/generators/artifact-name-and-directory-utils';
2
-
3
1
  export interface Schema {
4
- name: string;
5
- directory?: string;
2
+ path: string;
3
+ name?: string;
6
4
  appProject?: string;
7
5
  js?: string;
8
- nameAndDirectoryFormat?: NameAndDirectoryFormat;
9
6
  }
10
7
 
11
8
  interface NormalizedSchema extends Schema {
12
9
  projectType: string;
10
+ projectDirectory: string;
13
11
  projectSourcePath: string;
14
12
  projectModulePath: string;
15
13
  appProjectSourcePath: string;
@@ -6,27 +6,21 @@
6
6
  "description": "Create a Redux state slice for a React project.",
7
7
  "type": "object",
8
8
  "properties": {
9
- "name": {
9
+ "path": {
10
10
  "type": "string",
11
- "description": "Redux slice name.",
11
+ "description": "Path where the Redux slice will be generated.",
12
12
  "$default": {
13
13
  "$source": "argv",
14
14
  "index": 0
15
15
  },
16
+ "x-prompt": "Where should the Redux slice be generated?",
16
17
  "x-priority": "important"
17
18
  },
18
- "directory": {
19
+ "name": {
19
20
  "type": "string",
20
- "alias": "dir",
21
- "default": "",
22
- "description": "The directory at which to create the Redux files. When `--nameAndDirectoryFormat=as-provided`, it will be relative to the current working directory. Otherwise, it will be relative to the project root.",
21
+ "description": "Redux slice name.",
23
22
  "x-priority": "important"
24
23
  },
25
- "nameAndDirectoryFormat": {
26
- "description": "Whether to generate the component in the directory as provided, relative to the current working directory and ignoring the project (`as-provided`) or generate it using the project and directory relative to the workspace root (`derived`).",
27
- "type": "string",
28
- "enum": ["as-provided", "derived"]
29
- },
30
24
  "appProject": {
31
25
  "type": "string",
32
26
  "description": "The application project to add the slice to.",
@@ -38,5 +32,5 @@
38
32
  "default": false
39
33
  }
40
34
  },
41
- "required": ["name"]
35
+ "required": ["path"]
42
36
  }
@@ -16,6 +16,8 @@ const add_mf_env_to_inputs_1 = require("../../utils/add-mf-env-to-inputs");
16
16
  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
+ 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");
19
21
  function addModuleFederationFiles(host, options) {
20
22
  const templateVariables = {
21
23
  ...(0, devkit_1.names)(options.projectName),
@@ -45,6 +47,7 @@ function addModuleFederationFiles(host, options) {
45
47
  }
46
48
  }
47
49
  async function remoteGenerator(host, schema) {
50
+ (0, ts_solution_setup_1.assertNotUsingTsSolutionSetup)(host, 'react', 'remote');
48
51
  const tasks = [];
49
52
  const options = {
50
53
  ...(await (0, normalize_options_1.normalizeOptions)(host, schema)),
@@ -66,6 +69,7 @@ async function remoteGenerator(host, schema) {
66
69
  throw new Error(`Invalid remote name provided: ${options.projectName}. ${isValidRemote.message}`);
67
70
  }
68
71
  }
72
+ await (0, project_name_and_root_utils_1.ensureProjectName)(host, options, 'application');
69
73
  const initAppTask = await (0, application_1.default)(host, {
70
74
  ...options,
71
75
  name: options.projectName,
@@ -1,4 +1,3 @@
1
- import type { ProjectNameAndRootFormat } from '@nx/devkit/src/generators/project-name-and-root-utils';
2
1
  import type { Linter, LinterType } from '@nx/eslint';
3
2
  import type { SupportedStyles } from '../../../typings/style';
4
3
  import type { NormalizedSchema as ApplicationNormalizedSchema } from '../application/schema';
@@ -7,14 +6,13 @@ export interface Schema {
7
6
  classComponent?: boolean;
8
7
  compiler?: 'babel' | 'swc';
9
8
  devServerPort?: number;
10
- directory?: string;
11
- projectNameAndRootFormat?: ProjectNameAndRootFormat;
9
+ directory: string;
12
10
  e2eTestRunner: 'cypress' | 'playwright' | 'none';
13
11
  globalCss?: boolean;
14
12
  host?: string;
15
13
  js?: boolean;
16
14
  linter: Linter | LinterType;
17
- name: string;
15
+ name?: string;
18
16
  routing?: boolean;
19
17
  setParserOptionsProject?: boolean;
20
18
  skipFormat: boolean;
@@ -6,28 +6,22 @@
6
6
  "description": "Create Module Federation configuration files for given React Remote Application.",
7
7
  "type": "object",
8
8
  "properties": {
9
- "name": {
9
+ "directory": {
10
+ "description": "The directory of the new application.",
10
11
  "type": "string",
11
- "description": "The name of the remote application to generate the Module Federation configuration",
12
+ "alias": "dir",
12
13
  "$default": {
13
14
  "$source": "argv",
14
15
  "index": 0
15
16
  },
16
- "x-prompt": "What name would you like to use as the remote application?",
17
- "pattern": "^[a-zA-Z][^:]*$",
18
- "x-priority": "important"
17
+ "x-prompt": "Which directory do you want to create the application in?"
19
18
  },
20
- "directory": {
21
- "description": "The directory of the new application.",
19
+ "name": {
22
20
  "type": "string",
23
- "alias": "dir",
21
+ "description": "The name of the remote application to generate the Module Federation configuration",
22
+ "pattern": "^[a-zA-Z][^:]*$",
24
23
  "x-priority": "important"
25
24
  },
26
- "projectNameAndRootFormat": {
27
- "description": "Whether to generate the project name and root directory as provided (`as-provided`) or generate them composing their values and taking the configured layout into account (`derived`).",
28
- "type": "string",
29
- "enum": ["as-provided", "derived"]
30
- },
31
25
  "dynamic": {
32
26
  "type": "boolean",
33
27
  "description": "Should the host application use dynamic federation?",
@@ -186,6 +180,6 @@
186
180
  "x-priority": "important"
187
181
  }
188
182
  },
189
- "required": ["name"],
183
+ "required": ["directory"],
190
184
  "additionalProperties": false
191
185
  }
@@ -65,6 +65,12 @@ async function setupSsrGenerator(tree, options) {
65
65
  if (projectConfig.targets.build.options?.outputPath) {
66
66
  projectConfig.targets.build.options.outputPath = (0, devkit_1.joinPathFragments)(originalOutputPath, 'browser');
67
67
  }
68
+ if (projectConfig.targets.build.executor === '@nx/rspack:rspack') {
69
+ options.bundler = 'rspack';
70
+ }
71
+ else if (projectConfig.targets.build.executor === '@nx/webpack:webpack') {
72
+ options.bundler = 'webpack';
73
+ }
68
74
  projectConfig.targets = {
69
75
  ...projectConfig.targets,
70
76
  server: {
@@ -3,8 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.updateProject = updateProject;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  function updateProject(tree, config, options) {
6
- if (config?.targets?.build?.executor === '@nx/webpack:webpack' ||
7
- config?.targets?.build?.executor === '@nrwl/webpack:webpack') {
6
+ if (config?.targets?.build?.executor === '@nx/webpack:webpack') {
8
7
  config.targets.build.options ??= {};
9
8
  config.targets.build.options.postcssConfig = (0, devkit_1.joinPathFragments)(config.root, 'postcss.config.js');
10
9
  (0, devkit_1.updateProjectConfiguration)(tree, options.project, config);
@@ -33,7 +33,6 @@ async function storybookConfigurationGeneratorInternal(host, schema) {
33
33
  const projectConfig = (0, devkit_1.readProjectConfiguration)(host, schema.project);
34
34
  if (findWebpackConfig(host, projectConfig.root) ||
35
35
  projectConfig.targets['build']?.executor === '@nx/rollup:rollup' ||
36
- projectConfig.targets['build']?.executor === '@nrwl/rollup:rollup' ||
37
36
  projectConfig.targets['build']?.executor === '@nx/expo:build') {
38
37
  uiFramework = '@storybook/react-webpack5';
39
38
  }
@@ -17,7 +17,7 @@ async function withModuleFederationForSSR(options, configOverride) {
17
17
  runtimeChunk: false,
18
18
  };
19
19
  config.plugins.push(new (require('@module-federation/enhanced').ModuleFederationPlugin)({
20
- name: options.name,
20
+ name: options.name.replace(/-/g, '_'),
21
21
  filename: 'remoteEntry.js',
22
22
  exposes: options.exposes,
23
23
  remotes: mappedRemotes,
@@ -26,7 +26,7 @@ async function withModuleFederation(options, configOverride) {
26
26
  config.optimization.runtimeChunk = 'single';
27
27
  }
28
28
  config.plugins.push(new webpack_1.ModuleFederationPlugin({
29
- name: options.name,
29
+ name: options.name.replace(/-/g, '_'),
30
30
  filename: 'remoteEntry.js',
31
31
  exposes: options.exposes,
32
32
  remotes: mappedRemotes,
@@ -60,17 +60,12 @@ function assertValidConfig(config) {
60
60
  }
61
61
  async function getBundlerFromTarget(found, tree) {
62
62
  if (found.target && found.config?.executor) {
63
- return found.config.executor === '@nrwl/vite:build' ||
64
- found.config.executor === '@nx/vite:build'
65
- ? 'vite'
66
- : 'webpack';
63
+ return found.config.executor === '@nx/vite:build' ? 'vite' : 'webpack';
67
64
  }
68
65
  const { target, project } = (0, devkit_1.parseTargetString)(found.target, await (0, devkit_1.createProjectGraphAsync)());
69
66
  const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, project);
70
67
  const executor = projectConfig?.targets?.[target]?.executor;
71
- return executor === '@nrwl/vite:build' || executor === '@nx/vite:build'
72
- ? 'vite'
73
- : 'webpack';
68
+ return executor === '@nx/vite:build' ? 'vite' : 'webpack';
74
69
  }
75
70
  async function getActualBundler(tree, options, found) {
76
71
  // Specifically undefined to allow Remix workaround of passing an empty string
@@ -12,8 +12,7 @@ async function createApp(tree, appName) {
12
12
  skipFormat: true,
13
13
  style: 'css',
14
14
  unitTestRunner: 'none',
15
- name: appName,
16
- projectNameAndRootFormat: 'as-provided',
15
+ directory: appName,
17
16
  });
18
17
  }
19
18
  async function createLib(tree, libName) {
@@ -37,7 +37,7 @@ export declare const isbotVersion = "^3.6.5";
37
37
  export declare const corsVersion = "~2.8.5";
38
38
  export declare const typesCorsVersion = "~2.8.12";
39
39
  export declare const moduleFederationNodeVersion = "~2.5.0";
40
- export declare const moduleFederationEnhancedVersion = "~0.6.0";
40
+ export declare const moduleFederationEnhancedVersion = "0.6.6";
41
41
  export declare const lessVersion = "3.12.2";
42
42
  export declare const sassVersion = "^1.55.0";
43
43
  export declare const rollupPluginUrlVersion = "^8.0.2";
@@ -43,7 +43,7 @@ exports.isbotVersion = '^3.6.5';
43
43
  exports.corsVersion = '~2.8.5';
44
44
  exports.typesCorsVersion = '~2.8.12';
45
45
  exports.moduleFederationNodeVersion = '~2.5.0';
46
- exports.moduleFederationEnhancedVersion = '~0.6.0';
46
+ exports.moduleFederationEnhancedVersion = '0.6.6';
47
47
  // style preprocessors
48
48
  exports.lessVersion = '3.12.2';
49
49
  exports.sassVersion = '^1.55.0';
@@ -1,2 +0,0 @@
1
- import { Tree } from '@nx/devkit';
2
- export default function replacePackage(tree: Tree): Promise<void>;
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = replacePackage;
4
- const devkit_1 = require("@nx/devkit");
5
- const replace_package_1 = require("@nx/devkit/src/utils/replace-package");
6
- async function replacePackage(tree) {
7
- await (0, replace_package_1.replaceNrwlPackageWithNxPackage)(tree, '@nrwl/react', '@nx/react');
8
- await (0, devkit_1.formatFiles)(tree);
9
- }
@@ -1,2 +0,0 @@
1
- import { Tree } from '@nx/devkit';
2
- export default function removePackage(tree: Tree): Promise<void>;
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = removePackage;
4
- const devkit_1 = require("@nx/devkit");
5
- async function removePackage(tree) {
6
- (0, devkit_1.removeDependenciesFromPackageJson)(tree, [], ['react-test-renderer']);
7
- await (0, devkit_1.formatFiles)(tree);
8
- }
@@ -1,2 +0,0 @@
1
- import { Tree } from '@nx/devkit';
2
- export default function removePackage(tree: Tree): Promise<void>;
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = removePackage;
4
- const devkit_1 = require("@nx/devkit");
5
- async function removePackage(tree) {
6
- (0, devkit_1.removeDependenciesFromPackageJson)(tree, [], ['react-test-renderer']);
7
- await (0, devkit_1.formatFiles)(tree);
8
- }
@@ -1,2 +0,0 @@
1
- import { Tree } from '@nx/devkit';
2
- export default function addBabelCore(tree: Tree): Promise<void>;
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = addBabelCore;
4
- const devkit_1 = require("@nx/devkit");
5
- const versions_1 = require("../../utils/versions");
6
- async function addBabelCore(tree) {
7
- const packageJson = (0, devkit_1.readJson)(tree, 'package.json');
8
- if (packageJson?.devDependencies['@babel/preset-react']) {
9
- (0, devkit_1.addDependenciesToPackageJson)(tree, {}, {
10
- '@babel/core': versions_1.babelCoreVersion,
11
- });
12
- await (0, devkit_1.formatFiles)(tree);
13
- }
14
- }
@@ -1,2 +0,0 @@
1
- import { Tree } from '@nx/devkit';
2
- export default function addTypings(tree: Tree): Promise<void>;
@@ -1,57 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = addTypings;
4
- const devkit_1 = require("@nx/devkit");
5
- async function addTypings(tree) {
6
- const projects = (0, devkit_1.getProjects)(tree);
7
- const buildExecutors = [
8
- '@nx/webpack:webpack',
9
- '@nx/vite:build',
10
- '@nx/rspack:rspack',
11
- ];
12
- const serveExecutors = [
13
- '@nx/webpack:dev-server',
14
- '@nx/vite:dev-server',
15
- '@nx/rspack:dev-server',
16
- ];
17
- const relatedTsConfigs = [
18
- 'tsconfig.app.json',
19
- 'tsconfig.lib.json',
20
- 'tsconfig.spec.json',
21
- ];
22
- const typesToAdd = [
23
- '@nx/react/typings/cssmodule.d.ts',
24
- '@nx/react/typings/image.d.ts',
25
- ];
26
- for (const [, config] of projects) {
27
- if (!buildExecutors.includes(config?.targets?.build?.executor)) {
28
- continue;
29
- }
30
- if (config?.targets?.serve?.executor &&
31
- !serveExecutors.includes(config?.targets?.serve?.executor)) {
32
- continue;
33
- }
34
- const rootPath = config.root;
35
- const projectTsConfigPath = (0, devkit_1.joinPathFragments)(rootPath, 'tsconfig.json');
36
- const projectTsConfig = (0, devkit_1.readJson)(tree, projectTsConfigPath);
37
- if (projectTsConfig.compilerOptions?.jsx !== 'react-jsx') {
38
- continue;
39
- }
40
- relatedTsConfigs.forEach((tsConfig) => {
41
- const tsConfigPath = (0, devkit_1.joinPathFragments)(rootPath, tsConfig);
42
- if (tree.exists(tsConfigPath)) {
43
- (0, devkit_1.updateJson)(tree, tsConfigPath, (json) => {
44
- const compilerOptions = json.compilerOptions || {};
45
- compilerOptions.types = [
46
- ...new Set([...(compilerOptions.types || []), ...typesToAdd]),
47
- ];
48
- if (json.files?.length > 0) {
49
- json.files = json.files.filter((file) => !['cssmodule.d.ts', 'image.d.ts'].includes(file));
50
- }
51
- return { ...json, compilerOptions };
52
- });
53
- }
54
- });
55
- }
56
- await (0, devkit_1.formatFiles)(tree);
57
- }