@module-federation/manifest 2.7.0 → 2.8.0

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.
@@ -1,5 +1,5 @@
1
1
  import { StatsExpose, StatsRemote, StatsShared, moduleFederationPlugin } from '@module-federation/sdk';
2
- import type { StatsModule } from '../../../webpack/lib/stats/DefaultStatsFactoryPlugin';
2
+ import type { StatsModule } from 'webpack/lib/stats/DefaultStatsFactoryPlugin';
3
3
  import type managerTypes from '@module-federation/managers';
4
4
  export declare const getExposeName: (exposeKey: string) => string;
5
5
  export declare function getExposeItem({ exposeKey, name, file, }: {
@@ -75,6 +75,7 @@ const external_utils_js_namespaceObject = require("./utils.js");
75
75
 
76
76
 
77
77
 
78
+ const REMOTE_REFERENCE_PREFIX = /^(?:webpack|rspack)\/container\/reference\//;
78
79
  const isNonEmptyString = (value)=>{
79
80
  return typeof value === 'string' && value.trim().length > 0;
80
81
  };
@@ -328,11 +329,11 @@ class ModuleHandler {
328
329
  return;
329
330
  }
330
331
  const remoteManagerNormalizedOptions = this._remoteManager.normalizedOptions;
331
- // identifier = remote (default) webpack/container/reference/app2 ./Button
332
+ // identifier = remote (default) [webpack|rspack]/container/reference/app2 ./Button
332
333
  const data = identifier.split(' ');
333
334
  if (data.length === 4) {
334
335
  const moduleName = data[3].replace('./', '');
335
- const remoteAlias = data[2].replace('webpack/container/reference/', '');
336
+ const remoteAlias = data[2].replace(REMOTE_REFERENCE_PREFIX, '');
336
337
  const normalizedRemote = remoteManagerNormalizedOptions[remoteAlias];
337
338
  const basicRemote = {
338
339
  alias: normalizedRemote.alias,
@@ -11,6 +11,7 @@ import { getFileNameWithOutExt } from "./utils.mjs";
11
11
 
12
12
 
13
13
 
14
+ const REMOTE_REFERENCE_PREFIX = /^(?:webpack|rspack)\/container\/reference\//;
14
15
  const isNonEmptyString = (value)=>{
15
16
  return typeof value === 'string' && value.trim().length > 0;
16
17
  };
@@ -264,11 +265,11 @@ class ModuleHandler {
264
265
  return;
265
266
  }
266
267
  const remoteManagerNormalizedOptions = this._remoteManager.normalizedOptions;
267
- // identifier = remote (default) webpack/container/reference/app2 ./Button
268
+ // identifier = remote (default) [webpack|rspack]/container/reference/app2 ./Button
268
269
  const data = identifier.split(' ');
269
270
  if (data.length === 4) {
270
271
  const moduleName = data[3].replace('./', '');
271
- const remoteAlias = data[2].replace('webpack/container/reference/', '');
272
+ const remoteAlias = data[2].replace(REMOTE_REFERENCE_PREFIX, '');
272
273
  const normalizedRemote = remoteManagerNormalizedOptions[remoteAlias];
273
274
  const basicRemote = {
274
275
  alias: normalizedRemote.alias,
@@ -140,7 +140,7 @@ class StatsManager {
140
140
  remoteEntry: {
141
141
  name: getRemoteEntryName(),
142
142
  path: '',
143
- // same as the types supported by runtime, currently only global/var/script is supported
143
+ // The runtime loader type follows the configured container library type.
144
144
  type: this._options?.library?.type || 'global'
145
145
  },
146
146
  types: (0,external_utils_js_namespaceObject.getTypesMetaInfo)(this._options, compiler.context),
@@ -488,6 +488,13 @@ class StatsManager {
488
488
  }
489
489
  updateStats(stats, compiler) {
490
490
  const { metaData } = stats;
491
+ const configuredRemoteEntryType = this._options.library?.type;
492
+ if (configuredRemoteEntryType && metaData.remoteEntry) {
493
+ // Rspack may pre-emit stats with the default `global` type even when
494
+ // the configured container library and emitted remote entry are ESM.
495
+ // The configured library is authoritative for runtime loader selection.
496
+ metaData.remoteEntry.type = configuredRemoteEntryType;
497
+ }
491
498
  if (!metaData.types) {
492
499
  metaData.types = (0,external_utils_js_namespaceObject.getTypesMetaInfo)(this._options, compiler.context);
493
500
  }
@@ -79,7 +79,7 @@ class StatsManager {
79
79
  remoteEntry: {
80
80
  name: getRemoteEntryName(),
81
81
  path: '',
82
- // same as the types supported by runtime, currently only global/var/script is supported
82
+ // The runtime loader type follows the configured container library type.
83
83
  type: this._options?.library?.type || 'global'
84
84
  },
85
85
  types: getTypesMetaInfo(this._options, compiler.context),
@@ -427,6 +427,13 @@ class StatsManager {
427
427
  }
428
428
  updateStats(stats, compiler) {
429
429
  const { metaData } = stats;
430
+ const configuredRemoteEntryType = this._options.library?.type;
431
+ if (configuredRemoteEntryType && metaData.remoteEntry) {
432
+ // Rspack may pre-emit stats with the default `global` type even when
433
+ // the configured container library and emitted remote entry are ESM.
434
+ // The configured library is authoritative for runtime loader selection.
435
+ metaData.remoteEntry.type = configuredRemoteEntryType;
436
+ }
430
437
  if (!metaData.types) {
431
438
  metaData.types = getTypesMetaInfo(this._options, compiler.context);
432
439
  }
package/dist/utils.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Chunk, Compilation } from 'webpack';
2
- import type { StatsCompilation, StatsModule } from '../../../webpack/lib/stats/DefaultStatsFactoryPlugin';
2
+ import type { StatsCompilation, StatsModule } from 'webpack/lib/stats/DefaultStatsFactoryPlugin';
3
3
  import { StatsAssets, moduleFederationPlugin, MetaDataTypes } from '@module-federation/sdk';
4
4
  export declare function getAssetsByChunkIDs(compilation: Compilation, chunkIDMap: Record<string, Set<string | number>>): Record<string, {
5
5
  js: string[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/manifest",
3
- "version": "2.7.0",
3
+ "version": "2.8.0",
4
4
  "license": "MIT",
5
5
  "description": "Provide manifest/stats for webpack/rspack MF project .",
6
6
  "keywords": [
@@ -27,9 +27,9 @@
27
27
  "module": "./dist/index.mjs",
28
28
  "types": "./dist/index.d.ts",
29
29
  "dependencies": {
30
- "@module-federation/sdk": "2.7.0",
31
- "@module-federation/managers": "2.7.0",
32
- "@module-federation/dts-plugin": "2.7.0"
30
+ "@module-federation/sdk": "2.8.0",
31
+ "@module-federation/dts-plugin": "2.8.0",
32
+ "@module-federation/managers": "2.8.0"
33
33
  },
34
34
  "exports": {
35
35
  ".": {
@@ -51,7 +51,7 @@
51
51
  }
52
52
  },
53
53
  "devDependencies": {
54
- "typescript": "6.0.3",
54
+ "typescript": "7.0.2",
55
55
  "webpack": "^5.0.0"
56
56
  },
57
57
  "scripts": {