@nx/angular 18.2.3 → 18.2.4
Sign up to get free protection for your applications and to get access to all the features.
- package/package.json +8 -8
- package/src/generators/setup-mf/files/ts-webpack/module-federation.config.ts__tmpl__ +1 -1
- package/src/generators/setup-mf/files/webpack/module-federation.config.js__tmpl__ +1 -1
- package/src/generators/setup-mf/lib/add-remote-to-host.d.ts +7 -2
- package/src/generators/setup-mf/lib/add-remote-to-host.js +2 -15
- package/src/generators/setup-mf/lib/generate-config.js +1 -0
- package/src/generators/setup-mf/lib/update-host-app-routes.js +1 -4
- package/src/generators/setup-mf/setup-mf.js +14 -1
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@nx/angular",
|
3
|
-
"version": "18.2.
|
3
|
+
"version": "18.2.4",
|
4
4
|
"private": false,
|
5
5
|
"description": "The Nx Plugin for Angular contains executors, generators, and utilities for managing Angular applications and libraries within an Nx workspace. It provides: \n\n- Integration with libraries such as Storybook, Jest, ESLint, Tailwind CSS, and Cypress. \n\n- Generators to help scaffold code quickly (like: Micro Frontends, Libraries, both internal to your codebase and publishable to npm) \n\n- Single Component Application Modules (SCAMs) \n\n- NgRx helpers. \n\n- Utilities for automatic workspace refactoring.",
|
6
6
|
"repository": {
|
@@ -78,14 +78,14 @@
|
|
78
78
|
"tslib": "^2.3.0",
|
79
79
|
"webpack": "^5.80.0",
|
80
80
|
"webpack-merge": "^5.8.0",
|
81
|
-
"@nx/devkit": "18.2.
|
82
|
-
"@nx/js": "18.2.
|
83
|
-
"@nx/eslint": "18.2.
|
84
|
-
"@nx/webpack": "18.2.
|
85
|
-
"@nx/web": "18.2.
|
86
|
-
"@nx/workspace": "18.2.
|
81
|
+
"@nx/devkit": "18.2.4",
|
82
|
+
"@nx/js": "18.2.4",
|
83
|
+
"@nx/eslint": "18.2.4",
|
84
|
+
"@nx/webpack": "18.2.4",
|
85
|
+
"@nx/web": "18.2.4",
|
86
|
+
"@nx/workspace": "18.2.4",
|
87
87
|
"piscina": "^4.4.0",
|
88
|
-
"@nrwl/angular": "18.2.
|
88
|
+
"@nrwl/angular": "18.2.4"
|
89
89
|
},
|
90
90
|
"peerDependencies": {
|
91
91
|
"@angular-devkit/build-angular": ">= 15.0.0 < 18.0.0",
|
@@ -14,7 +14,7 @@ const config: ModuleFederationConfig = {
|
|
14
14
|
* declare module 'my-external-remote';
|
15
15
|
*
|
16
16
|
*/
|
17
|
-
remotes: [<% remotes.forEach(function(remote) { %>'<%= remote.remoteName %>',<% }); %>]<% } %><% if(type === 'remote') { %>
|
17
|
+
remotes: [<% if (federationType === 'static') { remotes.forEach(function(remote) { %>'<%= remote.remoteName %>',<% }); } %>]<% } %><% if(type === 'remote') { %>
|
18
18
|
exposes: {<% if(standalone) { %>
|
19
19
|
'./Routes': '<%= projectRoot %>/src/app/remote-entry/entry.routes.ts',<% } else { %>
|
20
20
|
'./Module': '<%= projectRoot %>/src/app/remote-entry/entry.module.ts',<% } %>
|
@@ -12,7 +12,7 @@ module.exports = {
|
|
12
12
|
* declare module 'my-external-remote';
|
13
13
|
*
|
14
14
|
*/
|
15
|
-
remotes: [<% remotes.forEach(function(remote) { %>'<%= remote.remoteName %>',<% }); %>]<% } %><% if(type === 'remote') { %>
|
15
|
+
remotes: [<% if (federationType === 'static') { remotes.forEach(function(remote) { %>'<%= remote.remoteName %>',<% }); } %>]<% } %><% if(type === 'remote') { %>
|
16
16
|
exposes: {<% if(standalone) { %>
|
17
17
|
'./Routes': '<%= projectRoot %>/src/app/remote-entry/entry.routes.ts',<% } else { %>
|
18
18
|
'./Module': '<%= projectRoot %>/src/app/remote-entry/entry.module.ts',<% } %>
|
@@ -1,4 +1,9 @@
|
|
1
1
|
import { Tree } from '@nx/devkit';
|
2
|
-
|
2
|
+
export type AddRemoteOptions = {
|
3
|
+
host: string;
|
4
|
+
appName: string;
|
5
|
+
standalone: boolean;
|
6
|
+
port: number;
|
7
|
+
};
|
3
8
|
export declare function checkIsCommaNeeded(mfRemoteText: string): boolean;
|
4
|
-
export declare function addRemoteToHost(tree: Tree, options:
|
9
|
+
export declare function addRemoteToHost(tree: Tree, options: AddRemoteOptions): void;
|
@@ -27,19 +27,6 @@ function addRemoteToHost(tree, options) {
|
|
27
27
|
else if (hostFederationType === 'dynamic') {
|
28
28
|
addRemoteToDynamicHost(tree, options, pathToMFManifest);
|
29
29
|
}
|
30
|
-
// const declarationFilePath = joinPathFragments(
|
31
|
-
// hostProject.sourceRoot,
|
32
|
-
// 'remotes.d.ts'
|
33
|
-
// );
|
34
|
-
//
|
35
|
-
// const declarationFileContent =
|
36
|
-
// (tree.exists(declarationFilePath)
|
37
|
-
// ? tree.read(declarationFilePath, 'utf-8')
|
38
|
-
// : '') +
|
39
|
-
// `\ndeclare module '${options.appName}/${
|
40
|
-
// options.standalone ? `Routes` : `Module`
|
41
|
-
// }';`;
|
42
|
-
// tree.write(declarationFilePath, declarationFileContent);
|
43
30
|
addLazyLoadedRouteToHostAppModule(tree, options, hostFederationType);
|
44
31
|
}
|
45
32
|
}
|
@@ -47,8 +34,8 @@ exports.addRemoteToHost = addRemoteToHost;
|
|
47
34
|
function determineHostFederationType(tree, pathToMfManifest) {
|
48
35
|
return tree.exists(pathToMfManifest) ? 'dynamic' : 'static';
|
49
36
|
}
|
50
|
-
function addRemoteToStaticHost(tree, options, hostProject,
|
51
|
-
const hostMFConfigPath = (0, devkit_1.joinPathFragments)(hostProject.root,
|
37
|
+
function addRemoteToStaticHost(tree, options, hostProject, isHostUsingTypescript) {
|
38
|
+
const hostMFConfigPath = (0, devkit_1.joinPathFragments)(hostProject.root, isHostUsingTypescript
|
52
39
|
? 'module-federation.config.ts'
|
53
40
|
: 'module-federation.config.js');
|
54
41
|
if (!hostMFConfigPath || !tree.exists(hostMFConfigPath)) {
|
@@ -18,6 +18,7 @@ function generateWebpackConfig(tree, options, appRoot, remotesWithPorts) {
|
|
18
18
|
(0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, `../files/${pathToWebpackTemplateFiles}`), appRoot, {
|
19
19
|
tmpl: '',
|
20
20
|
type: options.mfType,
|
21
|
+
federationType: options.federationType,
|
21
22
|
name: options.appName,
|
22
23
|
remotes: remotesWithPorts ?? [],
|
23
24
|
projectRoot: appRoot,
|
@@ -11,11 +11,8 @@ function updateHostAppRoutes(tree, options) {
|
|
11
11
|
tsModule = (0, ensure_typescript_1.ensureTypescript)();
|
12
12
|
}
|
13
13
|
const { sourceRoot } = (0, project_configuration_1.readProjectConfiguration)(tree, options.appName);
|
14
|
-
const remoteRoutes = options.remotes && Array.isArray(options.remotes)
|
15
|
-
? options.remotes.reduce((routes, remote) => `${routes}\n<li><a routerLink='${remote}'>${(0, devkit_1.names)(remote).className}</a></li>`, '')
|
16
|
-
: '';
|
17
14
|
tree.write((0, devkit_1.joinPathFragments)(sourceRoot, 'app/app.component.html'), `<ul class="remote-menu">
|
18
|
-
<li><a routerLink="/">Home</a></li
|
15
|
+
<li><a routerLink="/">Home</a></li>
|
19
16
|
</ul>
|
20
17
|
<router-outlet></router-outlet>
|
21
18
|
`);
|
@@ -9,7 +9,12 @@ async function setupMf(tree, rawOptions) {
|
|
9
9
|
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.appName);
|
10
10
|
let installTask = () => { };
|
11
11
|
if (options.mfType === 'remote') {
|
12
|
-
(0, lib_1.addRemoteToHost)(tree,
|
12
|
+
(0, lib_1.addRemoteToHost)(tree, {
|
13
|
+
appName: options.appName,
|
14
|
+
host: options.host,
|
15
|
+
standalone: options.standalone,
|
16
|
+
port: options.port,
|
17
|
+
});
|
13
18
|
(0, lib_1.addRemoteEntry)(tree, options, projectConfig.root);
|
14
19
|
(0, lib_1.removeDeadCodeFromRemote)(tree, options);
|
15
20
|
(0, lib_1.setupTspathForRemote)(tree, options);
|
@@ -24,6 +29,14 @@ async function setupMf(tree, rawOptions) {
|
|
24
29
|
if (options.mfType === 'host') {
|
25
30
|
(0, lib_1.setupHostIfDynamic)(tree, options);
|
26
31
|
(0, lib_1.updateHostAppRoutes)(tree, options);
|
32
|
+
for (const { remoteName, port } of remotesWithPorts) {
|
33
|
+
(0, lib_1.addRemoteToHost)(tree, {
|
34
|
+
appName: remoteName,
|
35
|
+
host: options.appName,
|
36
|
+
standalone: options.standalone,
|
37
|
+
port,
|
38
|
+
});
|
39
|
+
}
|
27
40
|
installTask = (0, devkit_1.addDependenciesToPackageJson)(tree, {}, { '@nx/webpack': versions_1.nxVersion });
|
28
41
|
}
|
29
42
|
if (!options.skipE2E) {
|