@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 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 Monorepos · Fast CI" src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-light.svg" width="100%">
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 Monorepos · Fast CI
23
+ # Nx: Smart Repos · Fast Builds
24
24
 
25
- Nx is a build system, optimized for monorepos, with plugins for popular frameworks and tools and advanced CI capabilities including caching and distribution.
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 Monorepos · Fast CI"></a></p>
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.2",
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.2",
29
- "@nx/js": "21.1.2",
30
- "@nx/web": "21.1.2",
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",
@@ -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
- let [nxRemoteProjectName, remoteLocation] = remote;
30
+ const [nxRemoteProjectName, remoteLocation] = remote;
31
31
  const mfRemoteName = normalizeRemoteName(nxRemoteProjectName);
32
- const remoteLocationExt = (0, path_1.extname)(remoteLocation);
33
- // If remote location already has .js or .mjs extension
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 baseRemote = remoteLocation.endsWith('/')
41
- ? remoteLocation.slice(0, -1)
42
- : remoteLocation;
43
- const globalPrefix = isRemoteGlobal
44
- ? `${normalizeRemoteName(nxRemoteProjectName)}@`
45
- : '';
46
- // if the remote is defined with anything other than http then we assume it's a promise based remote
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 remoteLocationExt = (0, path_1.extname)(remoteLocation);
77
- mappedRemotes[mfRemoteName] = `${mfRemoteName}@${['.js', '.mjs', '.json'].includes(remoteLocationExt)
78
- ? remoteLocation
79
- : `${remoteLocation.endsWith('/')
80
- ? remoteLocation.slice(0, -1)
81
- : remoteLocation}/remoteEntry.${remoteEntryExt}`}`;
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);