@module-federation/sdk 0.0.0-next-20240205220829 → 0.0.0-next-20240223065734

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
@@ -29,6 +29,29 @@ var NameTransformMap = (_obj = {}, _define_property$2(_obj, NameTransformSymbol.
29
29
  var _obj1;
30
30
  var EncodedNameTransformMap = (_obj1 = {}, _define_property$2(_obj1, NameTransformMap[NameTransformSymbol.AT], NameTransformSymbol.AT), _define_property$2(_obj1, NameTransformMap[NameTransformSymbol.HYPHEN], NameTransformSymbol.HYPHEN), _define_property$2(_obj1, NameTransformMap[NameTransformSymbol.SLASH], NameTransformSymbol.SLASH), _obj1);
31
31
  var SEPARATOR = ":";
32
+ var ManifestFileName = "mf-manifest.json";
33
+ var StatsFileName = "mf-stats.json";
34
+ exports.ModuleType = void 0;
35
+ (function(ModuleType) {
36
+ ModuleType["NPM"] = "npm";
37
+ ModuleType["APP"] = "app";
38
+ })(exports.ModuleType || (exports.ModuleType = {}));
39
+
40
+ var ContainerPlugin = /*#__PURE__*/Object.freeze({
41
+ __proto__: null
42
+ });
43
+
44
+ var ContainerReferencePlugin = /*#__PURE__*/Object.freeze({
45
+ __proto__: null
46
+ });
47
+
48
+ var ModuleFederationPlugin = /*#__PURE__*/Object.freeze({
49
+ __proto__: null
50
+ });
51
+
52
+ var SharePlugin = /*#__PURE__*/Object.freeze({
53
+ __proto__: null
54
+ });
32
55
 
33
56
  function isBrowserEnv() {
34
57
  return typeof window !== "undefined";
@@ -490,10 +513,11 @@ function generateSnapshotFromManifest(manifest) {
490
513
  };
491
514
  })
492
515
  };
