@nx/module-federation 23.3.0-beta.7 → 23.3.0-beta.8

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
@@ -12,7 +12,7 @@
12
12
  [![Semantic Release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=flat-square)](<>)
13
13
  [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
14
14
  [![Join us on the Official Nx Discord Server](https://img.shields.io/discord/1143497901675401286?label=discord)](https://go.nx.dev/community)
15
- [![Nx Sandboxing](https://staging.nx.app/workspaces/62d013ea0852fe0a2df74438/sandbox-badge.svg)](https://nx.dev/docs/features/ci-features/sandboxing)
15
+ [![Hours saved](https://img.shields.io/endpoint?url=https%3A%2F%2Fstaging.nx.app%2Fnx-cloud%2Fbadge%2F62d013ea0852fe0a2df74438%2Fhours-saved.json)](https://nx.dev/nx-cloud)
16
16
 
17
17
  </div>
18
18
 
@@ -28,11 +28,12 @@ function buildModuleFederationConfig(mfConfig, options, frameworkConfig, project
28
28
  dependencies.npmPackages = dependencies.npmPackages.filter((pkg) => mfConfig.shared(pkg, {}) !== false);
29
29
  }
30
30
  const sharedLibraries = (0, index_1.shareWorkspaceLibraries)(dependencies.workspaceLibraries, undefined, bundler);
31
- // Build npm packages list with framework-specific defaults
31
+ // Build npm packages list with framework-specific defaults. Undeclared defaults
32
+ // are dropped; a real project dependency still warns when its version is missing.
32
33
  let npmPackagesList = dependencies.npmPackages;
33
34
  if (defaultPackagesToShare.length > 0 || packagesToAvoid.length > 0) {
34
35
  npmPackagesList = Array.from(new Set([
35
- ...defaultPackagesToShare,
36
+ ...(0, index_1.filterPackagesDeclaredInRootPackageJson)(defaultPackagesToShare),
36
37
  ...dependencies.npmPackages.filter((pkg) => !packagesToAvoid.includes(pkg)),
37
38
  ]));
38
39
  }
@@ -17,6 +17,15 @@ export declare function shareWorkspaceLibraries(workspaceLibs: WorkspaceLibrary[
17
17
  * @param version - Version of the package to require by other apps in the Module Federation setup
18
18
  */
19
19
  export declare function getNpmPackageSharedConfig(pkgName: string, version: string): SharedLibraryConfig | undefined;
20
+ /**
21
+ * Narrow a list of package names down to those with a version declared in the
22
+ * root package.json.
23
+ *
24
+ * Version resolution matches {@link sharePackages}, so a package kept here never
25
+ * trips the missing-version warning in {@link getNpmPackageSharedConfig}.
26
+ * @param packages - Array of package names as strings
27
+ */
28
+ export declare function filterPackagesDeclaredInRootPackageJson(packages: string[]): string[];
20
29
  /**
21
30
  * Create a dictionary of packages and their Module Federation Shared Config
22
31
  * from an array of package names.
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.shareWorkspaceLibraries = shareWorkspaceLibraries;
4
4
  exports.getNpmPackageSharedConfig = getNpmPackageSharedConfig;
5
+ exports.filterPackagesDeclaredInRootPackageJson = filterPackagesDeclaredInRootPackageJson;
5
6
  exports.sharePackages = sharePackages;
6
7
  exports.applySharedFunction = applySharedFunction;
7
8
  exports.applyAdditionalShared = applyAdditionalShared;
@@ -213,6 +214,21 @@ function getNpmPackageSharedConfig(pkgName, version) {
213
214
  }
214
215
  return { singleton: true, strictVersion: true, requiredVersion: version };
215
216
  }
217
+ /**
218
+ * Narrow a list of package names down to those with a version declared in the
219
+ * root package.json.
220
+ *
221
+ * Version resolution matches {@link sharePackages}, so a package kept here never
222
+ * trips the missing-version warning in {@link getNpmPackageSharedConfig}.
223
+ * @param packages - Array of package names as strings
224
+ */
225
+ function filterPackagesDeclaredInRootPackageJson(packages) {
226
+ if (packages.length === 0) {
227
+ return [];
228
+ }
229
+ const pkgJson = (0, package_json_1.readRootPackageJson)();
230
+ return packages.filter((pkg) => Boolean((0, devkit_1.getDependencyVersionFromPackageJson)(pkg, devkit_1.workspaceRoot, pkgJson)));
231
+ }
216
232
  /**
217
233
  * Create a dictionary of packages and their Module Federation Shared Config
218
234
  * from an array of package names.
@@ -1,6 +1,7 @@
1
1
  import { ModuleFederationConfig, SharedLibraryConfig } from '../../utils';
2
2
  /**
3
- * Default npm packages to always share for Angular projects.
3
+ * Default npm packages to share for Angular projects, each shared only when the
4
+ * workspace declares it in the root package.json.
4
5
  */
5
6
  export declare const DEFAULT_ANGULAR_PACKAGES_TO_SHARE: string[];
6
7
  /**
@@ -7,7 +7,8 @@ exports.getModuleFederationConfig = getModuleFederationConfig;
7
7
  exports.getModuleFederationConfigSync = getModuleFederationConfigSync;
8
8
  const module_federation_config_1 = require("../../utils/module-federation-config");
9
9
  /**
10
- * Default npm packages to always share for Angular projects.
10
+ * Default npm packages to share for Angular projects, each shared only when the
11
+ * workspace declares it in the root package.json.
11
12
  */
12
13
  exports.DEFAULT_ANGULAR_PACKAGES_TO_SHARE = [
13
14
  '@angular/core',
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": "23.3.0-beta.7",
4
+ "version": "23.3.0-beta.8",
5
5
  "type": "commonjs",
6
6
  "files": [
7
7
  "dist",
@@ -124,9 +124,9 @@
124
124
  },
125
125
  "executors": "./executors.json",
126
126
  "dependencies": {
127
- "@nx/devkit": "23.3.0-beta.7",
128
- "@nx/js": "23.3.0-beta.7",
129
- "@nx/web": "23.3.0-beta.7",
127
+ "@nx/devkit": "23.3.0-beta.8",
128
+ "@nx/js": "23.3.0-beta.8",
129
+ "@nx/web": "23.3.0-beta.8",
130
130
  "@rspack/core": "^2.0.4",
131
131
  "express": "^4.21.2",
132
132
  "http-proxy-middleware": "^3.0.7",
@@ -150,7 +150,7 @@
150
150
  }
151
151
  },
152
152
  "devDependencies": {
153
- "nx": "23.3.0-beta.7",
153
+ "nx": "23.3.0-beta.8",
154
154
  "webpack": "5.109.2"
155
155
  },
156
156
  "nx-migrations": {