@nx/module-federation 21.1.2 → 21.1.3
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/README.md +4 -4
- package/package.json +4 -4
- package/src/utils/remotes.js +22 -26
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<p style="text-align: center;">
|
|
2
2
|
<picture>
|
|
3
3
|
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-dark.svg">
|
|
4
|
-
<img alt="Nx - Smart
|
|
4
|
+
<img alt="Nx - Smart Repos · Fast Builds" src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-light.svg" width="100%">
|
|
5
5
|
</picture>
|
|
6
6
|
</p>
|
|
7
7
|
|
|
@@ -20,9 +20,9 @@
|
|
|
20
20
|
|
|
21
21
|
<hr>
|
|
22
22
|
|
|
23
|
-
# Nx: Smart
|
|
23
|
+
# Nx: Smart Repos · Fast Builds
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
An AI-first build platform that connects everything from your editor to CI. Helping you deliver fast, without breaking things.
|
|
26
26
|
|
|
27
27
|
This package is a [Module Federation plugin for Nx](https://nx.dev/nx-api/module-federation).
|
|
28
28
|
Module Federation allows developers to share code between deployed applications easier and makes team collaboration more efficient.
|
|
@@ -66,5 +66,5 @@ npx nx@latest init
|
|
|
66
66
|
- [Blog Posts About Nx](https://nx.dev/blog)
|
|
67
67
|
|
|
68
68
|
<p style="text-align: center;"><a href="https://nx.dev/#learning-materials" target="_blank" rel="noreferrer"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-courses-and-videos.svg"
|
|
69
|
-
width="100%" alt="Nx - Smart
|
|
69
|
+
width="100%" alt="Nx - Smart Repos · Fast Builds"></a></p>
|
|
70
70
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/module-federation",
|
|
3
3
|
"description": "The Nx Plugin for Module Federation contains executors and utilities that support building applications using Module Federation.",
|
|
4
|
-
"version": "21.1.
|
|
4
|
+
"version": "21.1.3",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -25,9 +25,9 @@
|
|
|
25
25
|
"executors": "./executors.json",
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"tslib": "^2.3.0",
|
|
28
|
-
"@nx/devkit": "21.1.
|
|
29
|
-
"@nx/js": "21.1.
|
|
30
|
-
"@nx/web": "21.1.
|
|
28
|
+
"@nx/devkit": "21.1.3",
|
|
29
|
+
"@nx/js": "21.1.3",
|
|
30
|
+
"@nx/web": "21.1.3",
|
|
31
31
|
"picocolors": "^1.1.0",
|
|
32
32
|
"webpack": "^5.88.0",
|
|
33
33
|
"@rspack/core": "^1.3.8",
|
package/src/utils/remotes.js
CHANGED
|
@@ -27,30 +27,22 @@ function mapRemotes(remotes, remoteEntryExt, determineRemoteUrl, isRemoteGlobal
|
|
|
27
27
|
}
|
|
28
28
|
// Helper function to deal with remotes that are arrays
|
|
29
29
|
function handleArrayRemote(remote, remoteEntryExt, isRemoteGlobal) {
|
|
30
|
-
|
|
30
|
+
const [nxRemoteProjectName, remoteLocation] = remote;
|
|
31
31
|
const mfRemoteName = normalizeRemoteName(nxRemoteProjectName);
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
if (['.js', '.mjs', '.json'].includes(remoteLocationExt)) {
|
|
35
|
-
if (isRemoteGlobal && !remoteLocation.startsWith(`${mfRemoteName}@`)) {
|
|
36
|
-
return `${mfRemoteName}@${remoteLocation}`;
|
|
37
|
-
}
|
|
32
|
+
// Remote string starts like "promise new Promise(...)" – return as-is
|
|
33
|
+
if (remoteLocation.startsWith('promise new Promise')) {
|
|
38
34
|
return remoteLocation;
|
|
39
35
|
}
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
// In that case we should use what the user provides as the remote location
|
|
48
|
-
if (!remoteLocation.startsWith('promise new Promise')) {
|
|
49
|
-
return `${globalPrefix}${baseRemote}/remoteEntry.${remoteEntryExt}`;
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
return remoteLocation;
|
|
36
|
+
const resolvedUrl = new URL(remoteLocation);
|
|
37
|
+
const ext = (0, path_1.extname)(resolvedUrl.pathname);
|
|
38
|
+
const needsRemoteEntry = !['.js', '.mjs', '.json'].includes(ext);
|
|
39
|
+
if (needsRemoteEntry) {
|
|
40
|
+
resolvedUrl.pathname = resolvedUrl.pathname.endsWith('/')
|
|
41
|
+
? `${resolvedUrl.pathname}remoteEntry.${remoteEntryExt}`
|
|
42
|
+
: `${resolvedUrl.pathname}/remoteEntry.${remoteEntryExt}`;
|
|
53
43
|
}
|
|
44
|
+
const finalRemoteUrl = resolvedUrl.href;
|
|
45
|
+
return isRemoteGlobal ? `${mfRemoteName}@${finalRemoteUrl}` : finalRemoteUrl;
|
|
54
46
|
}
|
|
55
47
|
// Helper function to deal with remotes that are strings
|
|
56
48
|
function handleStringRemote(nxRemoteProjectName, determineRemoteUrl, isRemoteGlobal) {
|
|
@@ -73,12 +65,16 @@ function mapRemotesForSSR(remotes, remoteEntryExt, determineRemoteUrl) {
|
|
|
73
65
|
if (Array.isArray(remote)) {
|
|
74
66
|
let [nxRemoteProjectName, remoteLocation] = remote;
|
|
75
67
|
const mfRemoteName = normalizeRemoteName(nxRemoteProjectName);
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
68
|
+
const resolvedUrl = new URL(remoteLocation);
|
|
69
|
+
const remoteLocationExt = (0, path_1.extname)(resolvedUrl.pathname);
|
|
70
|
+
const needsRemoteEntry = !['.js', '.mjs', '.json'].includes(remoteLocationExt);
|
|
71
|
+
if (needsRemoteEntry) {
|
|
72
|
+
resolvedUrl.pathname = resolvedUrl.pathname.endsWith('/')
|
|
73
|
+
? `${resolvedUrl.pathname}remoteEntry.${remoteEntryExt}`
|
|
74
|
+
: `${resolvedUrl.pathname}/remoteEntry.${remoteEntryExt}`;
|
|
75
|
+
}
|
|
76
|
+
const finalRemoteUrl = resolvedUrl.href;
|
|
77
|
+
mappedRemotes[mfRemoteName] = `${mfRemoteName}@${finalRemoteUrl}`;
|
|
82
78
|
}
|
|
83
79
|
else if (typeof remote === 'string') {
|
|
84
80
|
const mfRemoteName = normalizeRemoteName(remote);
|