@nx/module-federation 22.0.0-beta.4 → 22.0.0-beta.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.
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": "22.0.0-beta.
|
|
4
|
+
"version": "22.0.0-beta.6",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -27,9 +27,9 @@
|
|
|
27
27
|
"@module-federation/enhanced": "^0.18.0",
|
|
28
28
|
"@module-federation/node": "^2.7.11",
|
|
29
29
|
"@module-federation/sdk": "^0.18.0",
|
|
30
|
-
"@nx/devkit": "22.0.0-beta.
|
|
31
|
-
"@nx/js": "22.0.0-beta.
|
|
32
|
-
"@nx/web": "22.0.0-beta.
|
|
30
|
+
"@nx/devkit": "22.0.0-beta.6",
|
|
31
|
+
"@nx/js": "22.0.0-beta.6",
|
|
32
|
+
"@nx/web": "22.0.0-beta.6",
|
|
33
33
|
"@rspack/core": "^1.3.8",
|
|
34
34
|
"express": "^4.21.2",
|
|
35
35
|
"http-proxy-middleware": "^3.0.5",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"webpack": "^5.101.3"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"nx": "22.0.0-beta.
|
|
41
|
+
"nx": "22.0.0-beta.6"
|
|
42
42
|
},
|
|
43
43
|
"nx-migrations": {
|
|
44
44
|
"migrations": "./migrations.json"
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
[key: string]: string;
|
|
4
|
-
};
|
|
5
|
-
devDependencies?: {
|
|
6
|
-
[key: string]: string;
|
|
7
|
-
};
|
|
8
|
-
};
|
|
1
|
+
import type { PackageJson } from 'nx/src/utils/package-json';
|
|
2
|
+
export declare function readRootPackageJson(): PackageJson;
|
|
9
3
|
//# sourceMappingURL=package-json.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package-json.d.ts","sourceRoot":"","sources":["../../../../../packages/module-federation/src/utils/package-json.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"package-json.d.ts","sourceRoot":"","sources":["../../../../../packages/module-federation/src/utils/package-json.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAE7D,wBAAgB,mBAAmB,IAAI,WAAW,CASjD"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.readRootPackageJson = readRootPackageJson;
|
|
4
|
-
const fs_1 = require("fs");
|
|
5
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const fs_1 = require("fs");
|
|
6
6
|
function readRootPackageJson() {
|
|
7
7
|
const pkgJsonPath = (0, devkit_1.joinPathFragments)(devkit_1.workspaceRoot, 'package.json');
|
|
8
8
|
if (!(0, fs_1.existsSync)(pkgJsonPath)) {
|
package/src/utils/share.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"share.d.ts","sourceRoot":"","sources":["../../../../../packages/module-federation/src/utils/share.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EACnB,4BAA4B,EAC5B,gBAAgB,EACjB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAQlE,OAAO,EACL,KAAK,YAAY,
|
|
1
|
+
{"version":3,"file":"share.d.ts","sourceRoot":"","sources":["../../../../../packages/module-federation/src/utils/share.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EACnB,4BAA4B,EAC5B,gBAAgB,EACjB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAQlE,OAAO,EACL,KAAK,YAAY,EAMlB,MAAM,YAAY,CAAC;AAKpB;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CACrC,aAAa,EAAE,gBAAgB,EAAE,EACjC,YAAY,SAAwD,EACpE,OAAO,GAAE,QAAQ,GAAG,SAAoB,GACvC,4BAA4B,CAgN9B;AAED;;;;;GAKG;AACH,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,GACd,mBAAmB,GAAG,SAAS,CAYjC;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,MAAM,EAAE,GACjB,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAqBrC;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,EACjD,QAAQ,EAAE,cAAc,GAAG,SAAS,GACnC,IAAI,CAgBN;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,qBAAqB,CACnC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,EACjD,gBAAgB,EAAE,sBAAsB,GAAG,SAAS,EACpD,YAAY,EAAE,YAAY,GACzB,IAAI,CAcN"}
|
package/src/utils/share.js
CHANGED
|
@@ -25,9 +25,6 @@ function shareWorkspaceLibraries(workspaceLibs, tsConfigPath = process.env.NX_TS
|
|
|
25
25
|
return getEmptySharedLibrariesConfig();
|
|
26
26
|
}
|
|
27
27
|
const tsconfigPathAliases = (0, typescript_1.readTsPathMappings)(tsConfigPath);
|
|
28
|
-
if (!Object.keys(tsconfigPathAliases).length) {
|
|
29
|
-
return getEmptySharedLibrariesConfig();
|
|
30
|
-
}
|
|
31
28
|
// Nested projects must come first, sort them as such
|
|
32
29
|
const sortedTsConfigPathAliases = {};
|
|
33
30
|
Object.keys(tsconfigPathAliases)
|
|
@@ -52,6 +49,16 @@ function shareWorkspaceLibraries(workspaceLibs, tsConfigPath = process.env.NX_TS
|
|
|
52
49
|
path: (0, path_1.normalize)((0, path_1.join)(devkit_1.workspaceRoot, paths[0])),
|
|
53
50
|
});
|
|
54
51
|
}
|
|
52
|
+
// Collect workspace libs that are not in TS path mappings
|
|
53
|
+
// This supports TS Solution + PM Workspaces where libs use package.json
|
|
54
|
+
const workspaceLibrariesAsDeps = [];
|
|
55
|
+
if (Object.keys(sortedTsConfigPathAliases).length !== workspaceLibs.length) {
|
|
56
|
+
for (const workspaceLib of workspaceLibs) {
|
|
57
|
+
if (!sortedTsConfigPathAliases[workspaceLib.importKey]) {
|
|
58
|
+
workspaceLibrariesAsDeps.push(workspaceLib.importKey);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
55
62
|
const normalModuleReplacementPluginImpl = bundler === 'rspack'
|
|
56
63
|
? core_1.NormalModuleReplacementPlugin
|
|
57
64
|
: require('webpack').NormalModuleReplacementPlugin;
|
|
@@ -68,9 +75,11 @@ function shareWorkspaceLibraries(workspaceLibs, tsConfigPath = process.env.NX_TS
|
|
|
68
75
|
(0, fs_1.existsSync)((0, devkit_1.joinPathFragments)(devkit_1.workspaceRoot, projectRoot, 'package.json'))) {
|
|
69
76
|
pkgJson = (0, devkit_1.readJsonFile)((0, devkit_1.joinPathFragments)(devkit_1.workspaceRoot, projectRoot, 'package.json'));
|
|
70
77
|
}
|
|
71
|
-
|
|
78
|
+
const libraries = pathMappings.reduce((libraries, library) => {
|
|
72
79
|
// Check to see if the library version is declared in the app's package.json
|
|
73
|
-
let version = pkgJson
|
|
80
|
+
let version = pkgJson
|
|
81
|
+
? (0, devkit_1.getDependencyVersionFromPackageJson)(library.name, devkit_1.workspaceRoot, pkgJson)
|
|
82
|
+
: null;
|
|
74
83
|
if (!version && workspaceLibs.length > 0) {
|
|
75
84
|
const workspaceLib = workspaceLibs.find((lib) => lib.importKey === library.name);
|
|
76
85
|
const libPackageJsonPath = workspaceLib
|
|
@@ -96,6 +105,48 @@ function shareWorkspaceLibraries(workspaceLibs, tsConfigPath = process.env.NX_TS
|
|
|
96
105
|
},
|
|
97
106
|
};
|
|
98
107
|
}, {});
|
|
108
|
+
// Add workspace libs from package.json dependencies
|
|
109
|
+
// This supports TS Solution + PM Workspaces
|
|
110
|
+
for (const libraryName of workspaceLibrariesAsDeps) {
|
|
111
|
+
let version = pkgJson?.dependencies?.[libraryName] ??
|
|
112
|
+
pkgJson?.devDependencies?.[libraryName];
|
|
113
|
+
// Normalize workspace protocol versions (workspace:*, workspace:^, *, etc.)
|
|
114
|
+
if (version &&
|
|
115
|
+
(version === '*' ||
|
|
116
|
+
version.startsWith('workspace:') ||
|
|
117
|
+
version.startsWith('file:'))) {
|
|
118
|
+
// Look up the actual version from the library's package.json
|
|
119
|
+
const workspaceLib = workspaceLibs.find((lib) => lib.importKey === libraryName);
|
|
120
|
+
if (workspaceLib) {
|
|
121
|
+
const libPackageJsonPath = (0, path_1.join)(devkit_1.workspaceRoot, workspaceLib.root, 'package.json');
|
|
122
|
+
if ((0, fs_1.existsSync)(libPackageJsonPath)) {
|
|
123
|
+
const libPkgJson = (0, devkit_1.readJsonFile)(libPackageJsonPath);
|
|
124
|
+
if (libPkgJson?.version) {
|
|
125
|
+
version = libPkgJson.version;
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
// Library has no version, treat as no version requirement
|
|
129
|
+
version = null;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
// Can't find library package.json, treat as no version requirement
|
|
134
|
+
version = null;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
// Can't find workspace library, treat as no version requirement
|
|
139
|
+
version = null;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
libraries[libraryName] = {
|
|
143
|
+
...(version
|
|
144
|
+
? { requiredVersion: version, singleton: true }
|
|
145
|
+
: { requiredVersion: false }),
|
|
146
|
+
eager,
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
return libraries;
|
|
99
150
|
},
|
|
100
151
|
getReplacementPlugin: () => new normalModuleReplacementPluginImpl(/./, (req) => {
|
|
101
152
|
if (!req.request.startsWith('.')) {
|
|
@@ -149,7 +200,7 @@ function sharePackages(packages) {
|
|
|
149
200
|
const pkgJson = (0, package_json_1.readRootPackageJson)();
|
|
150
201
|
const allPackages = [];
|
|
151
202
|
packages.forEach((pkg) => {
|
|
152
|
-
const pkgVersion =
|
|
203
|
+
const pkgVersion = (0, devkit_1.getDependencyVersionFromPackageJson)(pkg, devkit_1.workspaceRoot, pkgJson);
|
|
153
204
|
allPackages.push({ name: pkg, version: pkgVersion });
|
|
154
205
|
(0, secondary_entry_points_1.collectPackageSecondaryEntryPoints)(pkg, pkgVersion, allPackages);
|
|
155
206
|
});
|
|
@@ -218,8 +269,7 @@ function addStringDependencyToSharedConfig(sharedConfig, dependency, projectGrap
|
|
|
218
269
|
}
|
|
219
270
|
else if (projectGraph.externalNodes?.[`npm:${dependency}`]) {
|
|
220
271
|
const pkgJson = (0, package_json_1.readRootPackageJson)();
|
|
221
|
-
const config = getNpmPackageSharedConfig(dependency,
|
|
222
|
-
pkgJson.devDependencies?.[dependency]);
|
|
272
|
+
const config = getNpmPackageSharedConfig(dependency, (0, devkit_1.getDependencyVersionFromPackageJson)(dependency, devkit_1.workspaceRoot, pkgJson));
|
|
223
273
|
if (!config) {
|
|
224
274
|
return;
|
|
225
275
|
}
|