493
- if ((_manifest_metaData = manifest.metaData) === null || _manifest_metaData === void 0 ? void 0 : _manifest_metaData.prefetchInterface) {
494
- var prefetchInterface = manifest.metaData.prefetchInterface;
516
+ if ((_manifest_metaData = manifest.metaData) === null || _manifest_metaData === void 0 ? void 0 : _manifest_metaData.prefetchEntry) {
517
+ var _manifest_metaData_prefetchEntry = manifest.metaData.prefetchEntry, path = _manifest_metaData_prefetchEntry.path, name = _manifest_metaData_prefetchEntry.name, type = _manifest_metaData_prefetchEntry.type;
495
518
  basicRemoteSnapshot = _object_spread_props(_object_spread({}, basicRemoteSnapshot), {
496
- prefetchInterface: prefetchInterface
519
+ prefetchEntry: simpleJoinRemoteEntry(path, name),
520
+ prefetchEntryType: type
497
521
  });
498
522
  }
499
523
  if ("publicPath" in manifest.metaData) {
@@ -756,6 +780,63 @@ function createScript(url, cb, attrs, createScriptHook) {
756
780
  needAttach: needAttach
757
781
  };
758
782
  }
783
+ function createLink(url, cb, attrs, createLinkHook) {
784
+ // <link rel="preload" href="script.js" as="script">
785
+ // Retrieve the existing script element by its src attribute
786
+ var link = null;
787
+ var needAttach = true;
788
+ var links = document.getElementsByTagName("link");
789
+ for(var i = 0; i < links.length; i++){
790
+ var l = links[i];
791
+ var linkHref = l.getAttribute("href");
792
+ if (linkHref && isStaticResourcesEqual(linkHref, url)) {
793
+ link = l;
794
+ needAttach = false;
795
+ break;
796
+ }
797
+ }
798
+ if (!link) {
799
+ link = document.createElement("link");
800
+ link.setAttribute("href", url);
801
+ if (createLinkHook) {
802
+ var createLinkRes = createLinkHook(url);
803
+ if (_instanceof(createLinkRes, HTMLLinkElement)) {
804
+ link = createLinkRes;
805
+ }
806
+ }
807
+ }
808
+ if (attrs) {
809
+ Object.keys(attrs).forEach(function(name) {
810
+ if (link) {
811
+ link.setAttribute(name, attrs[name]);
812
+ }
813
+ });
814
+ }
815
+ var onLinkComplete = function(prev, // eslint-disable-next-line @typescript-eslint/no-explicit-any
816
+ event) {
817
+ // Prevent memory leaks in IE.
818
+ if (link) {
819
+ link.onerror = null;
820
+ link.onload = null;
821
+ safeWrapper(function() {
822
+ (link === null || link === void 0 ? void 0 : link.parentNode) && link.parentNode.removeChild(link);
823
+ });
824
+ if (prev) {
825
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
826
+ var res = prev(event);
827
+ cb();
828
+ return res;
829
+ }
830
+ }
831
+ cb();
832
+ };
833
+ link.onerror = onLinkComplete.bind(null, link.onerror);
834
+ link.onload = onLinkComplete.bind(null, link.onload);
835
+ return {
836
+ link: link,
837
+ needAttach: needAttach
838
+ };
839
+ }
759
840
  function loadScript(url, info) {
760
841
  var attrs = info.attrs, createScriptHook = info.createScriptHook;
761
842
  return new Promise(function(resolve, _reject) {
@@ -1035,7 +1116,7 @@ function createScriptNode(url, cb, attrs, createScriptHook) {
1035
1116
  script.runInThisContext()(scriptContext.exports, scriptContext.module, eval("require"), urlDirname, filename);
1036
1117
  exportedInterface = scriptContext.module.exports || scriptContext.exports;
1037
1118
  if (attrs && exportedInterface && attrs["globalName"]) {
1038
- container = exportedInterface[attrs["globalName"]];
1119
+ container = exportedInterface[attrs["globalName"]] || exportedInterface;
1039
1120
  cb(undefined, container);
1040
1121
  return [
1041
1122
  2
@@ -1082,11 +1163,16 @@ exports.EncodedNameTransformMap = EncodedNameTransformMap;
1082
1163
  exports.FederationModuleManifest = FederationModuleManifest;
1083
1164
  exports.Logger = Logger;
1084
1165
  exports.MANIFEST_EXT = MANIFEST_EXT;
1166
+ exports.ManifestFileName = ManifestFileName;
1085
1167
  exports.NameTransformMap = NameTransformMap;
1086
1168
  exports.NameTransformSymbol = NameTransformSymbol;
1087
1169
  exports.SEPARATOR = SEPARATOR;
1170
+ exports.StatsFileName = StatsFileName;
1088
1171
  exports.assert = assert;
1089
1172
  exports.composeKeyWithSeparator = composeKeyWithSeparator;
1173
+ exports.containerPlugin = ContainerPlugin;
1174
+ exports.containerReferencePlugin = ContainerReferencePlugin;
1175
+ exports.createLink = createLink;
1090
1176
  exports.createScript = createScript;
1091
1177
  exports.createScriptNode = createScriptNode;
1092
1178
  exports.decodeName = decodeName;
@@ -1104,7 +1190,9 @@ exports.isStaticResourcesEqual = isStaticResourcesEqual;
1104
1190
  exports.loadScript = loadScript;
1105
1191
  exports.loadScriptNode = loadScriptNode;
1106
1192
  exports.logger = logger;
1193
+ exports.moduleFederationPlugin = ModuleFederationPlugin;
1107
1194
  exports.parseEntry = parseEntry;
1108
1195
  exports.safeWrapper = safeWrapper;
1196
+ exports.sharePlugin = SharePlugin;
1109
1197
  exports.simpleJoinRemoteEntry = simpleJoinRemoteEntry;
1110
1198
  exports.warn = warn;
package/dist/index.esm.js CHANGED
@@ -25,6 +25,29 @@ var NameTransformMap = (_obj = {}, _define_property$2(_obj, NameTransformSymbol.
25
25
  var _obj1;
26
26
  var EncodedNameTransformMap = (_obj1 = {}, _define_property$2(_obj1, NameTransformMap[NameTransformSymbol.AT], NameTransformSymbol.AT), _define_property$2(_obj1, NameTransformMap[NameTransformSymbol.HYPHEN], NameTransformSymbol.HYPHEN), _define_property$2(_obj1, NameTransformMap[NameTransformSymbol.SLASH], NameTransformSymbol.SLASH), _obj1);
27
27
  var SEPARATOR = ":";
28
+ var ManifestFileName = "mf-manifest.json";
29
+ var StatsFileName = "mf-stats.json";
30
+ var ModuleType;
31
+ (function(ModuleType) {
32
+ ModuleType["NPM"] = "npm";
33
+ ModuleType["APP"] = "app";
34
+ })(ModuleType || (ModuleType = {}));
35
+
36
+ var ContainerPlugin = /*#__PURE__*/Object.freeze({
37
+ __proto__: null
38
+ });
39
+
40
+ var ContainerReferencePlugin = /*#__PURE__*/Object.freeze({
41
+ __proto__: null
42
+ });
43
+
44
+ var ModuleFederationPlugin = /*#__PURE__*/Object.freeze({
45
+ __proto__: null
46
+ });
47
+
48
+ var SharePlugin = /*#__PURE__*/Object.freeze({
49
+ __proto__: null
50
+ });
28
51
 
29
52
  function isBrowserEnv() {
30
53
  return typeof window !== "undefined";
@@ -486,10 +509,11 @@ function generateSnapshotFromManifest(manifest) {
486
509
  };
487
510
  })
488
511
  };
489
- if ((_manifest_metaData = manifest.metaData) === null || _manifest_metaData === void 0 ? void 0 : _manifest_metaData.prefetchInterface) {
490
- var prefetchInterface = manifest.metaData.prefetchInterface;
512
+ if ((_manifest_metaData = manifest.metaData) === null || _manifest_metaData === void 0 ? void 0 : _manifest_metaData.prefetchEntry) {
513
+ var _manifest_metaData_prefetchEntry = manifest.metaData.prefetchEntry, path = _manifest_metaData_prefetchEntry.path, name = _manifest_metaData_prefetchEntry.name, type = _manifest_metaData_prefetchEntry.type;
491
514
  basicRemoteSnapshot = _object_spread_props(_object_spread({}, basicRemoteSnapshot), {
492
- prefetchInterface: prefetchInterface
515
+ prefetchEntry: simpleJoinRemoteEntry(path, name),
516
+ prefetchEntryType: type
493
517
  });
494
518
  }
495
519
  if ("publicPath" in manifest.metaData) {
@@ -752,6 +776,63 @@ function createScript(url, cb, attrs, createScriptHook) {
752
776
  needAttach: needAttach
753
777
  };
754
778
  }
779
+ function createLink(url, cb, attrs, createLinkHook) {
780
+ // <link rel="preload" href="script.js" as="script">
781
+ // Retrieve the existing script element by its src attribute
782
+ var link = null;
783
+ var needAttach = true;
784
+ var links = document.getElementsByTagName("link");
785
+ for(var i = 0; i < links.length; i++){
786
+ var l = links[i];
787
+ var linkHref = l.getAttribute("href");
788
+ if (linkHref && isStaticResourcesEqual(linkHref, url)) {
789
+ link = l;
790
+ needAttach = false;
791
+ break;
792
+ }
793
+ }
794
+ if (!link) {
795
+ link = document.createElement("link");
796
+ link.setAttribute("href", url);
797
+ if (createLinkHook) {
798
+ var createLinkRes = createLinkHook(url);
799
+ if (_instanceof(createLinkRes, HTMLLinkElement)) {
800
+ link = createLinkRes;
801
+ }
802
+ }
803
+ }
804
+ if (attrs) {
805
+ Object.keys(attrs).forEach(function(name) {
806
+ if (link) {
807
+ link.setAttribute(name, attrs[name]);
808
+ }
809
+ });
810
+ }
811
+ var onLinkComplete = function(prev, // eslint-disable-next-line @typescript-eslint/no-explicit-any
812
+ event) {
813
+ // Prevent memory leaks in IE.
814
+ if (link) {
815
+ link.onerror = null;
816
+ link.onload = null;
817
+ safeWrapper(function() {
818
+ (link === null || link === void 0 ? void 0 : link.parentNode) && link.parentNode.removeChild(link);
819
+ });
820
+ if (prev) {
821
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
822
+ var res = prev(event);
823
+ cb();
824
+ return res;
825
+ }
826
+ }
827
+ cb();
828
+ };
829
+ link.onerror = onLinkComplete.bind(null, link.onerror);
830
+ link.onload = onLinkComplete.bind(null, link.onload);
831
+ return {
832
+ link: link,
833
+ needAttach: needAttach
834
+ };
835
+ }
755
836
  function loadScript(url, info) {
756
837
  var attrs = info.attrs, createScriptHook = info.createScriptHook;
757
838
  return new Promise(function(resolve, _reject) {
@@ -1031,7 +1112,7 @@ function createScriptNode(url, cb, attrs, createScriptHook) {
1031
1112
  script.runInThisContext()(scriptContext.exports, scriptContext.module, eval("require"), urlDirname, filename);
1032
1113
  exportedInterface = scriptContext.module.exports || scriptContext.exports;
1033
1114
  if (attrs && exportedInterface && attrs["globalName"]) {
1034
- container = exportedInterface[attrs["globalName"]];
1115
+ container = exportedInterface[attrs["globalName"]] || exportedInterface;
1035
1116
  cb(undefined, container);
1036
1117
  return [
1037
1118
  2
@@ -1072,4 +1153,4 @@ function loadScriptNode(url, info) {
1072
1153
  });
1073
1154
  }
1074
1155
 
1075
- export { BROWSER_LOG_KEY, BROWSER_LOG_VALUE, EncodedNameTransformMap, FederationModuleManifest, Logger, MANIFEST_EXT, NameTransformMap, NameTransformSymbol, SEPARATOR, assert, composeKeyWithSeparator, createScript, createScriptNode, decodeName, encodeName, error, generateExposeFilename, generateShareFilename, generateSnapshotFromManifest, getProcessEnv, getResourceUrl, isBrowserEnv, isDebugMode, isManifestProvider, isStaticResourcesEqual, loadScript, loadScriptNode, logger, parseEntry, safeWrapper, simpleJoinRemoteEntry, warn };
1156
+ export { BROWSER_LOG_KEY, BROWSER_LOG_VALUE, EncodedNameTransformMap, FederationModuleManifest, Logger, MANIFEST_EXT, ManifestFileName, ModuleType, NameTransformMap, NameTransformSymbol, SEPARATOR, StatsFileName, assert, composeKeyWithSeparator, ContainerPlugin as containerPlugin, ContainerReferencePlugin as containerReferencePlugin, createLink, createScript, createScriptNode, decodeName, encodeName, error, generateExposeFilename, generateShareFilename, generateSnapshotFromManifest, getProcessEnv, getResourceUrl, isBrowserEnv, isDebugMode, isManifestProvider, isStaticResourcesEqual, loadScript, loadScriptNode, logger, ModuleFederationPlugin as moduleFederationPlugin, parseEntry, safeWrapper, SharePlugin as sharePlugin, simpleJoinRemoteEntry, warn };
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/sdk",
3
- "version": "0.0.10",
3
+ "version": "0.0.13",
4
4
  "license": "MIT",
5
5
  "description": "A sdk for support module federation",
6
6
  "keywords": [
@@ -14,3 +14,9 @@ export declare const EncodedNameTransformMap: {
14
14
  [x: string]: string;
15
15
  };
16
16
  export declare const SEPARATOR = ":";
17
+ export declare const ManifestFileName = "mf-manifest.json";
18
+ export declare const StatsFileName = "mf-stats.json";
19
+ export declare enum ModuleType {
20
+ NPM = "npm",
21
+ APP = "app"
22
+ }
package/dist/src/dom.d.ts CHANGED
@@ -4,6 +4,10 @@ export declare function createScript(url: string, cb: (value: void | PromiseLike
4
4
  script: HTMLScriptElement;
5
5
  needAttach: boolean;
6
6
  };
7
+ export declare function createLink(url: string, cb: (value: void | PromiseLike<void>) => void, attrs?: Record<string, any>, createLinkHook?: (url: string) => HTMLLinkElement | void): {
8
+ link: HTMLLinkElement;
9
+ needAttach: boolean;
10
+ };
7
11
  export declare function loadScript(url: string, info: {
8
12
  attrs?: Record<string, any>;
9
13
  createScriptHook?: (url: string) => HTMLScriptElement | void;
@@ -2,3 +2,4 @@ export * from './common';
2
2
  export * from './manifest';
3
3
  export * from './stats';
4
4
  export * from './snapshot';
5
+ export * from './plugins';
@@ -0,0 +1,159 @@
1
+ /**
2
+ * 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.
3
+ */
4
+ export type Exposes = (ExposesItem | ExposesObject)[] | ExposesObject;
5
+ /**
6
+ * Module that should be exposed by this container.
7
+ */
8
+ export type ExposesItem = string;
9
+ /**
10
+ * Modules that should be exposed by this container.
11
+ */
12
+ export type ExposesItems = ExposesItem[];
13
+ /**
14
+ * Add a container for define/require functions in the AMD module.
15
+ */
16
+ export type AmdContainer = string;
17
+ /**
18
+ * Add a comment in the UMD wrapper.
19
+ */
20
+ export type AuxiliaryComment = string | LibraryCustomUmdCommentObject;
21
+ /**
22
+ * Specify which export should be exposed as library.
23
+ */
24
+ export type LibraryExport = string[] | string;
25
+ /**
26
+ * The name of the library (some types allow unnamed libraries too).
27
+ */
28
+ export type LibraryName = string[] | string | LibraryCustomUmdObject;
29
+ /**
30
+ * Type of library (types included by default are 'var', 'module', 'assign', 'assign-properties', 'this', 'window', 'self', 'global', 'commonjs', 'commonjs2', 'commonjs-module', 'commonjs-static', 'amd', 'amd-require', 'umd', 'umd2', 'jsonp', 'system', but others might be added by plugins).
31
+ */
32
+ export type LibraryType = ('var' | 'module' | 'assign' | 'assign-properties' | 'this' | 'window' | 'self' | 'global' | 'commonjs' | 'commonjs2' | 'commonjs-module' | 'commonjs-static' | 'amd' | 'amd-require' | 'umd' | 'umd2' | 'jsonp' | 'system') | string;
33
+ /**
34
+ * If `output.libraryTarget` is set to umd and `output.library` is set, setting this to true will name the AMD module.
35
+ */
36
+ export type UmdNamedDefine = boolean;
37
+ /**
38
+ * The name of the runtime chunk. If set a runtime chunk with this name is created or an existing entrypoint is used as runtime.
39
+ */
40
+ export type EntryRuntime = false | string;
41
+ export interface ContainerPluginOptions {
42
+ /**
43
+ * 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.
44
+ */
45
+ exposes: Exposes;
46
+ /**
47
+ * The filename for this container relative path inside the `output.path` directory.
48
+ */
49
+ filename?: string;
50
+ /**
51
+ * Options for library.
52
+ */
53
+ library?: LibraryOptions;
54
+ /**
55
+ * The name for this container.
56
+ */
57
+ name: string;
58
+ /**
59
+ * The name of the runtime chunk. If set a runtime chunk with this name is created or an existing entrypoint is used as runtime.
60
+ */
61
+ runtime?: EntryRuntime;
62
+ /**
63
+ * The name of the share scope which is shared with the host (defaults to 'default').
64
+ */
65
+ shareScope?: string;
66
+ /**
67
+ * Runtime plugin file paths or package name.
68
+ */
69
+ runtimePlugins?: string[];
70
+ }
71
+ /**
72
+ * Modules that should be exposed by this container. Property names are used as public paths.
73
+ */
74
+ export interface ExposesObject {
75
+ /**
76
+ * Modules that should be exposed by this container.
77
+ */
78
+ [k: string]: ExposesConfig | ExposesItem | ExposesItems;
79
+ }
80
+ /**
81
+ * Advanced configuration for modules that should be exposed by this container.
82
+ */
83
+ export interface ExposesConfig {
84
+ /**
85
+ * Request to a module that should be exposed by this container.
86
+ */
87
+ import: ExposesItem | ExposesItems;
88
+ /**
89
+ * Custom chunk name for the exposed module.
90
+ */
91
+ name?: string;
92
+ }
93
+ /**
94
+ * Options for library.
95
+ */
96
+ export interface LibraryOptions {
97
+ /**
98
+ * Add a container for define/require functions in the AMD module.
99
+ */
100
+ amdContainer?: AmdContainer;
101
+ /**
102
+ * Add a comment in the UMD wrapper.
103
+ */
104
+ auxiliaryComment?: AuxiliaryComment;
105
+ /**
106
+ * Specify which export should be exposed as library.
107
+ */
108
+ export?: LibraryExport;
109
+ /**
110
+ * The name of the library (some types allow unnamed libraries too).
111
+ */
112
+ name?: LibraryName;
113
+ /**
114
+ * Type of library (types included by default are 'var', 'module', 'assign', 'assign-properties', 'this', 'window', 'self', 'global', 'commonjs', 'commonjs2', 'commonjs-module', 'commonjs-static', 'amd', 'amd-require', 'umd', 'umd2', 'jsonp', 'system', but others might be added by plugins).
115
+ */
116
+ type: LibraryType;
117
+ /**
118
+ * If `output.libraryTarget` is set to umd and `output.library` is set, setting this to true will name the AMD module.
119
+ */
120
+ umdNamedDefine?: UmdNamedDefine;
121
+ }
122
+ /**
123
+ * Set explicit comments for `commonjs`, `commonjs2`, `amd`, and `root`.
124
+ */
125
+ export interface LibraryCustomUmdCommentObject {
126
+ /**
127
+ * Set comment for `amd` section in UMD.
128
+ */
129
+ amd?: string;
130
+ /**
131
+ * Set comment for `commonjs` (exports) section in UMD.
132
+ */
133
+ commonjs?: string;
134
+ /**
135
+ * Set comment for `commonjs2` (module.exports) section in UMD.
136
+ */
137
+ commonjs2?: string;
138
+ /**
139
+ * Set comment for `root` (global variable) section in UMD.
140
+ */
141
+ root?: string;
142
+ }
143
+ /**
144
+ * Description object for all UMD variants of the library name.
145
+ */
146
+ export interface LibraryCustomUmdObject {
147
+ /**
148
+ * Name of the exposed AMD library in the UMD.
149
+ */
150
+ amd?: string;
151
+ /**
152
+ * Name of the exposed commonjs export in the UMD.
153
+ */
154
+ commonjs?: string;
155
+ /**
156
+ * Name of the property exposed globally by a UMD library.
157
+ */
158
+ root?: string[] | string;
159
+ }
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Specifies the default type of externals ('amd*', 'umd*', 'system' and 'jsonp' depend on output.libraryTarget set to the same value).
3
+ */
4
+ export type ExternalsType = 'var' | 'module' | 'assign' | 'this' | 'window' | 'self' | 'global' | 'commonjs' | 'commonjs2' | 'commonjs-module' | 'commonjs-static' | 'amd' | 'amd-require' | 'umd' | 'umd2' | 'jsonp' | 'system' | 'promise' | 'import' | 'script' | 'node-commonjs';
5
+ /**
6
+ * Container locations and request scopes from which modules should be resolved and loaded at runtime. When provided, property name is used as request scope, otherwise request scope is automatically inferred from container location.
7
+ */
8
+ export type Remotes = (RemotesItem | RemotesObject)[] | RemotesObject;
9
+ /**
10
+ * Container location from which modules should be resolved and loaded at runtime.
11
+ */
12
+ export type RemotesItem = string;
13
+ /**
14
+ * Container locations from which modules should be resolved and loaded at runtime.
15
+ */
16
+ export type RemotesItems = RemotesItem[];
17
+ export interface ContainerReferencePluginOptions {
18
+ /**
19
+ * The external type of the remote containers.
20
+ */
21
+ remoteType: ExternalsType;
22
+ /**
23
+ * Container locations and request scopes from which modules should be resolved and loaded at runtime. When provided, property name is used as request scope, otherwise request scope is automatically inferred from container location.
24
+ */
25
+ remotes: Remotes;
26
+ /**
27
+ * The name of the share scope shared with all remotes (defaults to 'default').
28
+ */
29
+ shareScope?: string;
30
+ }
31
+ /**
32
+ * Container locations from which modules should be resolved and loaded at runtime. Property names are used as request scopes.
33
+ */
34
+ export interface RemotesObject {
35
+ /**
36
+ * Container locations from which modules should be resolved and loaded at runtime.
37
+ */
38
+ [k: string]: RemotesConfig | RemotesItem | RemotesItems;
39
+ }
40
+ /**
41
+ * Advanced configuration for container locations from which modules should be resolved and loaded at runtime.
42
+ */
43
+ export interface RemotesConfig {
44
+ /**
45
+ * Container locations from which modules should be resolved and loaded at runtime.
46
+ */
47
+ external: RemotesItem | RemotesItems;
48
+ /**
49
+ * The name of the share scope shared with this remote.
50
+ */
51
+ shareScope?: string;
52
+ }
@@ -0,0 +1,276 @@
1
+ /**
2
+ * 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.
3
+ */
4
+ export type Exposes = (ExposesItem | ExposesObject)[] | ExposesObject;
5
+ /**
6
+ * Module that should be exposed by this container.
7
+ */
8
+ export type ExposesItem = string;
9
+ /**
10
+ * Modules that should be exposed by this container.
11
+ */
12
+ export type ExposesItems = ExposesItem[];
13
+ /**
14
+ * Add a container for define/require functions in the AMD module.
15
+ */
16
+ export type AmdContainer = string;
17
+ /**
18
+ * Add a comment in the UMD wrapper.
19
+ */
20
+ export type AuxiliaryComment = string | LibraryCustomUmdCommentObject;
21
+ /**
22
+ * Specify which export should be exposed as library.
23
+ */
24
+ export type LibraryExport = string[] | string;
25
+ /**
26
+ * The name of the library (some types allow unnamed libraries too).
27
+ */
28
+ export type LibraryName = string[] | string | LibraryCustomUmdObject;
29
+ /**
30
+ * Type of library (types included by default are 'var', 'module', 'assign', 'assign-properties', 'this', 'window', 'self', 'global', 'commonjs', 'commonjs2', 'commonjs-module', 'commonjs-static', 'amd', 'amd-require', 'umd', 'umd2', 'jsonp', 'system', but others might be added by plugins).
31
+ */
32
+ export type LibraryType = ('var' | 'module' | 'assign' | 'assign-properties' | 'this' | 'window' | 'self' | 'global' | 'commonjs' | 'commonjs2' | 'commonjs-module' | 'commonjs-static' | 'amd' | 'amd-require' | 'umd' | 'umd2' | 'jsonp' | 'system') | string;
33
+ /**
34
+ * If `output.libraryTarget` is set to umd and `output.library` is set, setting this to true will name the AMD module.
35
+ */
36
+ export type UmdNamedDefine = boolean;
37
+ /**
38
+ * Specifies the default type of externals ('amd*', 'umd*', 'system' and 'jsonp' depend on output.libraryTarget set to the same value).
39
+ */
40
+ export type ExternalsType = 'var' | 'module' | 'assign' | 'this' | 'window' | 'self' | 'global' | 'commonjs' | 'commonjs2' | 'commonjs-module' | 'commonjs-static' | 'amd' | 'amd-require' | 'umd' | 'umd2' | 'jsonp' | 'system' | 'promise' | 'import' | 'script' | 'node-commonjs';
41
+ /**
42
+ * Container locations and request scopes from which modules should be resolved and loaded at runtime. When provided, property name is used as request scope, otherwise request scope is automatically inferred from container location.
43
+ */
44
+ export type Remotes = (RemotesItem | RemotesObject)[] | RemotesObject;
45
+ /**
46
+ * Container location from which modules should be resolved and loaded at runtime.
47
+ */
48
+ export type RemotesItem = string;
49
+ /**
50
+ * Container locations from which modules should be resolved and loaded at runtime.
51
+ */
52
+ export type RemotesItems = RemotesItem[];
53
+ /**
54
+ * The name of the runtime chunk. If set a runtime chunk with this name is created or an existing entrypoint is used as runtime.
55
+ */
56
+ export type EntryRuntime = false | string;
57
+ /**
58
+ * Modules that should be shared in the share scope. When provided, property names are used to match requested modules in this compilation.
59
+ */
60
+ export type Shared = (SharedItem | SharedObject)[] | SharedObject;
61
+ /**
62
+ * A module that should be shared in the share scope.
63
+ */
64
+ export type SharedItem = string;
65
+ export interface PluginManifestOptions {
66
+ filePath?: string;
67
+ disableAssetsAnalyze?: boolean;
68
+ }
69
+ export interface ModuleFederationPluginOptions {
70
+ /**
71
+ * 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.
72
+ */
73
+ exposes?: Exposes;
74
+ /**
75
+ * The filename of the container as relative path inside the `output.path` directory.
76
+ */
77
+ filename?: string;
78
+ /**
79
+ * Options for library.
80
+ */
81
+ library?: LibraryOptions;
82
+ /**
83
+ * The name of the container.
84
+ */
85
+ name?: string;
86
+ /**
87
+ * The external type of the remote containers.
88
+ */
89
+ remoteType?: ExternalsType;
90
+ /**
91
+ * Container locations and request scopes from which modules should be resolved and loaded at runtime. When provided, property name is used as request scope, otherwise request scope is automatically inferred from container location.
92
+ */
93
+ remotes?: Remotes;
94
+ /**
95
+ * The name of the runtime chunk. If set a runtime chunk with this name is created or an existing entrypoint is used as runtime.
96
+ */
97
+ runtime?: EntryRuntime;
98
+ /**
99
+ * Share scope name used for all shared modules (defaults to 'default').
100
+ */
101
+ shareScope?: string;
102
+ /**
103
+ * Modules that should be shared in the share scope. When provided, property names are used to match requested modules in this compilation.
104
+ */
105
+ shared?: Shared;
106
+ /**
107
+ * Runtime plugin file paths or package name.
108
+ */
109
+ runtimePlugins?: string[];
110
+ /**
111
+ * Bundler runtime path
112
+ */
113
+ implementation?: string;
114
+ manifest?: boolean | PluginManifestOptions;
115
+ }
116
+ /**
117
+ * Modules that should be exposed by this container. Property names are used as public paths.
118
+ */
119
+ export interface ExposesObject {
120
+ /**
121
+ * Modules that should be exposed by this container.
122
+ */
123
+ [k: string]: ExposesConfig | ExposesItem | ExposesItems;
124
+ }
125
+ /**
126
+ * Advanced configuration for modules that should be exposed by this container.
127
+ */
128
+ export interface ExposesConfig {
129
+ /**
130
+ * Request to a module that should be exposed by this container.
131
+ */
132
+ import: ExposesItem | ExposesItems;
133
+ /**
134
+ * Custom chunk name for the exposed module.
135
+ */
136
+ name?: string;
137
+ }
138
+ /**
139
+ * Options for library.
140
+ */
141
+ export interface LibraryOptions {
142
+ /**
143
+ * Add a container for define/require functions in the AMD module.
144
+ */
145
+ amdContainer?: AmdContainer;
146
+ /**
147
+ * Add a comment in the UMD wrapper.
148
+ */
149
+ auxiliaryComment?: AuxiliaryComment;
150
+ /**
151
+ * Specify which export should be exposed as library.
152
+ */
153
+ export?: LibraryExport;
154
+ /**
155
+ * The name of the library (some types allow unnamed libraries too).
156
+ */
157
+ name?: LibraryName;
158
+ /**
159
+ * Type of library (types included by default are 'var', 'module', 'assign', 'assign-properties', 'this', 'window', 'self', 'global', 'commonjs', 'commonjs2', 'commonjs-module', 'commonjs-static', 'amd', 'amd-require', 'umd', 'umd2', 'jsonp', 'system', but others might be added by plugins).
160
+ */
161
+ type: LibraryType;
162
+ /**
163
+ * If `output.libraryTarget` is set to umd and `output.library` is set, setting this to true will name the AMD module.
164
+ */
165
+ umdNamedDefine?: UmdNamedDefine;
166
+ }
167
+ /**
168
+ * Set explicit comments for `commonjs`, `commonjs2`, `amd`, and `root`.
169
+ */
170
+ export interface LibraryCustomUmdCommentObject {
171
+ /**
172
+ * Set comment for `amd` section in UMD.
173
+ */
174
+ amd?: string;
175
+ /**
176
+ * Set comment for `commonjs` (exports) section in UMD.
177
+ */
178
+ commonjs?: string;
179
+ /**
180
+ * Set comment for `commonjs2` (module.exports) section in UMD.
181
+ */
182
+ commonjs2?: string;
183
+ /**
184
+ * Set comment for `root` (global variable) section in UMD.
185
+ */
186
+ root?: string;
187
+ }
188
+ /**
189
+ * Description object for all UMD variants of the library name.
190
+ */
191
+ export interface LibraryCustomUmdObject {
192
+ /**
193
+ * Name of the exposed AMD library in the UMD.
194
+ */
195
+ amd?: string;
196
+ /**
197
+ * Name of the exposed commonjs export in the UMD.
198
+ */
199
+ commonjs?: string;
200
+ /**
201
+ * Name of the property exposed globally by a UMD library.
202
+ */
203
+ root?: string[] | string;
204
+ }
205
+ /**
206
+ * Container locations from which modules should be resolved and loaded at runtime. Property names are used as request scopes.
207
+ */
208
+ export interface RemotesObject {
209
+ /**
210
+ * Container locations from which modules should be resolved and loaded at runtime.
211
+ */
212
+ [k: string]: RemotesConfig | RemotesItem | RemotesItems;
213
+ }
214
+ /**
215
+ * Advanced configuration for container locations from which modules should be resolved and loaded at runtime.
216
+ */
217
+ export interface RemotesConfig {
218
+ /**
219
+ * Container locations from which modules should be resolved and loaded at runtime.
220
+ */
221
+ external: RemotesItem | RemotesItems;
222
+ /**
223
+ * The name of the share scope shared with this remote.
224
+ */
225
+ shareScope?: string;
226
+ }
227
+ /**
228
+ * Modules that should be shared in the share scope. Property names are used to match requested modules in this compilation. Relative requests are resolved, module requests are matched unresolved, absolute paths will match resolved requests. A trailing slash will match all requests with this prefix. In this case shareKey must also have a trailing slash.
229
+ */
230
+ export interface SharedObject {
231
+ /**
232
+ * Modules that should be shared in the share scope.
233
+ */
234
+ [k: string]: SharedConfig | SharedItem;
235
+ }
236
+ /**
237
+ * Advanced configuration for modules that should be shared in the share scope.
238
+ */
239
+ export interface SharedConfig {
240
+ /**
241
+ * Include the provided and fallback module directly instead behind an async request. This allows to use this shared module in initial load too. All possible shared modules need to be eager too.
242
+ */
243
+ eager?: boolean;
244
+ /**
245
+ * Provided module that should be provided to share scope. Also acts as fallback module if no shared module is found in share scope or version isn't valid. Defaults to the property name.
246
+ */
247
+ import?: false | SharedItem;
248
+ /**
249
+ * Package name to determine required version from description file. This is only needed when package name can't be automatically determined from request.
250
+ */
251
+ packageName?: string;
252
+ /**
253
+ * Version requirement from module in share scope.
254
+ */
255
+ requiredVersion?: false | string;
256
+ /**
257
+ * Module is looked up under this key from the share scope.
258
+ */
259
+ shareKey?: string;
260
+ /**
261
+ * Share scope name.
262
+ */
263
+ shareScope?: string;
264
+ /**
265
+ * Allow only a single version of the shared module in share scope (disabled by default).
266
+ */
267
+ singleton?: boolean;
268
+ /**
269
+ * Do not accept shared module if version is not valid (defaults to yes, if local fallback module is available and shared module is not a singleton, otherwise no, has no effect if there is no required version specified).
270
+ */
271
+ strictVersion?: boolean;
272
+ /**
273
+ * Version of the provided module. Will replace lower matching versions, but not higher.
274
+ */
275
+ version?: false | string;
276
+ }
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Modules that should be shared in the share scope. When provided, property names are used to match requested modules in this compilation.
3
+ */
4
+ export type Shared = (SharedItem | SharedObject)[] | SharedObject;
5
+ /**
6
+ * A module that should be shared in the share scope.
7
+ */
8
+ export type SharedItem = string;
9
+ /**
10
+ * Options for shared modules.
11
+ */
12
+ export interface SharePluginOptions {
13
+ /**
14
+ * Share scope name used for all shared modules (defaults to 'default').
15
+ */
16
+ shareScope?: string;
17
+ /**
18
+ * Modules that should be shared in the share scope. When provided, property names are used to match requested modules in this compilation.
19
+ */
20
+ shared: Shared;
21
+ }
22
+ /**
23
+ * Modules that should be shared in the share scope. Property names are used to match requested modules in this compilation. Relative requests are resolved, module requests are matched unresolved, absolute paths will match resolved requests. A trailing slash will match all requests with this prefix. In this case shareKey must also have a trailing slash.
24
+ */
25
+ export interface SharedObject {
26
+ /**
27
+ * Modules that should be shared in the share scope.
28
+ */
29
+ [k: string]: SharedConfig | SharedItem;
30
+ }
31
+ /**
32
+ * Advanced configuration for modules that should be shared in the share scope.
33
+ */
34
+ export interface SharedConfig {
35
+ /**
36
+ * Include the provided and fallback module directly instead behind an async request. This allows to use this shared module in initial load too. All possible shared modules need to be eager too.
37
+ */
38
+ eager?: boolean;
39
+ /**
40
+ * Provided module that should be provided to share scope. Also acts as fallback module if no shared module is found in share scope or version isn't valid. Defaults to the property name.
41
+ */
42
+ import?: false | SharedItem;
43
+ /**
44
+ * Package name to determine required version from description file. This is only needed when package name can't be automatically determined from request.
45
+ */
46
+ packageName?: string;
47
+ /**
48
+ * Version requirement from module in share scope.
49
+ */
50
+ requiredVersion?: false | string;
51
+ /**
52
+ * Module is looked up under this key from the share scope.
53
+ */
54
+ shareKey?: string;
55
+ /**
56
+ * Share scope name.
57
+ */
58
+ shareScope?: string;
59
+ /**
60
+ * Allow only a single version of the shared module in share scope (disabled by default).
61
+ */
62
+ singleton?: boolean;
63
+ /**
64
+ * Do not accept shared module if version is not valid (defaults to yes, if local fallback module is available and shared module is not a singleton, otherwise no, has no effect if there is no required version specified).
65
+ */
66
+ strictVersion?: boolean;
67
+ /**
68
+ * Version of the provided module. Will replace lower matching versions, but not higher.
69
+ */
70
+ version?: false | string;
71
+ }
@@ -0,0 +1,4 @@
1
+ export * as containerPlugin from './ContainerPlugin';
2
+ export * as containerReferencePlugin from './ContainerReferencePlugin';
3
+ export * as moduleFederationPlugin from './ModuleFederationPlugin';
4
+ export * as sharePlugin from './SharePlugin';
@@ -27,7 +27,8 @@ export interface BasicProviderModuleInfo extends BasicModuleInfo {
27
27
  modulePath?: string;
28
28
  assets: StatsAssets;
29
29
  }>;
30
- prefetchInterface?: boolean;
30
+ prefetchEntry?: string;
31
+ prefetchEntryType?: RemoteEntryType;
31
32
  }
32
33
  interface BasicProviderModuleInfoWithPublicPath extends BasicProviderModuleInfo {
33
34
  publicPath: string;
@@ -1,3 +1,4 @@
1
+ import { ModuleType } from '../constant';
1
2
  import type { RemoteWithEntry, RemoteWithVersion } from './common';
2
3
  export type RemoteEntryType = 'esm' | 'global';
3
4
  interface ResourceInfo {
@@ -14,8 +15,10 @@ export interface BasicStatsMetaData {
14
15
  globalName: string;
15
16
  buildInfo: StatsBuildInfo;
16
17
  remoteEntry: ResourceInfo;
17
- prefetchInterface: boolean;
18
+ prefetchEntry?: ResourceInfo;
18
19
  types: Omit<ResourceInfo, 'type'>;
20
+ type: ModuleType;
21
+ pluginVersion: string;
19
22
  }
20
23
  type StatsMetaDataWithGetPublicPath<T = BasicStatsMetaData> = T & {
21
24
  getPublicPath: string;
@@ -55,7 +58,7 @@ export type StatsRemoteWithVersion<T = StatsRemoteVal> = T & Omit<RemoteWithVers
55
58
  export type StatsRemote<T = StatsRemoteVal> = StatsRemoteWithEntry<T> | StatsRemoteWithVersion<T>;
56
59
  export interface StatsModuleInfo {
57
60
  name: string;
58
- file: string;
61
+ file: string[];
59
62
  }
60
63
  export interface ManifestModuleInfos {
61
64
  [exposeModuleName: string]: StatsModuleInfo;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/sdk",
3
- "version": "0.0.0-next-20240205220829",
3
+ "version": "0.0.0-next-20240223065734",
4
4
  "license": "MIT",
5
5
  "description": "A sdk for support module federation",
6
6
  "keywords": [