@nx/react 17.0.5 → 17.0.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 (154) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +4 -9
  3. package/generators.json +1 -1
  4. package/index.d.ts +0 -1
  5. package/index.js +1 -3
  6. package/migrations.json +0 -21
  7. package/package.json +7 -7
  8. package/plugins/component-testing/index.js +24 -52
  9. package/plugins/component-testing/webpack-fallback.js +1 -1
  10. package/plugins/storybook/index.js +2 -6
  11. package/plugins/storybook/merge-plugins.d.ts +1 -1
  12. package/plugins/webpack.d.ts +3 -1
  13. package/plugins/webpack.js +11 -3
  14. package/plugins/with-react.d.ts +4 -2
  15. package/plugins/with-react.js +58 -2
  16. package/src/executors/module-federation-dev-server/module-federation-dev-server.impl.d.ts +0 -13
  17. package/src/executors/module-federation-dev-server/module-federation-dev-server.impl.js +58 -173
  18. package/src/executors/module-federation-dev-server/schema.json +1 -13
  19. package/src/generators/application/application.js +18 -41
  20. package/src/generators/application/files/base-vite/index.html__tmpl__ +1 -1
  21. package/src/generators/application/files/base-webpack/src/environments/environment.prod.ts__tmpl__ +3 -0
  22. package/src/generators/application/files/base-webpack/src/environments/environment.ts__tmpl__ +6 -0
  23. package/src/generators/application/files/base-webpack/src/index.html +2 -0
  24. package/src/generators/application/files/base-webpack/webpack.config.js__tmpl__ +5 -46
  25. package/src/generators/application/files/nx-welcome/src/app/nx-welcome.tsx +13 -54
  26. package/src/generators/application/lib/add-e2e.js +7 -25
  27. package/src/generators/application/lib/add-jest.js +2 -2
  28. package/src/generators/application/lib/add-project.d.ts +2 -2
  29. package/src/generators/application/lib/add-project.js +15 -12
  30. package/src/generators/application/lib/add-routing.d.ts +1 -1
  31. package/src/generators/application/lib/add-routing.js +8 -4
  32. package/src/generators/application/lib/create-application-files.js +1 -30
  33. package/src/generators/application/lib/install-common-dependencies.js +1 -15
  34. package/src/generators/application/lib/normalize-options.js +1 -35
  35. package/src/generators/application/lib/set-defaults.js +0 -1
  36. package/src/generators/application/lib/update-jest-config.js +8 -8
  37. package/src/generators/application/schema.d.ts +0 -5
  38. package/src/generators/application/schema.json +3 -7
  39. package/src/generators/component/files/__fileName__.tsx__tmpl__ +22 -39
  40. package/src/generators/component/lib/normalize-options.js +2 -4
  41. package/src/generators/component/schema.d.ts +4 -6
  42. package/src/generators/component/schema.json +7 -7
  43. package/src/generators/component-cypress-spec/schema.json +1 -1
  44. package/src/generators/component-story/schema.json +1 -1
  45. package/src/generators/component-test/schema.json +1 -1
  46. package/src/generators/cypress-component-configuration/cypress-component-configuration.d.ts +1 -2
  47. package/src/generators/cypress-component-configuration/cypress-component-configuration.js +7 -18
  48. package/src/generators/cypress-component-configuration/lib/add-files.js +6 -1
  49. package/src/generators/cypress-component-configuration/schema.d.ts +0 -1
  50. package/src/generators/federate-module/federate-module.js +2 -2
  51. package/src/generators/federate-module/schema.d.ts +1 -1
  52. package/src/generators/federate-module/schema.json +3 -4
  53. package/src/generators/hook/files/__fileName__.ts__tmpl__ +15 -15
  54. package/src/generators/hook/schema.d.ts +4 -4
  55. package/src/generators/hook/schema.json +5 -5
  56. package/src/generators/host/files/module-federation/module-federation.config.js__tmpl__ +2 -17
  57. package/src/generators/host/files/module-federation/src/main.ts__tmpl__ +1 -0
  58. package/src/generators/host/files/module-federation-ssr/module-federation.server.config.js__tmpl__ +2 -5
  59. package/src/generators/host/files/module-federation-ssr-ts/module-federation.server.config.ts__tmpl__ +2 -5
  60. package/src/generators/host/files/module-federation-ts/module-federation.config.ts__tmpl__ +2 -17
  61. package/src/generators/host/files/module-federation-ts/src/main.ts__tmpl__ +1 -0
  62. package/src/generators/host/files/module-federation-ts/webpack.config.prod.ts__tmpl__ +1 -2
  63. package/src/generators/host/files/module-federation-ts/webpack.config.ts__tmpl__ +2 -2
  64. package/src/generators/host/host.js +1 -15
  65. package/src/generators/host/lib/add-module-federation-files.d.ts +1 -2
  66. package/src/generators/host/lib/add-module-federation-files.js +11 -24
  67. package/src/generators/host/lib/setup-ssr-for-host.js +0 -1
  68. package/src/generators/host/lib/update-module-federation-e2e-project.js +5 -7
  69. package/src/generators/host/schema.d.ts +2 -5
  70. package/src/generators/host/schema.json +6 -16
  71. package/src/generators/init/init.d.ts +1 -1
  72. package/src/generators/init/init.js +49 -10
  73. package/src/generators/init/schema.d.ts +6 -1
  74. package/src/generators/init/schema.json +22 -5
  75. package/src/generators/library/lib/add-linting.js +2 -2
  76. package/src/generators/library/lib/add-rollup-build-target.d.ts +1 -2
  77. package/src/generators/library/lib/add-rollup-build-target.js +8 -16
  78. package/src/generators/library/lib/install-common-dependencies.js +5 -13
  79. package/src/generators/library/lib/maybe-js.d.ts +2 -0
  80. package/src/generators/library/lib/normalize-options.js +5 -34
  81. package/src/generators/library/lib/update-app-routes.js +1 -1
  82. package/src/generators/library/library.js +6 -17
  83. package/src/generators/library/schema.d.ts +0 -1
  84. package/src/generators/library/schema.json +3 -3
  85. package/src/generators/redux/schema.d.ts +1 -1
  86. package/src/generators/redux/schema.json +2 -2
  87. package/src/generators/remote/files/module-federation/module-federation.config.js__tmpl__ +1 -4
  88. package/src/generators/remote/files/module-federation-ssr/module-federation.server.config.js__tmpl__ +1 -1
  89. package/src/generators/remote/files/module-federation-ssr-ts/module-federation.server.config.ts__tmpl__ +1 -1
  90. package/src/generators/remote/files/module-federation-ts/module-federation.config.ts__tmpl__ +1 -4
  91. package/src/generators/remote/lib/setup-ssr-for-remote.js +1 -5
  92. package/src/generators/remote/lib/setup-tspath-for-remote.js +1 -2
  93. package/src/generators/remote/lib/update-host-with-remote.js +1 -10
  94. package/src/generators/remote/remote.js +2 -22
  95. package/src/generators/remote/schema.d.ts +2 -3
  96. package/src/generators/remote/schema.json +6 -17
  97. package/src/generators/setup-ssr/schema.json +1 -1
  98. package/src/generators/setup-ssr/setup-ssr.js +7 -23
  99. package/src/generators/setup-tailwind/schema.json +1 -1
  100. package/src/generators/stories/schema.json +1 -1
  101. package/src/generators/stories/stories.js +5 -17
  102. package/src/generators/storybook-configuration/configuration.d.ts +0 -2
  103. package/src/generators/storybook-configuration/configuration.js +15 -37
  104. package/src/generators/storybook-configuration/schema.d.ts +1 -2
  105. package/src/generators/storybook-configuration/schema.json +7 -7
  106. package/src/module-federation/ast-utils.js +1 -1
  107. package/src/module-federation/utils.js +1 -8
  108. package/src/module-federation/with-module-federation-ssr.js +0 -3
  109. package/src/module-federation/with-module-federation.d.ts +3 -3
  110. package/src/module-federation/with-module-federation.js +4 -14
  111. package/src/rules/update-module-federation-project.d.ts +0 -2
  112. package/src/rules/update-module-federation-project.js +3 -12
  113. package/src/utils/assertion.js +0 -1
  114. package/src/utils/ct-utils.d.ts +1 -6
  115. package/src/utils/ct-utils.js +9 -39
  116. package/src/utils/get-in-source-vitest-tests-template.js +1 -1
  117. package/src/utils/versions.d.ts +1 -1
  118. package/src/utils/versions.js +1 -1
  119. package/typings/style.d.ts +0 -1
  120. package/mf/dynamic-federation.d.ts +0 -4
  121. package/mf/dynamic-federation.js +0 -75
  122. package/mf/index.d.ts +0 -1
  123. package/mf/index.js +0 -7
  124. package/plugins/nx-react-webpack-plugin/lib/apply-react-config.d.ts +0 -4
  125. package/plugins/nx-react-webpack-plugin/lib/apply-react-config.js +0 -86
  126. package/plugins/nx-react-webpack-plugin/nx-react-webpack-plugin.d.ts +0 -8
  127. package/plugins/nx-react-webpack-plugin/nx-react-webpack-plugin.js +0 -13
  128. package/src/generators/application/files/style-tailwind/src/app/__fileName__.tsx__tmpl__ +0 -33
  129. package/src/generators/application/files/style-tailwind/src/styles.css +0 -1
  130. package/src/generators/host/files/common/src/main.js__tmpl__ +0 -10
  131. package/src/generators/host/files/common/tsconfig.lint.json__tmpl__ +0 -19
  132. package/src/generators/host/files/common-ts/src/app/__fileName__.tsx__tmpl__ +0 -41
  133. package/src/generators/host/files/common-ts/src/main.ts__tmpl__ +0 -10
  134. package/src/generators/remote/files/module-federation-ssr-ts/tsconfig.lint.json__tmpl__ +0 -19
  135. package/src/generators/remote/files/module-federation-ts/tsconfig.lint.json__tmpl__ +0 -19
  136. package/src/generators/remote/lib/add-remote-to-dynamic-host.d.ts +0 -2
  137. package/src/generators/remote/lib/add-remote-to-dynamic-host.js +0 -11
  138. package/src/migrations/update-18-0-0/add-mf-env-var-to-target-defaults.d.ts +0 -2
  139. package/src/migrations/update-18-0-0/add-mf-env-var-to-target-defaults.js +0 -26
  140. package/src/migrations/update-18-1-1/fix-target-defaults-inputs.d.ts +0 -2
  141. package/src/migrations/update-18-1-1/fix-target-defaults-inputs.js +0 -53
  142. package/src/utils/add-mf-env-to-inputs.d.ts +0 -2
  143. package/src/utils/add-mf-env-to-inputs.js +0 -27
  144. package/src/utils/has-vite-plugin.d.ts +0 -2
  145. package/src/utils/has-vite-plugin.js +0 -11
  146. package/src/utils/has-webpack-plugin.d.ts +0 -2
  147. package/src/utils/has-webpack-plugin.js +0 -11
  148. package/src/utils/maybe-js.d.ts +0 -3
  149. /package/src/generators/host/files/common/src/app/{__fileName__.js__tmpl__ → __fileName__.tsx__tmpl__} +0 -0
  150. /package/src/{utils → generators/library/lib}/maybe-js.js +0 -0
  151. /package/src/generators/remote/files/{common/src/main.js__tmpl__ → module-federation/src/main.ts__tmpl__} +0 -0
  152. /package/src/generators/remote/files/{common/src/remote-entry.js__tmpl__ → module-federation/src/remote-entry.ts__tmpl__} +0 -0
  153. /package/src/generators/remote/files/{common-ts → module-federation-ts}/src/main.ts__tmpl__ +0 -0
  154. /package/src/generators/remote/files/{common-ts → module-federation-ts}/src/remote-entry.ts__tmpl__ +0 -0
