@module-federation/sdk 0.0.0-next-20240701075157 → 0.0.0-next-20240701101956

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/dist/index.cjs.js CHANGED
@@ -30,6 +30,13 @@ const MFModuleType = {
30
30
  };
31
31
  const MODULE_DEVTOOL_IDENTIFIER = '__MF_DEVTOOLS_MODULE_INFO__';
32
32
  const ENCODE_NAME_PREFIX = 'ENCODE_NAME_PREFIX';
33
+ const MFPrefetchCommon = {
34
+ identifier: 'MFDataPrefetch',
35
+ globalKey: '__PREFETCH__',
36
+ library: 'mf-data-prefetch',
37
+ exportsKey: '__PREFETCH_EXPORTS__',
38
+ fileName: 'bootstrap.js'
39
+ };
33
40
 
34
41
  var ContainerPlugin = /*#__PURE__*/Object.freeze({
35
42
  __proto__: null
@@ -336,7 +343,7 @@ function generateSnapshotFromManifest(manifest, options = {}) {
336
343
  // overrides will override dependencies
337
344
  matchedVersion: overridesKeys.includes(key) ? overrides[key] : remotes[key]
338
345
  });
339
- const { remoteEntry: { path: remoteEntryPath, name: remoteEntryName, type: remoteEntryType }, types: remoteTypes, buildInfo: { buildVersion }, globalName, ssrRemoteEntry } = manifest.metaData;
346
+ const { remoteEntry: { path: remoteEntryPath, name: remoteEntryName, type: remoteEntryType }, types: remoteTypes, buildInfo: { buildVersion }, globalName } = manifest.metaData;
340
347
  const { exposes } = manifest;
341
348
  let basicRemoteSnapshot = {
342
349
  version: version ? version : '',
@@ -381,11 +388,6 @@ function generateSnapshotFromManifest(manifest, options = {}) {
381
388
  getPublicPath: getPublicPath()
382
389
  });
383
390
  }
384
- if (ssrRemoteEntry) {
385
- const fullSSRRemoteEntry = simpleJoinRemoteEntry(ssrRemoteEntry.path, ssrRemoteEntry.name);
386
- remoteSnapshot.ssrRemoteEntry = fullSSRRemoteEntry;
387
- remoteSnapshot.ssrRemoteEntryType = 'commonjs-module';
388
- }
389
391
  return remoteSnapshot;
390
392
  }
