@nx/react 20.1.0-canary.20241030-62f58eb → 20.1.0-canary.20241101-d4f4dac
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.
- package/package.json +5 -5
- package/src/generators/application/files/base-rspack/src/app/__fileName__.spec.tsx__tmpl__ +3 -3
- package/src/generators/application/files/base-rspack/src/main.tsx__tmpl__ +24 -4
- package/src/generators/application/files/base-rspack/tsconfig.app.json__tmpl__ +1 -1
- package/src/generators/application/files/base-vite/src/app/__fileName__.spec.tsx__tmpl__ +3 -3
- package/src/generators/application/files/base-vite/src/main.tsx__tmpl__ +31 -6
- package/src/generators/application/files/base-vite/tsconfig.app.json__tmpl__ +1 -1
- package/src/generators/application/files/base-webpack/src/app/__fileName__.spec.tsx__tmpl__ +3 -3
- package/src/generators/application/files/base-webpack/src/main.tsx__tmpl__ +22 -2
- package/src/generators/application/files/base-webpack/tsconfig.app.json__tmpl__ +1 -1
- package/src/generators/application/files/base-webpack/webpack.config.js__tmpl__ +3 -3
- package/src/generators/application/files/style-css-module/src/app/__fileName__.tsx__tmpl__ +26 -16
- package/src/generators/application/files/style-global-css/src/app/__fileName__.tsx__tmpl__ +29 -20
- package/src/generators/application/files/style-none/src/app/__fileName__.tsx__tmpl__ +26 -16
- package/src/generators/application/files/style-styled-jsx/src/app/__fileName__.tsx__tmpl__ +31 -22
- package/src/generators/application/files/style-styled-module/src/app/__fileName__.tsx__tmpl__ +30 -21
- package/src/generators/application/files/style-tailwind/src/app/__fileName__.tsx__tmpl__ +30 -18
- package/src/generators/application/lib/get-app-tests.js +8 -9
- package/src/generators/component/files/__fileName__.tsx__tmpl__ +55 -56
- package/src/generators/component-story/files/jsx/__componentFileName__.stories.jsx__tmpl__ +5 -5
- package/src/generators/component-story/files/tsx/__componentFileName__.stories.tsx__tmpl__ +3 -4
- package/src/generators/host/files/common/src/app/__fileName__.js__tmpl__ +20 -20
- package/src/generators/host/files/common/src/main.js__tmpl__ +9 -9
- package/src/generators/host/files/common-ts/src/app/__fileName__.tsx__tmpl__ +27 -27
- package/src/generators/host/files/common-ts/src/main.ts__tmpl__ +9 -9
- package/src/generators/host/files/rspack-common/src/app/__fileName__.jsx__tmpl__ +13 -13
- package/src/generators/host/files/rspack-common/src/main.jsx__tmpl__ +9 -9
- package/src/generators/host/files/rspack-module-federation/module-federation.config.js__tmpl__ +4 -4
- package/src/generators/host/files/rspack-module-federation/rspack.config.prod.js__tmpl__ +3 -1
- package/src/generators/host/files/rspack-module-federation-ssr/module-federation.server.config.js__tmpl__ +6 -4
- package/src/generators/host/files/rspack-module-federation-ssr/rspack.server.config.js__tmpl__ +1 -1
- package/src/generators/host/files/rspack-module-federation-ssr-ts/module-federation.server.config.ts__tmpl__ +6 -6
- package/src/generators/host/files/rspack-module-federation-ssr-ts/rspack.server.config.ts__tmpl__ +1 -1
- package/src/generators/host/files/rspack-module-federation-ts/module-federation.config.ts__tmpl__ +18 -18
- package/src/generators/host/files/rspack-module-federation-ts/rspack.config.prod.ts__tmpl__ +23 -21
- package/src/generators/host/files/rspack-module-federation-ts/rspack.config.ts__tmpl__ +1 -1
- package/src/generators/host/files/webpack-module-federation/module-federation.config.js__tmpl__ +4 -4
- package/src/generators/host/files/webpack-module-federation/webpack.config.prod.js__tmpl__ +23 -21
- package/src/generators/host/files/webpack-module-federation-ssr/module-federation.server.config.js__tmpl__ +6 -6
- package/src/generators/host/files/webpack-module-federation-ssr/webpack.server.config.js__tmpl__ +1 -1
- package/src/generators/host/files/webpack-module-federation-ssr-ts/module-federation.server.config.ts__tmpl__ +6 -6
- package/src/generators/host/files/webpack-module-federation-ssr-ts/webpack.server.config.ts__tmpl__ +1 -1
- package/src/generators/host/files/webpack-module-federation-ts/module-federation.config.ts__tmpl__ +18 -18
- package/src/generators/host/files/webpack-module-federation-ts/webpack.config.prod.ts__tmpl__ +23 -21
- package/src/generators/host/files/webpack-module-federation-ts/webpack.config.ts__tmpl__ +1 -1
- package/src/generators/library/files/common/tsconfig.lib.json__tmpl__ +1 -1
- package/src/generators/library/files/vite/tsconfig.lib.json__tmpl__ +1 -1
- package/src/generators/remote/files/rspack-module-federation/module-federation.config.js__tmpl__ +7 -7
- package/src/generators/remote/files/rspack-module-federation-ssr/module-federation.server.config.js__tmpl__ +4 -4
- package/src/generators/remote/files/rspack-module-federation-ssr/rspack.server.config.js__tmpl__ +1 -1
- package/src/generators/remote/files/rspack-module-federation-ssr-ts/module-federation.server.config.ts__tmpl__ +4 -4
- package/src/generators/remote/files/rspack-module-federation-ssr-ts/rspack.server.config.ts__tmpl__ +1 -1
- package/src/generators/remote/files/rspack-module-federation-ts/module-federation.config.ts__tmpl__ +7 -7
- package/src/generators/remote/files/rspack-module-federation-ts/rspack.config.ts__tmpl__ +1 -1
- package/src/generators/remote/files/webpack-module-federation/module-federation.config.js__tmpl__ +7 -7
- package/src/generators/remote/files/webpack-module-federation-ssr/module-federation.server.config.js__tmpl__ +4 -4
- package/src/generators/remote/files/webpack-module-federation-ssr/webpack.server.config.js__tmpl__ +1 -1
- package/src/generators/remote/files/webpack-module-federation-ssr-ts/module-federation.server.config.ts__tmpl__ +4 -4
- package/src/generators/remote/files/webpack-module-federation-ssr-ts/webpack.server.config.ts__tmpl__ +1 -1
- package/src/generators/remote/files/webpack-module-federation-ts/module-federation.config.ts__tmpl__ +7 -7
- package/src/generators/remote/files/webpack-module-federation-ts/webpack.config.ts__tmpl__ +1 -1
@@ -1,84 +1,83 @@
|
|
1
|
-
<% if (classComponent) { %>
|
1
|
+
<%_ if (classComponent) { _%>
|
2
2
|
import { Component } from 'react';
|
3
|
-
<% } %>
|
4
|
-
|
5
|
-
<% if (routing) { %>
|
3
|
+
<%_ } _%>
|
4
|
+
<%_ if (routing) { _%>
|
6
5
|
import { Route, Link } from 'react-router-dom';
|
7
|
-
<% } %>
|
6
|
+
<%_ } _%>
|
8
7
|
|
9
|
-
<% if (hasStyles) {
|
8
|
+
<%_ if (hasStyles) {
|
10
9
|
if (styledModule && styledModule !== 'styled-jsx') {
|
11
10
|
var wrapper = 'Styled' + className;
|
12
11
|
var extras = '';
|
13
|
-
%>
|
14
|
-
|
15
|
-
<% } else {
|
12
|
+
_%>
|
13
|
+
import styled from '<%= styledModule %>';
|
14
|
+
<%_ } else {
|
16
15
|
var wrapper = 'div';
|
17
16
|
var extras = globalCss || styledModule === 'styled-jsx' ? '' : " className={styles['container']}";
|
18
|
-
%>
|
19
|
-
|
20
|
-
<% }
|
17
|
+
_%>
|
18
|
+
<%- style !== 'styled-jsx' ? globalCss ? `import './${fileName}.${style}';` : `import styles from './${fileName}.module.${style}';`: '' %>
|
19
|
+
<%_ }
|
21
20
|
} else {
|
22
21
|
var wrapper = 'div';
|
23
22
|
var extras = '';
|
24
|
-
} %>
|
23
|
+
} _%>
|
25
24
|
|
26
|
-
<% if (styledModule && styledModule !== 'styled-jsx') { %>
|
25
|
+
<%_ if (styledModule && styledModule !== 'styled-jsx') { _%>
|
27
26
|
const Styled<%= className %> = styled.div`
|
28
27
|
color: pink;
|
29
28
|
`;
|
30
|
-
<% }%>
|
31
|
-
<% if(!isNextPage) { %>
|
32
|
-
<% if (classComponent) { %>
|
33
|
-
|
34
|
-
|
35
|
-
return (
|
36
|
-
<<%= wrapper %><%- extras %>>
|
37
|
-
<%= styledModule === 'styled-jsx' ? `<style jsx>{\`div { color: pink; }\`}</style>` : `` %>
|
38
|
-
<p>Welcome to <%= className %>!</p>
|
39
|
-
<% if (routing) { %>
|
40
|
-
<ul>
|
41
|
-
<li><Link to="/"><%= name %> root</Link></li>
|
42
|
-
</ul>
|
43
|
-
<Route path="/" element={<div>This is the <%= name %> root route.</div>} />
|
44
|
-
<% } %>
|
45
|
-
</<%= wrapper %>>
|
46
|
-
);
|
47
|
-
}
|
48
|
-
}
|
49
|
-
<% } else { %>
|
50
|
-
export function <%= className %>() {
|
29
|
+
<%_ } _%>
|
30
|
+
<%_ if(!isNextPage) { _%>
|
31
|
+
<%_ if (classComponent) { _%>
|
32
|
+
export class <%= className %> extends Component<{}> {
|
33
|
+
override render() {
|
51
34
|
return (
|
52
35
|
<<%= wrapper %><%- extras %>>
|
53
|
-
|
54
|
-
<
|
55
|
-
<% if (routing) { %>
|
36
|
+
<%= styledModule === 'styled-jsx' ? `<style jsx>{\`div { color: pink; }\`}</style>` : `` %>
|
37
|
+
<p>Welcome to <%= className %>!</p>
|
38
|
+
<%_ if (routing) { _%>
|
56
39
|
<ul>
|
57
40
|
<li><Link to="/"><%= name %> root</Link></li>
|
58
41
|
</ul>
|
59
42
|
<Route path="/" element={<div>This is the <%= name %> root route.</div>} />
|
60
|
-
<% } %>
|
43
|
+
<%_ } _%>
|
61
44
|
</<%= wrapper %>>
|
62
45
|
);
|
63
46
|
}
|
64
|
-
|
47
|
+
}
|
48
|
+
<%_ } else { _%>
|
49
|
+
export function <%= className %>() {
|
50
|
+
return (
|
51
|
+
<<%= wrapper %><%- extras %>>
|
52
|
+
<%_ if (styledModule === 'styled-jsx') { _%><style jsx>{`div { color: pink; }`}</style><%_ } _%>
|
53
|
+
<h1>Welcome to <%= className %>!</h1>
|
54
|
+
<%_ if (routing) { _%>
|
55
|
+
<ul>
|
56
|
+
<li><Link to="/"><%= name %> root</Link></li>
|
57
|
+
</ul>
|
58
|
+
<Route path="/" element={<div>This is the <%= name %> root route.</div>} />
|
59
|
+
<%_ } _%>
|
60
|
+
</<%= wrapper %>>
|
61
|
+
);
|
62
|
+
}
|
63
|
+
<%_ } _%>
|
65
64
|
|
66
|
-
|
67
|
-
<% } else { %>
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
65
|
+
export default <%= className %>;
|
66
|
+
<%_ } else { _%>
|
67
|
+
export default function <%= className %>() {
|
68
|
+
return (
|
69
|
+
<<%= wrapper %><%- extras %>>
|
70
|
+
<%_ if (styledModule === 'styled-jsx') { _%><style jsx>{`div { color: pink; }`}</style><%_ } _%>
|
71
|
+
<h1>Welcome to <%= className %>!</h1>
|
72
|
+
<% if (routing) { %>
|
73
|
+
<ul>
|
74
|
+
<li><Link to="/"><%= name %> root</Link></li>
|
75
|
+
</ul>
|
76
|
+
<Route path="/" element={<div>This is the <%= name %> root route.</div>} />
|
77
|
+
<% } %>
|
78
|
+
</<%= wrapper %>>
|
79
|
+
);
|
80
|
+
};
|
82
81
|
<% } %>
|
83
82
|
|
84
83
|
<% if (inSourceTests === true) { %> <%- inSourceVitestTests %> <% } %>
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import componentName from './<%= componentImportFileName %>';
|
2
|
-
<% if ( interactionTests ) { %>
|
2
|
+
<%_ if ( interactionTests ) { _%>
|
3
3
|
import { within } from '@storybook/testing-library';
|
4
4
|
import { expect } from '@storybook/jest';
|
5
|
-
<% } %>
|
5
|
+
<%_ } _%>
|
6
6
|
|
7
7
|
export default {
|
8
8
|
component: <%= componentName %>,
|
@@ -10,7 +10,7 @@ export default {
|
|
10
10
|
argTypes: {<% for (let argType of argTypes) { %>
|
11
11
|
<%= argType.name %>: { <%- argType.type %> : "<%- argType.actionText %>" },<% } %>
|
12
12
|
}
|
13
|
-
<% } %>
|
13
|
+
<%_ } _%>
|
14
14
|
};
|
15
15
|
|
16
16
|
export const Primary = {
|
@@ -19,11 +19,11 @@ export const Primary = {
|
|
19
19
|
},
|
20
20
|
};
|
21
21
|
|
22
|
-
<% if ( interactionTests ) { %>
|
22
|
+
<%_ if ( interactionTests ) { _%>
|
23
23
|
export const Heading: Story = {
|
24
24
|
play: async ({ canvasElement }) => {
|
25
25
|
const canvas = within(canvasElement);
|
26
26
|
expect(canvas.getByText(/Welcome to <%=componentName%>!/gi)).toBeTruthy();
|
27
27
|
},
|
28
28
|
};
|
29
|
-
<% } %>
|
29
|
+
<%_ } _%>
|
@@ -1,9 +1,9 @@
|
|
1
1
|
import type { Meta, StoryObj } from '@storybook/react';
|
2
2
|
import { <%= componentName %> } from './<%= componentImportFileName %>';
|
3
|
-
<% if ( interactionTests ) { %>
|
3
|
+
<%_ if ( interactionTests ) { _%>
|
4
4
|
import { within } from '@storybook/testing-library';
|
5
5
|
import { expect } from '@storybook/jest';
|
6
|
-
<% } %>
|
6
|
+
<%_ } _%>
|
7
7
|
|
8
8
|
const meta: Meta<typeof <%= componentName %>> = {
|
9
9
|
component: <%= componentName %>,
|
@@ -16,14 +16,13 @@ const meta: Meta<typeof <%= componentName %>> = {
|
|
16
16
|
export default meta;
|
17
17
|
type Story = StoryObj<typeof <%= componentName %>>;
|
18
18
|
|
19
|
-
|
20
19
|
export const Primary = {
|
21
20
|
args: {<% for (let prop of props) { %>
|
22
21
|
<%= prop.name %>: <%- prop.defaultValue %>,<% } %>
|
23
22
|
},
|
24
23
|
};
|
25
24
|
|
26
|
-
<% if ( interactionTests ) { %>
|
25
|
+
<%_ if ( interactionTests ) { _%>
|
27
26
|
export const Heading: Story = {
|
28
27
|
args: {<% for (let prop of props) { %>
|
29
28
|
<%= prop.name %>: <%- prop.defaultValue %>,<% } %>
|
@@ -1,31 +1,31 @@
|
|
1
1
|
import * as React from 'react';
|
2
|
-
<% if (!minimal) { %>
|
2
|
+
<%_ if (!minimal) { _%>
|
3
3
|
import NxWelcome from "./nx-welcome";
|
4
|
-
<% } %>
|
4
|
+
<%_ } _%>
|
5
5
|
import { Link, Route, Routes } from 'react-router-dom';
|
6
6
|
|
7
|
-
<% if (remotes.length > 0) {
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
<%_ if (remotes.length > 0) {
|
8
|
+
remotes.forEach(function(r) { _%>
|
9
|
+
const <%= r.className %> = React.lazy(() => import('<%= r.fileName %>/Module'));
|
10
|
+
<%_ }); _%>
|
11
11
|
<% } %>
|
12
12
|
export function App() {
|
13
13
|
return (
|
14
14
|
<React.Suspense fallback={null}>
|
15
|
-
|
16
|
-
|
17
|
-
<% remotes.forEach(function(r) { %>
|
18
|
-
|
19
|
-
<% }); %>
|
20
|
-
|
21
|
-
|
22
|
-
<% if (!minimal) { %>
|
23
|
-
|
24
|
-
<% } %>
|
25
|
-
<% remotes.forEach(function(r) { %>
|
26
|
-
|
27
|
-
<% }); %>
|
28
|
-
|
15
|
+
<ul>
|
16
|
+
<li><Link to="/">Home</Link></li>
|
17
|
+
<%_ remotes.forEach(function(r) { _%>
|
18
|
+
<li><Link to="/<%=r.fileName%>"><%=r.className%></Link></li>
|
19
|
+
<%_ }); _%>
|
20
|
+
</ul>
|
21
|
+
<Routes>
|
22
|
+
<%_ if (!minimal) { _%>
|
23
|
+
<Route path="/" element={<NxWelcome title="<%= projectName %>"/>} />
|
24
|
+
<%_ } _%>
|
25
|
+
<%_ remotes.forEach(function(r) { _%>
|
26
|
+
<Route path="/<%=r.fileName%>" element={<<%= r.className %>/>} />
|
27
|
+
<%_ }); _%>
|
28
|
+
</Routes>
|
29
29
|
</React.Suspense>
|
30
30
|
);
|
31
31
|
}
|
@@ -1,10 +1,10 @@
|
|
1
|
-
<% if (dynamic) { %>
|
2
|
-
|
1
|
+
<%_ if (dynamic) { _%>
|
2
|
+
import { setRemoteDefinitions } from '@nx/react/mf';
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
<% } else { %>
|
9
|
-
|
10
|
-
<% } %>
|
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,39 +1,39 @@
|
|
1
1
|
import * as React from 'react';
|
2
|
-
<% if (!minimal) { %>
|
2
|
+
<%_ if (!minimal) { _%>
|
3
3
|
import NxWelcome from "./nx-welcome";
|
4
|
-
<% } %>
|
4
|
+
<%_ } _%>
|
5
5
|
import { Link, Route, Routes } from 'react-router-dom';
|
6
|
-
<% if (dynamic) { %>
|
6
|
+
<%_ if (dynamic) { _%>
|
7
7
|
import { loadRemoteModule } from '@nx/react/mf';
|
8
|
-
<% } %>
|
8
|
+
<%_ } _%>
|
9
9
|
|
10
|
-
<% if (remotes.length > 0) {
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
<% } else
|
15
|
-
|
16
|
-
<% } %>
|
17
|
-
|
18
|
-
<% } %>
|
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
19
|
|
20
20
|
export function App() {
|
21
21
|
return (
|
22
22
|
<React.Suspense fallback={null}>
|
23
|
-
|
24
|
-
|
25
|
-
<% remotes.forEach(function(r) { %>
|
26
|
-
|
27
|
-
<% }); %>
|
28
|
-
|
29
|
-
|
30
|
-
<% if (!minimal) { %>
|
31
|
-
|
32
|
-
<% } %>
|
33
|
-
<% remotes.forEach(function(r) { %>
|
34
|
-
|
35
|
-
<% }); %>
|
36
|
-
|
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
37
|
</React.Suspense>
|
38
38
|
);
|
39
39
|
}
|
@@ -1,10 +1,10 @@
|
|
1
|
-
<% if (dynamic) { %>
|
2
|
-
|
1
|
+
<%_ if (dynamic) { _%>
|
2
|
+
import { setRemoteDefinitions } from '@nx/react/mf';
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
<% } else { %>
|
9
|
-
|
10
|
-
<% } %>
|
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,30 +1,30 @@
|
|
1
1
|
import * as React from 'react';
|
2
|
-
<% if (!minimal) { %>
|
2
|
+
<%_ if (!minimal) { _%>
|
3
3
|
import NxWelcome from "./nx-welcome";
|
4
|
-
<% } %>
|
4
|
+
<%_ } _%>
|
5
5
|
import { Link, Route, Routes } from 'react-router-dom';
|
6
6
|
|
7
|
-
<% if (remotes.length > 0) {
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
<% } %>
|
7
|
+
<% if (remotes.length > 0) {
|
8
|
+
remotes.forEach(function(r) { %>
|
9
|
+
const <%= r.className %> = React.lazy(() => import('<%= r.fileName %>/Module'));
|
10
|
+
<%_ }); _%>
|
11
|
+
<%_ } _%>
|
12
12
|
export function App() {
|
13
13
|
return (
|
14
14
|
<React.Suspense fallback={null}>
|
15
15
|
<ul>
|
16
16
|
<li><Link to="/">Home</Link></li>
|
17
|
-
<% remotes.forEach(function(r) { %>
|
17
|
+
<%_ remotes.forEach(function(r) { _%>
|
18
18
|
<li><Link to="/<%=r.fileName%>"><%=r.className%></Link></li>
|
19
|
-
<% }); %>
|
19
|
+
<%_ }); _%>
|
20
20
|
</ul>
|
21
21
|
<Routes>
|
22
|
-
<% if (!minimal) { %>
|
22
|
+
<%_ if (!minimal) { _%>
|
23
23
|
<Route path="/" element={<NxWelcome title="<%= projectName %>"/>} />
|
24
|
-
<% } %>
|
25
|
-
<% remotes.forEach(function(r) { %>
|
24
|
+
<%_ } _%>
|
25
|
+
<%_ remotes.forEach(function(r) { _%>
|
26
26
|
<Route path="/<%=r.fileName%>" element={<<%= r.className %>/>} />
|
27
|
-
<% }); %>
|
27
|
+
<%_ }); _%>
|
28
28
|
</Routes>
|
29
29
|
</React.Suspense>
|
30
30
|
);
|
@@ -1,10 +1,10 @@
|
|
1
|
-
<% if (dynamic) { %>
|
2
|
-
|
1
|
+
<%_ if (dynamic) { _%>
|
2
|
+
import { setRemoteDefinitions } from '@nx/react/mf';
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
<% } else { %>
|
9
|
-
|
10
|
-
<% } %>
|
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
|
+
<%_ } _%>
|
@@ -23,7 +23,9 @@ const prodConfig = {
|
|
23
23
|
* ]
|
24
24
|
*/
|
25
25
|
remotes: [
|
26
|
-
|
26
|
+
<%_ remotes.forEach(function(r) { _%>
|
27
|
+
['<%= r.fileName %>', 'http://localhost:<%= r.port %>/'],
|
28
|
+
<%_ }); _%>
|
27
29
|
],
|
28
30
|
};
|
29
31
|
|
@@ -6,10 +6,12 @@
|
|
6
6
|
const moduleFederationConfig = {
|
7
7
|
name: '<%= projectName %>',
|
8
8
|
remotes: [
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
9
|
+
<%_ if (static) {
|
10
|
+
remotes.forEach(function(r) { _%>
|
11
|
+
"<%= r.fileName %>",
|
12
|
+
<%_ });
|
13
|
+
}
|
14
|
+
_%>
|
13
15
|
],
|
14
16
|
};
|
15
17
|
|
package/src/generators/host/files/rspack-module-federation-ssr/rspack.server.config.js__tmpl__
CHANGED
@@ -4,7 +4,7 @@ const {withModuleFederationForSSR} = require('@nx/rspack/module-federation');
|
|
4
4
|
const baseConfig = require('./module-federation.config');
|
5
5
|
|
6
6
|
const defaultConfig = {
|
7
|
-
|
7
|
+
...baseConfig
|
8
8
|
};
|
9
9
|
|
10
10
|
// Nx plugins for rspack to build config object from Nx options and context.
|
@@ -1,12 +1,12 @@
|
|
1
1
|
import { ModuleFederationConfig } from '@nx/rspack/module-federation';
|
2
2
|
|
3
3
|
const config: ModuleFederationConfig = {
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
4
|
+
name: '<%= projectName %>',
|
5
|
+
remotes: [
|
6
|
+
<%_ if (static) {
|
7
|
+
remotes.forEach(function(r) { _%>
|
8
|
+
"<%= r.fileName %>",
|
9
|
+
<%_ }); } _%>
|
10
10
|
],
|
11
11
|
};
|
12
12
|
|
package/src/generators/host/files/rspack-module-federation-ssr-ts/rspack.server.config.ts__tmpl__
CHANGED
@@ -4,7 +4,7 @@ import {withModuleFederationForSSR} from '@nx/rspack/module-federation';
|
|
4
4
|
import baseConfig from './module-federation.config';
|
5
5
|
|
6
6
|
const defaultConfig = {
|
7
|
-
|
7
|
+
...baseConfig
|
8
8
|
};
|
9
9
|
|
10
10
|
// Nx plugins for rspack to build config object from Nx options and context.
|
package/src/generators/host/files/rspack-module-federation-ts/module-federation.config.ts__tmpl__
CHANGED
@@ -1,24 +1,24 @@
|
|
1
1
|
import { ModuleFederationConfig } from '@nx/rspack/module-federation';
|
2
2
|
|
3
3
|
const config: ModuleFederationConfig = {
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
%>
|
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
|
+
remotes: [
|
18
|
+
<%_ if (static) {
|
19
|
+
remotes.forEach(function(r) { _%>
|
20
|
+
"<%= r.fileName %>",
|
21
|
+
<%_ }); } _%>
|
22
22
|
],
|
23
23
|
};
|
24
24
|
|
@@ -4,27 +4,29 @@ import { withModuleFederation, ModuleFederationConfig } from '@nx/rspack/module-
|
|
4
4
|
import baseConfig from './module-federation.config';
|
5
5
|
|
6
6
|
const prodConfig: ModuleFederationConfig = {
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
],
|
7
|
+
...baseConfig,
|
8
|
+
/*
|
9
|
+
* Remote overrides for production.
|
10
|
+
* Each entry is a pair of a unique name and the URL where it is deployed.
|
11
|
+
*
|
12
|
+
* e.g.
|
13
|
+
* remotes: [
|
14
|
+
* ['app1', 'http://app1.example.com'],
|
15
|
+
* ['app2', 'http://app2.example.com'],
|
16
|
+
* ]
|
17
|
+
*
|
18
|
+
* You can also use a full path to the remoteEntry.js file if desired.
|
19
|
+
*
|
20
|
+
* remotes: [
|
21
|
+
* ['app1', 'http://example.com/path/to/app1/remoteEntry.js'],
|
22
|
+
* ['app2', 'http://example.com/path/to/app2/remoteEntry.js'],
|
23
|
+
* ]
|
24
|
+
*/
|
25
|
+
remotes: [
|
26
|
+
<%_ remotes.forEach(function(r) { _%>
|
27
|
+
['<%= r.fileName %>', 'http://localhost:<%= r.port %>/'],
|
28
|
+
<%_ }); _%>
|
29
|
+
],
|
28
30
|
};
|
29
31
|
|
30
32
|
// Nx plugins for rspack to build config object from Nx options and context.
|
@@ -4,7 +4,7 @@ import {withModuleFederation, ModuleFederationConfig} from '@nx/rspack/module-fe
|
|
4
4
|
import baseConfig from './module-federation.config';
|
5
5
|
|
6
6
|
const config: ModuleFederationConfig = {
|
7
|
-
|
7
|
+
...baseConfig,
|
8
8
|
};
|
9
9
|
|
10
10
|
// Nx plugins for rspack to build config object from Nx options and context.
|