@nx/react 17.0.4 → 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 -12
  17. package/src/executors/module-federation-dev-server/module-federation-dev-server.impl.js +51 -149
  18. package/src/executors/module-federation-dev-server/schema.json +1 -9
  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
@@ -2,7 +2,6 @@ export type SupportedStyles =
2
2
  | 'css'
3
3
  | 'scss'
4
4
  | 'less'
5
- | 'tailwind'
6
5
  | 'styled-components'
7
6
  | '@emotion/styled'
8
7
  | 'styled-jsx'
@@ -1,4 +0,0 @@
1
- export type ResolveRemoteUrlFunction = (remoteName: string) => string | Promise<string>;
2
- export declare function setRemoteUrlResolver(_resolveRemoteUrl: ResolveRemoteUrlFunction): void;
3
- export declare function setRemoteDefinitions(definitions: Record<string, string>): void;
4
- export declare function loadRemoteModule(remoteName: string, moduleName: string): Promise<any>;
@@ -1,75 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.loadRemoteModule = exports.setRemoteDefinitions = exports.setRemoteUrlResolver = void 0;
4
- let remoteUrlDefinitions;
5
- let resolveRemoteUrl;
6
- const remoteModuleMap = new Map();
7
- const remoteContainerMap = new Map();
8
- let initialSharingScopeCreated = false;
9
- function setRemoteUrlResolver(_resolveRemoteUrl) {
10
- resolveRemoteUrl = _resolveRemoteUrl;
11
- }
12
- exports.setRemoteUrlResolver = setRemoteUrlResolver;
13
- function setRemoteDefinitions(definitions) {
14
- remoteUrlDefinitions = definitions;
15
- }
16
- exports.setRemoteDefinitions = setRemoteDefinitions;
17
- async function loadRemoteModule(remoteName, moduleName) {
18
- const remoteModuleKey = `${remoteName}:${moduleName}`;
19
- if (remoteModuleMap.has(remoteModuleKey)) {
20
- return remoteModuleMap.get(remoteModuleKey);
21
- }
22
- const container = remoteContainerMap.has(remoteName)
23
- ? remoteContainerMap.get(remoteName)
24
- : await loadRemoteContainer(remoteName);
25
- const factory = await container.get(moduleName);
26
- const Module = factory();
27
- remoteModuleMap.set(remoteModuleKey, Module);
28
- return Module;
29
- }
30
- exports.loadRemoteModule = loadRemoteModule;
31
- const fetchRemoteModule = (url, remoteName) => {
32
- return new Promise((resolve, reject) => {
33
- const script = document.createElement('script');
34
- script.src = url;
35
- script.type = 'text/javascript';
36
- script.async = true;
37
- script.onload = () => {
38
- const proxy = {
39
- get: (request) => window[remoteName].get(request),
40
- init: (arg) => {
41
- try {
42
- window[remoteName].init(arg);
43
- }
44
- catch (e) {
45
- console.error(`Failed to initialize remote ${remoteName}`, e);
46
- reject(e);
47
- }
48
- },
49
- };
50
- resolve(proxy);
51
- };
52
- script.onerror = () => reject(new Error(`Remote ${remoteName} not found`));
53
- document.head.appendChild(script);
54
- });
55
- };
56
- async function loadRemoteContainer(remoteName) {
57
- if (!resolveRemoteUrl && !remoteUrlDefinitions) {
58
- throw new Error('Call setRemoteDefinitions or setRemoteUrlResolver to allow Dynamic Federation to find the remote apps correctly.');
59
- }
60
- if (!initialSharingScopeCreated) {
61
- initialSharingScopeCreated = true;
62
- await __webpack_init_sharing__('default');
63
- }
64
- const remoteUrl = remoteUrlDefinitions
65
- ? remoteUrlDefinitions[remoteName]
66
- : await resolveRemoteUrl(remoteName);
67
- let containerUrl = remoteUrl;
68
- if (!remoteUrl.endsWith('.mjs') && !remoteUrl.endsWith('.js')) {
69
- containerUrl = `${remoteUrl}${remoteUrl.endsWith('/') ? '' : '/'}remoteEntry.js`;
70
- }
71
- const container = await fetchRemoteModule(containerUrl, remoteName);
72
- await container.init(__webpack_share_scopes__.default);
73
- remoteContainerMap.set(remoteName, container);
74
- return container;
75
- }
package/mf/index.d.ts DELETED
@@ -1 +0,0 @@
1
- export { loadRemoteModule, setRemoteDefinitions, setRemoteUrlResolver, } from './dynamic-federation';
package/mf/index.js DELETED
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.setRemoteUrlResolver = exports.setRemoteDefinitions = exports.loadRemoteModule = void 0;
4
- var dynamic_federation_1 = require("./dynamic-federation");
5
- Object.defineProperty(exports, "loadRemoteModule", { enumerable: true, get: function () { return dynamic_federation_1.loadRemoteModule; } });
6
- Object.defineProperty(exports, "setRemoteDefinitions", { enumerable: true, get: function () { return dynamic_federation_1.setRemoteDefinitions; } });
7
- Object.defineProperty(exports, "setRemoteUrlResolver", { enumerable: true, get: function () { return dynamic_federation_1.setRemoteUrlResolver; } });
@@ -1,4 +0,0 @@
1
- import { Configuration, WebpackOptionsNormalized } from 'webpack';
2
- export declare function applyReactConfig(options: {
3
- svgr?: boolean;
4
- }, config?: Partial<WebpackOptionsNormalized | Configuration>): void;
@@ -1,86 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.applyReactConfig = void 0;
4
- function applyReactConfig(options, config = {}) {
5
- if (!process.env['NX_TASK_TARGET_PROJECT'])
6
- return;
7
- addHotReload(config);
8
- if (options.svgr !== false) {
9
- removeSvgLoaderIfPresent(config);
10
- // TODO(v20): Remove file-loader and use `?react` querystring to differentiate between asset and SVGR.
11
- // It should be:
12
- // use: [{
13
- // test: /\.svg$/i,
14
- // type: 'asset',
15
- // resourceQuery: /react/, // *.svg?react
16
- // },
17
- // {
18
- // test: /\.svg$/i,
19
- // issuer: /\.[jt]sx?$/,
20
- // resourceQuery: { not: [/react/] }, // exclude react component if *.svg?react
21
- // use: ['@svgr/webpack'],
22
- // }],
23
- // See:
24
- // - SVGR: https://react-svgr.com/docs/webpack/#use-svgr-and-asset-svg-in-the-same-project
25
- // - Vite: https://www.npmjs.com/package/vite-plugin-svgr
26
- // - Rsbuild: https://github.com/web-infra-dev/rsbuild/pull/1783
27
- // Note: We also need a migration for any projects that are using SVGR to convert
28
- // `import { ReactComponent as X } from './x.svg` to
29
- // `import X from './x.svg?react';
30
- config.module.rules.push({
31
- test: /\.svg$/,
32
- issuer: /\.(js|ts|md)x?$/,
33
- use: [
34
- {
35
- loader: require.resolve('@svgr/webpack'),
36
- options: {
37
- svgo: false,
38
- titleProp: true,
39
- ref: true,
40
- },
41
- },
42
- {
43
- loader: require.resolve('file-loader'),
44
- options: {
45
- name: '[name].[hash].[ext]',
46
- },
47
- },
48
- ],
49
- });
50
- }
51
- // enable webpack node api
52
- config.node = {
53
- __dirname: true,
54
- __filename: true,
55
- };
56
- }
57
- exports.applyReactConfig = applyReactConfig;
58
- function addHotReload(config) {
59
- if (config.mode === 'development' && config['devServer']?.hot) {
60
- // add `react-refresh/babel` to babel loader plugin
61
- const babelLoader = config.module.rules.find((rule) => rule &&
62
- typeof rule !== 'string' &&
63
- rule.loader?.toString().includes('babel-loader'));
64
- if (babelLoader && typeof babelLoader !== 'string') {
65
- babelLoader.options['plugins'] = [
66
- ...(babelLoader.options['plugins'] || []),
67
- [
68
- require.resolve('react-refresh/babel'),
69
- {
70
- skipEnvCheck: true,
71
- },
72
- ],
73
- ];
74
- }
75
- const ReactRefreshPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
76
- config.plugins.push(new ReactRefreshPlugin());
77
- }
78
- }
79
- // We remove potentially conflicting rules that target SVGs because we use @svgr/webpack loader
80
- // See https://github.com/nrwl/nx/issues/14383
81
- function removeSvgLoaderIfPresent(config) {
82
- const svgLoaderIdx = config.module.rules.findIndex((rule) => typeof rule === 'object' && rule.test.toString().includes('svg'));
83
- if (svgLoaderIdx === -1)
84
- return;
85
- config.module.rules.splice(svgLoaderIdx, 1);
86
- }
@@ -1,8 +0,0 @@
1
- import { Compiler } from 'webpack';
2
- export declare class NxReactWebpackPlugin {
3
- private options;
4
- constructor(options?: {
5
- svgr?: boolean;
6
- });
7
- apply(compiler: Compiler): void;
8
- }
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NxReactWebpackPlugin = void 0;
4
- const apply_react_config_1 = require("./lib/apply-react-config");
5
- class NxReactWebpackPlugin {
6
- constructor(options = {}) {
7
- this.options = options;
8
- }
9
- apply(compiler) {
10
- (0, apply_react_config_1.applyReactConfig)(this.options, compiler.options);
11
- }
12
- }
13
- exports.NxReactWebpackPlugin = NxReactWebpackPlugin;
@@ -1,33 +0,0 @@
1
- <% if (classComponent) { %>
2
- import { Component } from 'react';
3
- <% } if (!minimal) { %>
4
- import NxWelcome from "./nx-welcome";
5
- <% } %>
6
-
7
- <% if (classComponent) { %>
8
- export class App extends Component {
9
- render() {
10
- <% } else { %>
11
- export function App() {
12
- <% } %>
13
- return (
14
- <div>
15
- <% if (!minimal) { %>
16
- <NxWelcome title="<%= projectName %>"/>
17
- <% } else { %>
18
- <h1>
19
- <span> Hello there, </span>
20
- Welcome <%= projectName %> 👋
21
- </h1>
22
- <% } %>
23
- </div>);
24
- <% if (classComponent) { %>
25
- }
26
- }
27
- <% } else { %>
28
- }
29
- <% } %>
30
-
31
- export default App;
32
-
33
- <% if (inSourceTests === true) { %> <%- inSourceVitestTests %> <% } %>
@@ -1 +0,0 @@
1
- /* You can add global styles to this file, and also import other style files */
@@ -1,10 +0,0 @@
1
- <% if (dynamic) { %>
2
- import { setRemoteDefinitions } from '@nx/react/mf';
3
-
4
- fetch('/assets/module-federation.manifest.json')
5
- .then((res) => res.json())
6
- .then(definitions => setRemoteDefinitions(definitions))
7
- .then(() => import('./bootstrap').catch(err => console.error(err)));
8
- <% } else { %>
9
- import('./bootstrap').catch(err => console.error(err));
10
- <% } %>
@@ -1,19 +0,0 @@
1
- {
2
- "extends": "./tsconfig.json",
3
- "compilerOptions": {
4
- "outDir": "../../dist/out-tsc",
5
- "types": [
6
- "node",
7
- "@nx/react/typings/cssmodule.d.ts",
8
- "@nx/react/typings/image.d.ts"
9
- ]
10
- },
11
- "include": [
12
- "src/**/*.js",
13
- "src/**/*.jsx",
14
- "src/**/*.ts",
15
- "src/**/*.tsx",
16
- "webpack.config.ts",
17
- "webpack.prod.config.ts"
18
- ]
19
- }
@@ -1,41 +0,0 @@
1
- import * as React from 'react';
2
- <% if (!minimal) { %>
3
- import NxWelcome from "./nx-welcome";
4
- <% } %>
5
- import { Link, Route, Routes } from 'react-router-dom';
6
- <% if (dynamic) { %>
7
- import { loadRemoteModule } from '@nx/react/mf';
8
- <% } %>
9
-
10
- <% if (remotes.length > 0) { %>
11
- <% remotes.forEach(function(r) { %>
12
- <% if (dynamic) { %>
13
- const <%= r.className %> = React.lazy(() => loadRemoteModule('<%= r.fileName %>', './Module'))
14
- <% } else { %>
15
- const <%= r.className %> = React.lazy(() => import('<%= r.fileName %>/Module'));
16
- <% } %>
17
- <% }); %>
18
- <% } %>
19
-
20
- export function App() {
21
- return (
22
- <React.Suspense fallback={null}>
23
- <ul>
24
- <li><Link to="/">Home</Link></li>
25
- <% remotes.forEach(function(r) { %>
26
- <li><Link to="/<%=r.fileName%>"><%=r.className%></Link></li>
27
- <% }); %>
28
- </ul>
29
- <Routes>
30
- <% if (!minimal) { %>
31
- <Route path="/" element={<NxWelcome title="<%= projectName %>"/>} />
32
- <% } %>
33
- <% remotes.forEach(function(r) { %>
34
- <Route path="/<%=r.fileName%>" element={<<%= r.className %>/>} />
35
- <% }); %>
36
- </Routes>
37
- </React.Suspense>
38
- );
39
- }
40
-
41
- export default App;
@@ -1,10 +0,0 @@
1
- <% if (dynamic) { %>
2
- import { setRemoteDefinitions } from '@nx/react/mf';
3
-
4
- fetch('/assets/module-federation.manifest.json')
5
- .then((res) => res.json())
6
- .then(definitions => setRemoteDefinitions(definitions))
7
- .then(() => import('./bootstrap').catch(err => console.error(err)));
8
- <% } else { %>
9
- import('./bootstrap').catch(err => console.error(err));
10
- <% } %>
@@ -1,19 +0,0 @@
1
- {
2
- "extends": "./tsconfig.json",
3
- "compilerOptions": {
4
- "outDir": "../../dist/out-tsc",
5
- "types": [
6
- "node",
7
- "@nx/react/typings/cssmodule.d.ts",
8
- "@nx/react/typings/image.d.ts"
9
- ]
10
- },
11
- "include": [
12
- "src/**/*.js",
13
- "src/**/*.jsx",
14
- "src/**/*.ts",
15
- "src/**/*.tsx",
16
- "webpack.config.ts",
17
- "webpack.prod.config.ts"
18
- ]
19
- }
@@ -1,19 +0,0 @@
1
- {
2
- "extends": "./tsconfig.json",
3
- "compilerOptions": {
4
- "outDir": "../../dist/out-tsc",
5
- "types": [
6
- "node",
7
- "@nx/react/typings/cssmodule.d.ts",
8
- "@nx/react/typings/image.d.ts"
9
- ]
10
- },
11
- "include": [
12
- "src/**/*.js",
13
- "src/**/*.jsx",
14
- "src/**/*.ts",
15
- "src/**/*.tsx",
16
- "webpack.config.ts",
17
- "webpack.prod.config.ts"
18
- ]
19
- }
@@ -1,2 +0,0 @@
1
- import { Tree } from '@nx/devkit';
2
- export declare function addRemoteToDynamicHost(tree: Tree, remoteName: string, remotePort: number, pathToMfManifest: string): void;
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.addRemoteToDynamicHost = void 0;
4
- function addRemoteToDynamicHost(tree, remoteName, remotePort, pathToMfManifest) {
5
- const current = tree.read(pathToMfManifest, 'utf8');
6
- tree.write(pathToMfManifest, JSON.stringify({
7
- ...JSON.parse(current),
8
- [remoteName]: `http://localhost:${remotePort}`,
9
- }));
10
- }
11
- exports.addRemoteToDynamicHost = addRemoteToDynamicHost;
@@ -1,2 +0,0 @@
1
- import { type Tree } from '@nx/devkit';
2
- export default function (tree: Tree): Promise<void>;
@@ -1,26 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const devkit_1 = require("@nx/devkit");
4
- const add_mf_env_to_inputs_1 = require("../../utils/add-mf-env-to-inputs");
5
- async function default_1(tree) {
6
- if (!hasModuleFederationProject(tree)) {
7
- return;
8
- }
9
- (0, add_mf_env_to_inputs_1.addMfEnvToTargetDefaultInputs)(tree);
10
- await (0, devkit_1.formatFiles)(tree);
11
- }
12
- exports.default = default_1;
13
- function hasModuleFederationProject(tree) {
14
- const projects = (0, devkit_1.getProjects)(tree);
15
- for (const project of projects.values()) {
16
- const targets = project.targets || {};
17
- for (const [_, target] of Object.entries(targets)) {
18
- if (target.executor === '@nx/webpack:webpack' &&
19
- (tree.exists((0, devkit_1.joinPathFragments)(project.root, 'module-federation.config.ts')) ||
20
- tree.exists((0, devkit_1.joinPathFragments)(project.root, 'module-federation.config.js')))) {
21
- return true;
22
- }
23
- }
24
- }
25
- return false;
26
- }
@@ -1,2 +0,0 @@
1
- import { type Tree } from '@nx/devkit';
2
- export default function (tree: Tree): Promise<void>;
@@ -1,53 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const devkit_1 = require("@nx/devkit");
4
- async function default_1(tree) {
5
- if (!hasModuleFederationProject(tree)) {
6
- return;
7
- }
8
- ensureTargetDefaultsContainProductionInputs(tree);
9
- await (0, devkit_1.formatFiles)(tree);
10
- }
11
- exports.default = default_1;
12
- function ensureTargetDefaultsContainProductionInputs(tree) {
13
- const nxJson = (0, devkit_1.readNxJson)(tree);
14
- const webpackExecutor = '@nx/webpack:webpack';
15
- const mfEnvVar = 'NX_MF_DEV_SERVER_STATIC_REMOTES';
16
- nxJson.targetDefaults[webpackExecutor] ??= {};
17
- nxJson.targetDefaults[webpackExecutor].inputs ??= [
18
- 'production',
19
- '^production',
20
- { env: mfEnvVar },
21
- ];
22
- if (!nxJson.targetDefaults[webpackExecutor].inputs.includes('production')) {
23
- nxJson.targetDefaults[webpackExecutor].inputs.push('production');
24
- }
25
- if (!nxJson.targetDefaults[webpackExecutor].inputs.includes('^production')) {
26
- nxJson.targetDefaults[webpackExecutor].inputs.push('^production');
27
- }
28
- let mfEnvVarExists = false;
29
- for (const input of nxJson.targetDefaults[webpackExecutor].inputs) {
30
- if (typeof input === 'object' && input['env'] === mfEnvVar) {
31
- mfEnvVarExists = true;
32
- break;
33
- }
34
- }
35
- if (!mfEnvVarExists) {
36
- nxJson.targetDefaults[webpackExecutor].inputs.push({ env: mfEnvVar });
37
- }
38
- (0, devkit_1.updateNxJson)(tree, nxJson);
39
- }
40
- function hasModuleFederationProject(tree) {
41
- const projects = (0, devkit_1.getProjects)(tree);
42
- for (const project of projects.values()) {
43
- const targets = project.targets || {};
44
- for (const [_, target] of Object.entries(targets)) {
45
- if (target.executor === '@nx/webpack:webpack' &&
46
- (tree.exists((0, devkit_1.joinPathFragments)(project.root, 'module-federation.config.ts')) ||
47
- tree.exists((0, devkit_1.joinPathFragments)(project.root, 'module-federation.config.js')))) {
48
- return true;
49
- }
50
- }
51
- }
52
- return false;
53
- }
@@ -1,2 +0,0 @@
1
- import { type Tree } from '@nx/devkit';
2
- export declare function addMfEnvToTargetDefaultInputs(tree: Tree): void;
@@ -1,27 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.addMfEnvToTargetDefaultInputs = void 0;
4
- const devkit_1 = require("@nx/devkit");
5
- function addMfEnvToTargetDefaultInputs(tree) {
6
- const nxJson = (0, devkit_1.readNxJson)(tree);
7
- const webpackExecutor = '@nx/webpack:webpack';
8
- const mfEnvVar = 'NX_MF_DEV_SERVER_STATIC_REMOTES';
9
- nxJson.targetDefaults ??= {};
10
- nxJson.targetDefaults[webpackExecutor] ??= {};
11
- nxJson.targetDefaults[webpackExecutor].inputs ??= [
12
- 'production',
13
- '^production',
14
- ];
15
- let mfEnvVarExists = false;
16
- for (const input of nxJson.targetDefaults[webpackExecutor].inputs) {
17
- if (typeof input === 'object' && input['env'] === mfEnvVar) {
18
- mfEnvVarExists = true;
19
- break;
20
- }
21
- }
22
- if (!mfEnvVarExists) {
23
- nxJson.targetDefaults[webpackExecutor].inputs.push({ env: mfEnvVar });
24
- (0, devkit_1.updateNxJson)(tree, nxJson);
25
- }
26
- }
27
- exports.addMfEnvToTargetDefaultInputs = addMfEnvToTargetDefaultInputs;
@@ -1,2 +0,0 @@
1
- import { Tree } from '@nx/devkit';
2
- export declare function hasVitePlugin(tree: Tree): boolean;
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.hasVitePlugin = void 0;
4
- const devkit_1 = require("@nx/devkit");
5
- function hasVitePlugin(tree) {
6
- const nxJson = (0, devkit_1.readNxJson)(tree);
7
- return !!nxJson.plugins?.some((p) => typeof p === 'string'
8
- ? p === '@nx/vite/plugin'
9
- : p.plugin === '@nx/vite/plugin');
10
- }
11
- exports.hasVitePlugin = hasVitePlugin;
@@ -1,2 +0,0 @@
1
- import { Tree } from '@nx/devkit';
2
- export declare function hasWebpackPlugin(tree: Tree): boolean;
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.hasWebpackPlugin = void 0;
4
- const devkit_1 = require("@nx/devkit");
5
- function hasWebpackPlugin(tree) {
6
- const nxJson = (0, devkit_1.readNxJson)(tree);
7
- return !!nxJson.plugins?.some((p) => typeof p === 'string'
8
- ? p === '@nx/webpack/plugin'
9
- : p.plugin === '@nx/webpack/plugin');
10
- }
11
- exports.hasWebpackPlugin = hasWebpackPlugin;
@@ -1,3 +0,0 @@
1
- export declare function maybeJs(options: {
2
- js?: boolean;
3
- }, path: string): string;