@nx/module-federation 22.0.0-beta.4 → 22.0.0-beta.5

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",
4
+ "version": "22.0.0-beta.5",
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.4",
31
- "@nx/js": "22.0.0-beta.4",
32
- "@nx/web": "22.0.0-beta.4",
30
+ "@nx/devkit": "22.0.0-beta.5",
31
+ "@nx/js": "22.0.0-beta.5",
32
+ "@nx/web": "22.0.0-beta.5",
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.4"
41
+ "nx": "22.0.0-beta.5"
42
42
  },
43
43
  "nx-migrations": {
44
44
  "migrations": "./migrations.json"
@@ -53,5 +53,7 @@ function getLibraryImportPath(library, projectGraph) {
53
53
  }
54
54
  }
55
55
  }
56
- return undefined;
56
+ // Return library name if not found in TS path mappings
57
+ // This supports TS Solution + PM Workspaces where libs use package.json instead
58
+ return library;
57
59
  }
@@ -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,EAKlB,MAAM,YAAY,CAAC;AAKpB;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CACrC,aAAa,EAAE,gBAAgB,EAAE,EACjC,YAAY,SAAwD,EACpE,OAAO,GAAE,QAAQ,GAAG,SAAoB,GACvC,4BAA4B,CA8I9B;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,CAkBrC;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"}
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,EAKlB,MAAM,YAAY,CAAC;AAKpB;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CACrC,aAAa,EAAE,gBAAgB,EAAE,EACjC,YAAY,SAAwD,EACpE,OAAO,GAAE,QAAQ,GAAG,SAAoB,GACvC,4BAA4B,CA0M9B;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,CAkBrC;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"}
@@ -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,7 +75,7 @@ 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
- return pathMappings.reduce((libraries, library) => {
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
80
  let version = pkgJson?.dependencies?.[library.name];
74
81
  if (!version && workspaceLibs.length > 0) {
@@ -96,6 +103,48 @@ function shareWorkspaceLibraries(workspaceLibs, tsConfigPath = process.env.NX_TS
96
103
  },
97
104
  };
98
105
  }, {});
106
+ // Add workspace libs from package.json dependencies
107
+ // This supports TS Solution + PM Workspaces
108
+ for (const libraryName of workspaceLibrariesAsDeps) {
109
+ let version = pkgJson?.dependencies?.[libraryName] ??
110
+ pkgJson?.devDependencies?.[libraryName];
111
+ // Normalize workspace protocol versions (workspace:*, workspace:^, *, etc.)
112
+ if (version &&
113
+ (version === '*' ||
114
+ version.startsWith('workspace:') ||
115
+ version.startsWith('file:'))) {
116
+ // Look up the actual version from the library's package.json
117
+ const workspaceLib = workspaceLibs.find((lib) => lib.importKey === libraryName);
118
+ if (workspaceLib) {
119
+ const libPackageJsonPath = (0, path_1.join)(devkit_1.workspaceRoot, workspaceLib.root, 'package.json');
120
+ if ((0, fs_1.existsSync)(libPackageJsonPath)) {
121
+ const libPkgJson = (0, devkit_1.readJsonFile)(libPackageJsonPath);
122
+ if (libPkgJson?.version) {
123
+ version = libPkgJson.version;
124
+ }
125
+ else {
126
+ // Library has no version, treat as no version requirement
127
+ version = null;
128
+ }
129
+ }
130
+ else {
131
+ // Can't find library package.json, treat as no version requirement
132
+ version = null;
133
+ }
134
+ }
135
+ else {
136
+ // Can't find workspace library, treat as no version requirement
137
+ version = null;
138
+ }
139
+ }
140
+ libraries[libraryName] = {
141
+ ...(version
142
+ ? { requiredVersion: version, singleton: true }
143
+ : { requiredVersion: false }),
144
+ eager,
145
+ };
146
+ }
147
+ return libraries;
99
148
  },
100
149
  getReplacementPlugin: () => new normalModuleReplacementPluginImpl(/./, (req) => {
101
150
  if (!req.request.startsWith('.')) {