@@ -22,7 +22,7 @@ async function normalizeOptions(tree, options) {
22
22
  });
23
23
  const project = (0, devkit_1.readProjectConfiguration)(tree, projectName);
24
24
  const { className } = (0, devkit_1.names)(name);
25
- const { sourceRoot: projectSourceRoot, root: projectRoot, projectType, } = project;
25
+ const { sourceRoot: projectSourceRoot, projectType } = project;
26
26
  const styledModule = /^(css|scss|less|none)$/.test(options.style)
27
27
  ? null
28
28
  : options.style;
@@ -33,8 +33,6 @@ async function normalizeOptions(tree, options) {
33
33
  options.routing = options.routing ?? false;
34
34
  options.globalCss = options.globalCss ?? false;
35
35
  options.inSourceTests = options.inSourceTests ?? false;
36
- //TODO (nicholas): Remove when Next page generator is removed
37
- options.isNextPage = options.isNextPage ?? false;
38
36
  return {
39
37
  ...options,
40
38
  projectName,
@@ -44,7 +42,7 @@ async function normalizeOptions(tree, options) {
44
42
  className,
45
43
  fileName,
46
44
  filePath,
47
- projectSourceRoot: projectSourceRoot ?? projectRoot,
45
+ projectSourceRoot,
48
46
  };
49
47
  }
50
48
  exports.normalizeOptions = normalizeOptions;
@@ -3,7 +3,7 @@ import { SupportedStyles } from '../../../typings/style';
3
3
  export interface Schema {
4
4
  name: string;
5
5
  /**
6
- * @deprecated Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx v19.
6
+ * @deprecated Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx v18.
7
7
  */
8
8
  project?: string;
9
9
  style: SupportedStyles;
@@ -11,18 +11,18 @@ export interface Schema {
11
11
  directory?: string;
12
12
  export?: boolean;
13
13
  /**
14
- * @deprecated Provide the `name` in pascal-case and use the `as-provided` format. This option will be removed in Nx v19.
14
+ * @deprecated Provide the `name` in pascal-case and use the `as-provided` format. This option will be removed in Nx v18.
15
15
  */
16
16
  pascalCaseFiles?: boolean;
17
17
  /**
18
- * @deprecated Provide the `directory` in pascal-case and use the `as-provided` format. This option will be removed in Nx v19.
18
+ * @deprecated Provide the `directory` in pascal-case and use the `as-provided` format. This option will be removed in Nx v18.
19
19
  */
20
20
  pascalCaseDirectory?: boolean;
21
21
  classComponent?: boolean;
22
22
  routing?: boolean;
23
23
  js?: boolean;
24
24
  /**
25
- * @deprecated Provide the `directory` option instead and use the `as-provided` format. This option will be removed in Nx v19.
25
+ * @deprecated Provide the `directory` option instead and use the `as-provided` format. This option will be removed in Nx v18.
26
26
  */
27
27
  flat?: boolean;
28
28
  globalCss?: boolean;
@@ -33,8 +33,6 @@ export interface Schema {
33
33
  // Used by other wrapping generators to preserve previous behavior
34
34
  // e.g. @nx/next:component
35
35
  derivedDirectory?: string;
36
- // Used by Next.js to determine how React should generate the page
37
- isNextPage?: boolean;
38
36
  }
39
37
 
40
38
  export interface NormalizedSchema extends Schema {
@@ -1,5 +1,5 @@
1
1
  {
2
- "$schema": "https://json-schema.org/schema",
2
+ "$schema": "http://json-schema.org/schema",
3
3
  "cli": "nx",
4
4
  "$id": "NxReactComponent",
5
5
  "title": "Create a React Component",
@@ -13,7 +13,7 @@
13
13
  "$default": {
14
14
  "$source": "projectName"
15
15
  },
16
- "x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx v19."
16
+ "x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx v18."
17
17
  },
18
18
  "name": {
19
19
  "type": "string",
@@ -40,11 +40,11 @@
40
40
  },
41
41
  {
42
42
  "value": "scss",
43
- "label": "SASS(.scss) [ https://sass-lang.com ]"
43
+ "label": "SASS(.scss) [ http://sass-lang.com ]"
44
44
  },
45
45
  {
46
46
  "value": "less",
47
- "label": "LESS [ https://lesscss.org ]"
47
+ "label": "LESS [ http://lesscss.org ]"
48
48
  },
49
49
  {
50
50
  "value": "styled-components",
@@ -91,7 +91,7 @@
91
91
  "type": "boolean",
92
92
  "description": "Create component at the source root rather than its own directory.",
93
93
  "default": false,
94
- "x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. This option will be removed in Nx v19."
94
+ "x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. This option will be removed in Nx v18."
95
95
  },
96
96
  "export": {
97
97
  "type": "boolean",
@@ -105,14 +105,14 @@
105
105
  "description": "Use pascal case component file name (e.g. `App.tsx`).",
106
106
  "alias": "P",
107
107
  "default": false,
108
- "x-deprecated": "Provide the `name` in pascal-case and use the `as-provided` format. This option will be removed in Nx v19."
108
+ "x-deprecated": "Provide the `name` in pascal-case and use the `as-provided` format. This option will be removed in Nx v18."
109
109
  },
110
110
  "pascalCaseDirectory": {
111
111
  "type": "boolean",
112
112
  "description": "Use pascal case directory name (e.g. `App/App.tsx`).",
113
113
  "alias": "R",
114
114
  "default": false,
115
- "x-deprecated": "Provide the `directory` in pascal-case and use the `as-provided` format. This option will be removed in Nx v19."
115
+ "x-deprecated": "Provide the `directory` in pascal-case and use the `as-provided` format. This option will be removed in Nx v18."
116
116
  },
117
117
  "classComponent": {
118
118
  "type": "boolean",
@@ -1,5 +1,5 @@
1
1
  {
2
- "$schema": "https://json-schema.org/schema",
2
+ "$schema": "http://json-schema.org/schema",
3
3
  "cli": "nx",
4
4
  "$id": "NxReactComponentCypressSpec",
5
5
  "title": "Create component Cypress spec",
@@ -1,5 +1,5 @@
1
1
  {
2
- "$schema": "https://json-schema.org/schema",
2
+ "$schema": "http://json-schema.org/schema",
3
3
  "cli": "nx",
4
4
  "$id": "NxReactComponentStory",
5
5
  "title": "Create component story",
@@ -1,5 +1,5 @@
1
1
  {
2
- "$schema": "https://json-schema.org/schema",
2
+ "$schema": "http://json-schema.org/schema",
3
3
  "cli": "nx",
4
4
  "$id": "NxReactCypressComponentTest",
5
5
  "title": "Add Cypress component test",
@@ -1,10 +1,9 @@
1
1
  import { Tree } from '@nx/devkit';
2
2
  import { CypressComponentConfigurationSchema } from './schema.d';
3
- export declare function cypressComponentConfigGenerator(tree: Tree, options: CypressComponentConfigurationSchema): Promise<import("@nx/devkit").GeneratorCallback>;
4
3
  /**
5
4
  * This is for using cypresses own Component testing, if you want to use test
6
5
  * storybook components then use componentCypressGenerator instead.
7
6
  *
8
7
  */
9
- export declare function cypressComponentConfigGeneratorInternal(tree: Tree, options: CypressComponentConfigurationSchema): Promise<import("@nx/devkit").GeneratorCallback>;
8
+ export declare function cypressComponentConfigGenerator(tree: Tree, options: CypressComponentConfigurationSchema): Promise<() => void>;
10
9
  export default cypressComponentConfigGenerator;
@@ -1,39 +1,26 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.cypressComponentConfigGeneratorInternal = exports.cypressComponentConfigGenerator = void 0;
3
+ exports.cypressComponentConfigGenerator = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const versions_1 = require("../../utils/versions");
6
6
  const add_files_1 = require("./lib/add-files");
7
7
  const ct_utils_1 = require("../../utils/ct-utils");
8
- function cypressComponentConfigGenerator(tree, options) {
9
- return cypressComponentConfigGeneratorInternal(tree, {
10
- addPlugin: false,
11
- ...options,
12
- });
13
- }
14
- exports.cypressComponentConfigGenerator = cypressComponentConfigGenerator;
15
8
  /**
16
9
  * This is for using cypresses own Component testing, if you want to use test
17
10
  * storybook components then use componentCypressGenerator instead.
18
11
  *
19
12
  */
20
- async function cypressComponentConfigGeneratorInternal(tree, options) {
13
+ async function cypressComponentConfigGenerator(tree, options) {
21
14
  const { componentConfigurationGenerator: baseCyCtConfig } = (0, devkit_1.ensurePackage)('@nx/cypress', versions_1.nxVersion);
22
- const nxJson = (0, devkit_1.readNxJson)(tree);
23
- const addPlugin = process.env.NX_ADD_PLUGINS !== 'false' &&
24
- nxJson.useInferencePlugins !== false;
25
- options.addPlugin ??= addPlugin;
26
15
  const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.project);
27
16
  const installTask = await baseCyCtConfig(tree, {
28
17
  project: options.project,
29
18
  skipFormat: true,
30
19
  jsx: true,
31
- addPlugin: options.addPlugin,
32
20
  });
33
- const found = await (0, ct_utils_1.configureCypressCT)(tree, {
21
+ const found = await (0, ct_utils_1.addCTTargetWithBuildTarget)(tree, {
34
22
  project: options.project,
35
23
  buildTarget: options.buildTarget,
36
- bundler: options.bundler,
37
24
  validExecutorNames: new Set([
38
25
  '@nx/webpack:webpack',
39
26
  '@nx/vite:build',
@@ -45,7 +32,9 @@ async function cypressComponentConfigGeneratorInternal(tree, options) {
45
32
  if (!options.skipFormat) {
46
33
  await (0, devkit_1.formatFiles)(tree);
47
34
  }
48
- return installTask;
35
+ return () => {
36
+ installTask();
37
+ };
49
38
  }
50
- exports.cypressComponentConfigGeneratorInternal = cypressComponentConfigGeneratorInternal;
39
+ exports.cypressComponentConfigGenerator = cypressComponentConfigGenerator;
51
40
  exports.default = cypressComponentConfigGenerator;
@@ -10,7 +10,9 @@ async function addFiles(tree, projectConfig, options, found) {
10
10
  // when importing react
11
11
  const { addMountDefinition, addDefaultCTConfig } = await Promise.resolve().then(() => require('@nx/cypress/src/utils/config'));
12
12
  // Specifically undefined to allow Remix workaround of passing an empty string
13
- const actualBundler = await (0, ct_utils_1.getActualBundler)(tree, options, found);
13
+ const actualBundler = options.buildTarget !== undefined && options.bundler
14
+ ? options.bundler
15
+ : await (0, ct_utils_1.getBundlerFromTarget)(found, tree);
14
16
  if (options.bundler && options.bundler !== actualBundler) {
15
17
  devkit_1.logger.warn(`You have specified ${options.bundler} as the bundler but this project is configured to use ${actualBundler}.
16
18
  This may cause errors. If you are seeing errors, try removing the --bundler option.`);
@@ -19,6 +21,9 @@ async function addFiles(tree, projectConfig, options, found) {
19
21
  const commandFile = (0, devkit_1.joinPathFragments)(projectConfig.root, 'cypress', 'support', 'component.ts');
20
22
  const updatedCommandFile = await addMountDefinition(tree.read(commandFile, 'utf-8'));
21
23
  tree.write(commandFile, `import { mount } from 'cypress/react18';\n${updatedCommandFile}`);
24
+ const cyFile = (0, devkit_1.joinPathFragments)(projectConfig.root, 'cypress.config.ts');
25
+ const updatedCyConfig = await addDefaultCTConfig(tree.read(cyFile, 'utf-8'), { bundler: bundlerToUse });
26
+ tree.write(cyFile, `import { nxComponentTestingPreset } from '@nx/react/plugins/component-testing';\n${updatedCyConfig}`);
22
27
  if (options.bundler === 'webpack' ||
23
28
  (!options.bundler && actualBundler === 'webpack')) {
24
29
  (0, devkit_1.addDependenciesToPackageJson)(tree, {}, { '@nx/webpack': versions_1.nxVersion });
@@ -4,5 +4,4 @@ export interface CypressComponentConfigurationSchema {
4
4
  skipFormat?: boolean;
5
5
  buildTarget?: string;
6
6
  bundler?: 'webpack' | 'vite';
7
- addPlugin?: boolean;
8
7
  }
@@ -59,10 +59,10 @@ async function federateModuleGenerator(tree, schema) {
59
59
  Now you can use the module from your host app like this:
60
60
 
61
61
  Static import:
62
- import { MyComponent } from '${remoteName}/${schema.name}';
62
+ import { MyComponent } from '${schema.name}/${remoteName}';
63
63
 
64
64
  Dynamic import:
65
- import('${remoteName}/${schema.name}').then((m) => m.${schema.name});
65
+ import('${schema.name}/${remoteName}').then((m) => m.${remoteName});
66
66
  `);
67
67
  return (0, devkit_1.runTasksInSerial)(...tasks);
68
68
  }
@@ -4,7 +4,7 @@ export interface Schema {
4
4
  remote: string;
5
5
  remoteDirectory?: string;
6
6
  projectNameAndRootFormat?: ProjectNameAndRootFormat;
7
- e2eTestRunner?: 'cypress' | 'playwright' | 'none';
7
+ e2eTestRunner?: 'cypress' | 'none';
8
8
  host?: string;
9
9
  linter?: Linter;
10
10
  skipFormat?: boolean;
@@ -1,5 +1,5 @@
1
1
  {
2
- "$schema": "https://json-schema.org/schema",
2
+ "$schema": "http://json-schema.org/schema",
3
3
  "cli": "nx",
4
4
  "$id": "NxReactFederateModule",
5
5
  "title": "Federate Module",
@@ -68,9 +68,8 @@
68
68
  },
69
69
  "e2eTestRunner": {
70
70
  "type": "string",
71
- "enum": ["cypress", "playwright", "none"],
72
- "description": "Test runner to use for end to end (E2E) tests.",
73
- "x-prompt": "Which E2E test runner would you like to use?",
71
+ "enum": ["cypress", "none"],
72
+ "description": "Test runner to use for end to end (e2e) tests.",
74
73
  "default": "cypress"
75
74
  },
76
75
  "host": {
@@ -1,15 +1,15 @@
1
- import { useState, useCallback } from 'react'
2
-
3
- // eslint-disable-next-line @typescript-eslint/no-empty-interface
4
- export interface <%= hookTypeName %> {
5
- count: number;
6
- increment: () => void;
7
- }
8
-
9
- export function <%= hookName %>(): <%= hookTypeName %> {
10
- const [count, setCount] = useState(0)
11
- const increment = useCallback(() => setCount((x) => x + 1), [])
12
- return { count, increment }
13
- }
14
-
15
- export default <%= hookName %>;
1
+ import { useState, useCallback } from 'react'
2
+
3
+ // eslint-disable-next-line @typescript-eslint/no-empty-interface
4
+ export interface <%= hookTypeName %> {
5
+ count: number;
6
+ increment: () => void;
7
+ }
8
+
9
+ export function <%= hookName %>(): <%= hookTypeName %> {
10
+ const [count, setCount] = useState(0)
11
+ const increment = useCallback(() => setCount((x) => x + 1), [])
12
+ return { count, increment }
13
+ };
14
+
15
+ export default <%= hookName %>;
@@ -1,22 +1,22 @@
1
1
  export interface Schema {
2
2
  name: string;
3
3
  /**
4
- * @deprecated Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx v19.
4
+ * @deprecated Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx v18.
5
5
  */
6
6
  project: string;
7
7
  skipTests?: boolean;
8
8
  directory?: string;
9
9
  export?: boolean;
10
10
  /**
11
- * @deprecated Provide the `name` option instead and use the `as-provided` format. This option will be removed in Nx v19.
11
+ * @deprecated Provide the `name` option instead and use the `as-provided` format. This option will be removed in Nx v18.
12
12
  */
13
13
  pascalCaseFiles?: boolean;
14
14
  /**
15
- * @deprecated Provide the `directory` option instead and use the `as-provided` format. This option will be removed in Nx v19.
15
+ * @deprecated Provide the `directory` option instead and use the `as-provided` format. This option will be removed in Nx v18.
16
16
  */
17
17
  pascalCaseDirectory?: boolean;
18
18
  /**
19
- * @deprecated Provide the `directory` option instead and use the `as-provided` format. This option will be removed in Nx v19.
19
+ * @deprecated Provide the `directory` option instead and use the `as-provided` format. This option will be removed in Nx v18.
20
20
  */
21
21
  flat?: boolean;
22
22
  js?: boolean;
@@ -1,5 +1,5 @@
1
1
  {
2
- "$schema": "https://json-schema.org/schema",
2
+ "$schema": "http://json-schema.org/schema",
3
3
  "cli": "nx",
4
4
  "$id": "NxReactHook",
5
5
  "title": "Create a React Hook for Nx",
@@ -19,7 +19,7 @@
19
19
  "$default": {
20
20
  "$source": "projectName"
21
21
  },
22
- "x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx v19."
22
+ "x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx v18."
23
23
  },
24
24
  "name": {
25
25
  "type": "string",
@@ -56,7 +56,7 @@
56
56
  "type": "boolean",
57
57
  "description": "Create hook at the source root rather than its own directory.",
58
58
  "default": false,
59
- "x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v19."
59
+ "x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v18."
60
60
  },
61
61
  "export": {
62
62
  "type": "boolean",
@@ -70,14 +70,14 @@
70
70
  "description": "Use pascal case hook file name (e.g. `useHook.ts`).",
71
71
  "alias": "P",
72
72
  "default": false,
73
- "x-deprecated": "Provide the `name` in pascal-case and use the `as-provided` format. This option will be removed in Nx v19."
73
+ "x-deprecated": "Provide the `name` in pascal-case and use the `as-provided` format. This option will be removed in Nx v18."
74
74
  },
75
75
  "pascalCaseDirectory": {
76
76
  "type": "boolean",
77
77
  "description": "Use pascal case directory name (e.g. `useHook/useHook.ts`).",
78
78
  "alias": "R",
79
79
  "default": false,
80
- "x-deprecated": "Provide the `directory` in pascal-case and use the `as-provided` format. This option will be removed in Nx v19."
80
+ "x-deprecated": "Provide the `directory` in pascal-case and use the `as-provided` format. This option will be removed in Nx v18."
81
81
  }
82
82
  },
83
83
  "required": ["name"]
@@ -1,21 +1,6 @@
1
1
  module.exports = {
2
2
  name: '<%= projectName %>',
3
- /**
4
- * To use a remote that does not exist in your current Nx Workspace
5
- * You can use the tuple-syntax to define your remote
6
- *
7
- * remotes: [['my-external-remote', 'https://nx-angular-remote.netlify.app']]
8
- *
9
- * You _may_ need to add a `remotes.d.ts` file to your `src/` folder declaring the external remote for tsc, with the
10
- * following content:
11
- *
12
- * declare module 'my-external-remote';
13
- *
14
- */
15
3
  remotes: [
16
- <% if (static) {
17
- remotes.forEach(function(r) { %> "<%= r.fileName %>", <% });
18
- }
19
- %>
4
+ <% remotes.forEach(function(r) {%> "<%= r.fileName %>", <% }); %>
20
5
  ],
21
- };
6
+ };
@@ -0,0 +1 @@
1
+ import('./bootstrap');
@@ -6,11 +6,8 @@
6
6
  const moduleFederationConfig = {
7
7
  name: '<%= projectName %>',
8
8
  remotes: [
9
- <% if (static) {
10
- remotes.forEach(function(r) { %> "<%= r.fileName %>", <% });
11
- }
12
- %>
13
- ],
9
+ <% remotes.forEach(function(r) {%> "<%= r.fileName %>", <% }); %>
10
+ ],
14
11
  };
15
12
 
16
13
  module.exports = moduleFederationConfig;
@@ -3,11 +3,8 @@ import { ModuleFederationConfig } from '@nx/webpack';
3
3
  const config: ModuleFederationConfig = {
4
4
  name: '<%= projectName %>',
5
5
  remotes: [
6
- <% if (static) {
7
- remotes.forEach(function(r) { %> "<%= r.fileName %>", <% });
8
- }
9
- %>
10
- ],
6
+ <% remotes.forEach(function(r) {%> "<%= r.fileName %>", <% }); %>
7
+ ],
11
8
  };
12
9
 
13
10
  export default config;
@@ -2,24 +2,9 @@ import { ModuleFederationConfig } from '@nx/webpack';
2
2
 
3
3
  const config: ModuleFederationConfig = {
4
4
  name: '<%= projectName %>',
5
- /**
6
- * To use a remote that does not exist in your current Nx Workspace
7
- * You can use the tuple-syntax to define your remote
8
- *
9
- * remotes: [['my-external-remote', 'https://nx-angular-remote.netlify.app']]
10
- *
11
- * You _may_ need to add a `remotes.d.ts` file to your `src/` folder declaring the external remote for tsc, with the
12
- * following content:
13
- *
14
- * declare module 'my-external-remote';
15
- *
16
- */
17
5
  remotes: [
18
- <% if (static) {
19
- remotes.forEach(function(r) { %> "<%= r.fileName %>", <% });
20
- }
21
- %>
22
- ],
6
+ <% remotes.forEach(function(r) {%> "<%= r.fileName %>", <% }); %>
7
+ ],
23
8
  };
24
9
 
25
10
  export default config;
@@ -0,0 +1 @@
1
+ import('./bootstrap');
@@ -1,11 +1,10 @@
1
1
  import { composePlugins, withNx } from '@nx/webpack';
2
2
  import { withReact } from '@nx/react';
3
3
  import { withModuleFederation } from '@nx/react/module-federation';
4
- import { ModuleFederationConfig } from '@nx/webpack';
5
4
 
6
5
  import baseConfig from './module-federation.config';
7
6
 
8
- const prodConfig: ModuleFederationConfig = {
7
+ const prodConfig = {
9
8
  ...baseConfig,
10
9
  /*
11
10
  * Remote overrides for production.
@@ -1,10 +1,10 @@
1
- import {composePlugins, withNx, ModuleFederationConfig} from '@nx/webpack';
1
+ import {composePlugins, withNx} from '@nx/webpack';
2
2
  import {withReact} from '@nx/react';
3
3
  import {withModuleFederation} from '@nx/react/module-federation';
4
4
 
5
5
  import baseConfig from './module-federation.config';
6
6
 
7
- const config: ModuleFederationConfig = {
7
+ const config = {
8
8
  ...baseConfig,
9
9
  };
10
10
 
@@ -11,7 +11,6 @@ const add_module_federation_files_1 = require("./lib/add-module-federation-files
11
11
  const normalize_remote_1 = require("./lib/normalize-remote");
12
12
  const setup_ssr_for_host_1 = require("./lib/setup-ssr-for-host");
13
13
  const update_module_federation_e2e_project_1 = require("./lib/update-module-federation-e2e-project");
14
- const add_mf_env_to_inputs_1 = require("../../utils/add-mf-env-to-inputs");
15
14
  async function hostGenerator(host, schema) {
16
15
  return hostGeneratorInternal(host, {
17
16
  projectNameAndRootFormat: 'derived',
@@ -23,13 +22,7 @@ async function hostGeneratorInternal(host, schema) {
23
22
  const tasks = [];
24
23
  const options = {
25
24
  ...(await (0, normalize_options_1.normalizeOptions)(host, schema, '@nx/react:host')),
26
- js: schema.js ?? false,
27
- typescriptConfiguration: schema.js
28
- ? false
29
- : schema.typescriptConfiguration ?? true,
30
- dynamic: schema.dynamic ?? false,
31
- // TODO(colum): remove when MF works with Crystal
32
- addPlugin: false,
25
+ typescriptConfiguration: schema.typescriptConfiguration ?? true,
33
26
  };
34
27
  const initTask = await (0, application_1.default)(host, {
35
28
  ...options,
@@ -58,9 +51,6 @@ async function hostGeneratorInternal(host, schema) {
58
51
  skipFormat: true,
59
52
  projectNameAndRootFormat: options.projectNameAndRootFormat,
60
53
  typescriptConfiguration: options.typescriptConfiguration,
61
- js: options.js,
62
- dynamic: options.dynamic,
63
- host: options.name,
64
54
  });
65
55
  tasks.push(remoteTask);
66
56
  remotePort++;
@@ -82,10 +72,6 @@ async function hostGeneratorInternal(host, schema) {
82
72
  projectConfig.targets.server.options.webpackConfig = (0, devkit_1.joinPathFragments)(projectConfig.root, `webpack.server.config.${options.typescriptConfiguration ? 'ts' : 'js'}`);
83
73
  (0, devkit_1.updateProjectConfiguration)(host, options.projectName, projectConfig);
84
74
  }
85
- if (!options.setParserOptionsProject) {
86
- host.delete((0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.lint.json'));
87
- }
88
- (0, add_mf_env_to_inputs_1.addMfEnvToTargetDefaultInputs)(host);
89
75
  if (!options.skipFormat) {
90
76
  await (0, devkit_1.formatFiles)(host);
91
77
  }
@@ -1,6 +1,5 @@
1
- import { Tree } from '@nx/devkit';
2
1
  import { NormalizedSchema } from '../schema';
3
- export declare function addModuleFederationFiles(host: Tree, options: NormalizedSchema, defaultRemoteManifest: {
2
+ export declare function addModuleFederationFiles(host: any, options: NormalizedSchema, defaultRemoteManifest: {
4
3
  name: string;
5
4
  port: number;
6
5
  }[]): void;
@@ -2,12 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.addModuleFederationFiles = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
- const maybe_js_1 = require("../../../utils/maybe-js");
5
+ const path_1 = require("path");
6
6
  function addModuleFederationFiles(host, options, defaultRemoteManifest) {
7
7
  const templateVariables = {
8
8
  ...(0, devkit_1.names)(options.name),
9
9
  ...options,
10
- static: !options?.dynamic,
11
10
  tmpl: '',
12
11
  remotes: defaultRemoteManifest.map(({ name, port }) => {
13
12
  return {
@@ -16,36 +15,24 @@ function addModuleFederationFiles(host, options, defaultRemoteManifest) {
16
15
  };
17
16
  }),
18
17
  };
19
- const projectConfig = (0, devkit_1.readProjectConfiguration)(host, options.name);
20
- const pathToMFManifest = (0, devkit_1.joinPathFragments)(projectConfig.sourceRoot, 'assets/module-federation.manifest.json');
21
18
  // Module federation requires bootstrap code to be dynamically imported.
22
19
  // Renaming original entry file so we can use `import(./bootstrap)` in
23
20
  // new entry file.
24
- host.rename((0, devkit_1.joinPathFragments)(options.appProjectRoot, (0, maybe_js_1.maybeJs)(options, 'src/main.tsx')), (0, devkit_1.joinPathFragments)(options.appProjectRoot, (0, maybe_js_1.maybeJs)(options, 'src/bootstrap.tsx')));
25
- (0, devkit_1.generateFiles)(host, (0, devkit_1.joinPathFragments)(__dirname, `../files/${options.js ? 'common' : 'common-ts'}`), options.appProjectRoot, templateVariables);
21
+ host.rename((0, path_1.join)(options.appProjectRoot, 'src/main.tsx'), (0, path_1.join)(options.appProjectRoot, 'src/bootstrap.tsx'));
22
+ (0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, `../files/common`), options.appProjectRoot, templateVariables);
26
23
  const pathToModuleFederationFiles = options.typescriptConfiguration
27
24
  ? 'module-federation-ts'
28
25
  : 'module-federation';
29
26
  // New entry file is created here.
30
- (0, devkit_1.generateFiles)(host, (0, devkit_1.joinPathFragments)(__dirname, `../files/${pathToModuleFederationFiles}`), options.appProjectRoot, templateVariables);
31
- function deleteFileIfExists(host, filePath) {
32
- if (host.exists(filePath)) {
33
- host.delete(filePath);
34
- }
35
- }
36
- function processWebpackConfig(options, host, fileName) {
37
- const pathToWebpackConfig = (0, devkit_1.joinPathFragments)(options.appProjectRoot, fileName);
38
- deleteFileIfExists(host, pathToWebpackConfig);
39
- }
27
+ (0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, `../files/${pathToModuleFederationFiles}`), options.appProjectRoot, templateVariables);
40
28
  if (options.typescriptConfiguration) {
41
- processWebpackConfig(options, host, 'webpack.config.js');
42
- processWebpackConfig(options, host, 'webpack.config.prod.js');
43
- }
44
- if (options.dynamic) {
45
- processWebpackConfig(options, host, 'webpack.config.prod.js');
46
- processWebpackConfig(options, host, 'webpack.config.prod.ts');
47
- if (!host.exists(pathToMFManifest)) {
48
- host.write(pathToMFManifest, '{}');
29
+ const pathToWebpackConfig = (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'webpack.config.js');
30
+ const pathToWebpackProdConfig = (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'webpack.config.prod.js');
31
+ if (host.exists(pathToWebpackConfig)) {
32
+ host.delete(pathToWebpackConfig);
33
+ }
34
+ if (host.exists(pathToWebpackProdConfig)) {
35
+ host.delete(pathToWebpackProdConfig);
49
36
  }
50
37
  }
51
38
  }
@@ -13,7 +13,6 @@ async function setupSsrForHost(tree, options, appName, defaultRemoteManifest) {
13
13
  : 'module-federation-ssr';
14
14
  (0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, `../files/${pathToModuleFederationSsrFiles}`), project.root, {
15
15
  ...options,
16
- static: !options?.dynamic,
17
16
  remotes: defaultRemoteManifest.map(({ name, port }) => {
18
17
  return {
19
18
  ...(0, devkit_1.names)(name),