391
393
  function isManifestProvider(moduleInfo) {
@@ -435,7 +437,7 @@ function createScript(info) {
435
437
  script.type = 'text/javascript';
436
438
  script.src = info.url;
437
439
  if (info.createScriptHook) {
438
- const createScriptRes = info.createScriptHook(info.url);
440
+ const createScriptRes = info.createScriptHook(info.url, info.attrs);
439
441
  if (createScriptRes instanceof HTMLScriptElement) {
440
442
  script = createScriptRes;
441
443
  } else if (typeof createScriptRes === 'object') {
@@ -653,7 +655,7 @@ function createScriptNode(url, cb, attrs, createScriptHook) {
653
655
  }
654
656
  cb(undefined, exportedInterface);
655
657
  } catch (e) {
656
- cb(e instanceof Error ? e : new Error(`Script execution error: ${e}`));
658
+ cb(new Error(`Script execution error: ${e}`));
657
659
  }
658
660
  };
659
661
  getFetch().then((f)=>handleScriptFetch(f, urlObj)).catch((err)=>{
@@ -705,6 +707,7 @@ exports.FederationModuleManifest = FederationModuleManifest;
705
707
  exports.Logger = Logger;
706
708
  exports.MANIFEST_EXT = MANIFEST_EXT;
707
709
  exports.MFModuleType = MFModuleType;
710
+ exports.MFPrefetchCommon = MFPrefetchCommon;
708
711
  exports.MODULE_DEVTOOL_IDENTIFIER = MODULE_DEVTOOL_IDENTIFIER;
709
712
  exports.ManifestFileName = ManifestFileName;
710
713
  exports.NameTransformMap = NameTransformMap;
package/dist/index.esm.js CHANGED
@@ -26,6 +26,13 @@ const MFModuleType = {
26
26
  };
27
27
  const MODULE_DEVTOOL_IDENTIFIER = '__MF_DEVTOOLS_MODULE_INFO__';
28
28
  const ENCODE_NAME_PREFIX = 'ENCODE_NAME_PREFIX';
29
+ const MFPrefetchCommon = {
30
+ identifier: 'MFDataPrefetch',
31
+ globalKey: '__PREFETCH__',
32
+ library: 'mf-data-prefetch',
33
+ exportsKey: '__PREFETCH_EXPORTS__',
34
+ fileName: 'bootstrap.js'
35
+ };
29
36
 
30
37
  var ContainerPlugin = /*#__PURE__*/Object.freeze({
31
38
  __proto__: null
@@ -332,7 +339,7 @@ function generateSnapshotFromManifest(manifest, options = {}) {
332
339
  // overrides will override dependencies
333
340
  matchedVersion: overridesKeys.includes(key) ? overrides[key] : remotes[key]
334
341
  });
335
- const { remoteEntry: { path: remoteEntryPath, name: remoteEntryName, type: remoteEntryType }, types: remoteTypes, buildInfo: { buildVersion }, globalName, ssrRemoteEntry } = manifest.metaData;
342
+ const { remoteEntry: { path: remoteEntryPath, name: remoteEntryName, type: remoteEntryType }, types: remoteTypes, buildInfo: { buildVersion }, globalName } = manifest.metaData;
336
343
  const { exposes } = manifest;
337
344
  let basicRemoteSnapshot = {
338
345
  version: version ? version : '',
@@ -377,11 +384,6 @@ function generateSnapshotFromManifest(manifest, options = {}) {
377
384
  getPublicPath: getPublicPath()
378
385
  });
379
386
  }
380
- if (ssrRemoteEntry) {
381
- const fullSSRRemoteEntry = simpleJoinRemoteEntry(ssrRemoteEntry.path, ssrRemoteEntry.name);
382
- remoteSnapshot.ssrRemoteEntry = fullSSRRemoteEntry;
383
- remoteSnapshot.ssrRemoteEntryType = 'commonjs-module';
384
- }
385
387
  return remoteSnapshot;
386
388
  }
387
389
  function isManifestProvider(moduleInfo) {
@@ -431,7 +433,7 @@ function createScript(info) {
431
433
  script.type = 'text/javascript';
432
434
  script.src = info.url;
433
435
  if (info.createScriptHook) {
434
- const createScriptRes = info.createScriptHook(info.url);
436
+ const createScriptRes = info.createScriptHook(info.url, info.attrs);
435
437
  if (createScriptRes instanceof HTMLScriptElement) {
436
438
  script = createScriptRes;
437
439
  } else if (typeof createScriptRes === 'object') {
@@ -649,7 +651,7 @@ function createScriptNode(url, cb, attrs, createScriptHook) {
649
651
  }
650
652
  cb(undefined, exportedInterface);
651
653
  } catch (e) {
652
- cb(e instanceof Error ? e : new Error(`Script execution error: ${e}`));
654
+ cb(new Error(`Script execution error: ${e}`));
653
655
  }
654
656
  };
655
657
  getFetch().then((f)=>handleScriptFetch(f, urlObj)).catch((err)=>{
@@ -693,4 +695,4 @@ function normalizeOptions(enableDefault, defaultOptions, key) {
693
695
  };
694
696
  }
695
697
 
696
- export { BROWSER_LOG_KEY, BROWSER_LOG_VALUE, ENCODE_NAME_PREFIX, EncodedNameTransformMap, FederationModuleManifest, Logger, MANIFEST_EXT, MFModuleType, MODULE_DEVTOOL_IDENTIFIER, ManifestFileName, NameTransformMap, NameTransformSymbol, SEPARATOR, StatsFileName, assert, composeKeyWithSeparator, ContainerPlugin as containerPlugin, ContainerReferencePlugin as containerReferencePlugin, createLink, createScript, createScriptNode, decodeName, encodeName, error, generateExposeFilename, generateShareFilename, generateSnapshotFromManifest, getProcessEnv, getResourceUrl, inferAutoPublicPath, isBrowserEnv, isDebugMode, isManifestProvider, isStaticResourcesEqual, loadScript, loadScriptNode, logger, ModuleFederationPlugin as moduleFederationPlugin, normalizeOptions, parseEntry, safeWrapper, SharePlugin as sharePlugin, simpleJoinRemoteEntry, warn };
698
+ export { BROWSER_LOG_KEY, BROWSER_LOG_VALUE, ENCODE_NAME_PREFIX, EncodedNameTransformMap, FederationModuleManifest, Logger, MANIFEST_EXT, MFModuleType, MFPrefetchCommon, MODULE_DEVTOOL_IDENTIFIER, ManifestFileName, NameTransformMap, NameTransformSymbol, SEPARATOR, StatsFileName, assert, composeKeyWithSeparator, ContainerPlugin as containerPlugin, ContainerReferencePlugin as containerReferencePlugin, createLink, createScript, createScriptNode, decodeName, encodeName, error, generateExposeFilename, generateShareFilename, generateSnapshotFromManifest, getProcessEnv, getResourceUrl, inferAutoPublicPath, isBrowserEnv, isDebugMode, isManifestProvider, isStaticResourcesEqual, loadScript, loadScriptNode, logger, ModuleFederationPlugin as moduleFederationPlugin, normalizeOptions, parseEntry, safeWrapper, SharePlugin as sharePlugin, simpleJoinRemoteEntry, warn };
@@ -22,3 +22,10 @@ export declare const MFModuleType: {
22
22
  };
23
23
  export declare const MODULE_DEVTOOL_IDENTIFIER = "__MF_DEVTOOLS_MODULE_INFO__";
24
24
  export declare const ENCODE_NAME_PREFIX = "ENCODE_NAME_PREFIX";
25
+ export declare const MFPrefetchCommon: {
26
+ identifier: string;
27
+ globalKey: string;
28
+ library: string;
29
+ exportsKey: string;
30
+ fileName: string;
31
+ };
package/dist/src/dom.d.ts CHANGED
@@ -9,7 +9,7 @@ export declare function createScript(info: {
9
9
  cb?: (value: void | PromiseLike<void>) => void;
10
10
  attrs?: Record<string, any>;
11
11
  needDeleteScript?: boolean;
12
- createScriptHook?: (url: string) => CreateScriptHookReturn;
12
+ createScriptHook?: (url: string, attrs?: Record<string, any> | undefined) => CreateScriptHookReturn;
13
13
  }): {
14
14
  script: HTMLScriptElement;
15
15
  needAttach: boolean;
@@ -26,5 +26,5 @@ export declare function createLink(info: {
26
26
  };
27
27
  export declare function loadScript(url: string, info: {
28
28
  attrs?: Record<string, any>;
29
- createScriptHook?: (url: string) => CreateScriptHookReturn;
29
+ createScriptHook?: (url: string, attrs?: Record<string, any> | undefined) => CreateScriptHookReturn;
30
30
  }): Promise<void>;
@@ -65,6 +65,10 @@ export type Shared = (SharedItem | SharedObject)[] | SharedObject;
65
65
  * A module that should be shared in the share scope.
66
66
  */
67
67
  export type SharedItem = string;
68
+ /**
69
+ * Enable Data Prefetch
70
+ */
71
+ export type DataPrefetch = boolean;
68
72
  export interface AdditionalDataOptions {
69
73
  stats: Stats;
70
74
  manifest?: Manifest;
@@ -91,7 +95,6 @@ export interface DtsHostOptions {
91
95
  deleteTypesFolder?: boolean;
92
96
  maxRetries?: number;
93
97
  consumeAPITypes?: boolean;
94
- runtimePkgs?: string[];
95
98
  }
96
99
  export interface DtsRemoteOptions {
97
100
  tsConfigPath?: string;
@@ -113,10 +116,6 @@ export interface PluginDtsOptions {
113
116
  extraOptions?: Record<string, any>;
114
117
  implementation?: string;
115
118
  }
116
- export type AsyncBoundaryOptions = {
117
- eager?: RegExp | ((module: any) => boolean);
118
- excludeChunk?: (chunk: any) => boolean;
119
- };
120
119
  export interface ModuleFederationPluginOptions {
121
120
  /**
122
121
  * Modules that should be exposed by this container. When provided, property name is used as public name, otherwise public name is automatically inferred from request.
@@ -169,7 +168,7 @@ export interface ModuleFederationPluginOptions {
169
168
  manifest?: boolean | PluginManifestOptions;
170
169
  dev?: boolean | PluginDevOptions;
171
170
  dts?: boolean | PluginDtsOptions;
172
- async?: boolean | AsyncBoundaryOptions;
171
+ dataPrefetch?: DataPrefetch;
173
172
  }
174
173
  /**
175
174
  * Modules that should be exposed by this container. Property names are used as public paths.
@@ -23,8 +23,6 @@ interface BasicModuleInfo {
23
23
  export interface BasicProviderModuleInfo extends BasicModuleInfo {
24
24
  remoteEntry: string;
25
25
  remoteEntryType: RemoteEntryType;
26
- ssrRemoteEntry?: string;
27
- ssrRemoteEntryType?: RemoteEntryType;
28
26
  remoteManifest?: string;
29
27
  globalName: string;
30
28
  modules: Array<{
@@ -44,7 +42,6 @@ interface BasicProviderModuleInfoWithGetPublicPath extends BasicProviderModuleIn
44
42
  }
45
43
  export interface ManifestProvider {
46
44
  remoteEntry: string;
47
- ssrRemoteEntry?: string;
48
45
  version?: string;
49
46
  }
50
47
  export interface PureEntryProvider extends ManifestProvider {
@@ -1,6 +1,6 @@
1
1
  import type { RemoteWithEntry, RemoteWithVersion } from './common';
2
2
  export type RemoteEntryType = 'var' | 'module' | 'assign' | 'assign-properties' | 'this' | 'window' | 'self' | 'global' | 'commonjs' | 'commonjs2' | 'commonjs-module' | 'commonjs-static' | 'amd' | 'amd-require' | 'umd' | 'umd2' | 'jsonp' | 'system' | string;
3
- export interface ResourceInfo {
3
+ interface ResourceInfo {
4
4
  path: string;
5
5
  name: string;
6
6
  type: RemoteEntryType;
@@ -20,7 +20,6 @@ export interface BasicStatsMetaData {
20
20
  globalName: string;
21
21
  buildInfo: StatsBuildInfo;
22
22
  remoteEntry: ResourceInfo;
23
- ssrRemoteEntry?: ResourceInfo;
24
23
  prefetchInterface?: boolean;
25
24
  prefetchEntry?: ResourceInfo;
26
25
  types: MetaDataTypes;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/sdk",
3
- "version": "0.0.0-next-20240701075157",
3
+ "version": "0.0.0-next-20240701101956",
4
4
  "license": "MIT",
5
5
  "description": "A sdk for support module federation",
6
6
  "keywords": [