@module-federation/sdk 0.0.14 → 0.0.15

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,28 @@ 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
+ var MFModuleType = {
35
+ NPM: "npm",
36
+ APP: "app"
37
+ };
38
+
39
+ var ContainerPlugin = /*#__PURE__*/Object.freeze({
40
+ __proto__: null
41
+ });
42
+
43
+ var ContainerReferencePlugin = /*#__PURE__*/Object.freeze({
44
+ __proto__: null
45
+ });
46
+
47
+ var ModuleFederationPlugin = /*#__PURE__*/Object.freeze({
48
+ __proto__: null
49
+ });
50
+
51
+ var SharePlugin = /*#__PURE__*/Object.freeze({
52
+ __proto__: null
53
+ });
32
54
 
33
55
  function isBrowserEnv() {
34
56
  return typeof window !== "undefined";
@@ -223,7 +245,8 @@ var LOG_CATEGORY = "[ Federation Runtime ]";
223
245
  // entry: name:version version : 1.0.0 | ^1.2.3
224
246
  // entry: name:entry entry: https://localhost:9000/federation-manifest.json
225
247
  var parseEntry = function(str, devVerOrUrl) {
226
- var strSplit = str.split(SEPARATOR);
248
+ var separator = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : SEPARATOR;
249
+ var strSplit = str.split(separator);
227
250
  var devVersionOrUrl = getProcessEnv()["NODE_ENV"] === "development" && devVerOrUrl;
228
251
  var defaultVersion = "*";
229
252
  var isEntry = function(s) {
@@ -232,7 +255,7 @@ var parseEntry = function(str, devVerOrUrl) {
232
255
  // Check if the string starts with a type
233
256
  if (strSplit.length >= 2) {
234
257
  var _strSplit = _to_array(strSplit), name = _strSplit[0], versionOrEntryArr = _strSplit.slice(1);
235
- var versionOrEntry = devVersionOrUrl || versionOrEntryArr.join(SEPARATOR);
258
+ var versionOrEntry = devVersionOrUrl || versionOrEntryArr.join(separator);
236
259
  if (isEntry(versionOrEntry)) {
237
260
  return {
238
261
  name: name,
@@ -767,7 +790,8 @@ function createScript(url, cb, attrs, createScriptHook) {
767
790
  needAttach: needAttach
768
791
  };
769
792
  }
770
- function createLink(url, cb, attrs, createLinkHook) {
793
+ function createLink(url, cb) {
794
+ var attrs = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}, createLinkHook = arguments.length > 3 ? arguments[3] : void 0;
771
795
  // <link rel="preload" href="script.js" as="script">
772
796
  // Retrieve the existing script element by its src attribute
773
797
  var link = null;
@@ -776,7 +800,8 @@ function createLink(url, cb, attrs, createLinkHook) {
776
800
  for(var i = 0; i < links.length; i++){
777
801
  var l = links[i];
778
802
  var linkHref = l.getAttribute("href");
779
- if (linkHref && isStaticResourcesEqual(linkHref, url)) {
803
+ var linkRef = l.getAttribute("ref");
804
+ if (linkHref && isStaticResourcesEqual(linkHref, url) && linkRef === attrs["ref"]) {
780
805
  link = l;
781
806
  needAttach = false;
782
807
  break;
@@ -1150,11 +1175,16 @@ exports.EncodedNameTransformMap = EncodedNameTransformMap;
1150
1175
  exports.FederationModuleManifest = FederationModuleManifest;
1151
1176
  exports.Logger = Logger;
1152
1177
  exports.MANIFEST_EXT = MANIFEST_EXT;
1178
+ exports.MFModuleType = MFModuleType;
1179
+ exports.ManifestFileName = ManifestFileName;
1153
1180
  exports.NameTransformMap = NameTransformMap;
1154
1181
  exports.NameTransformSymbol = NameTransformSymbol;
1155
1182
  exports.SEPARATOR = SEPARATOR;
1183
+ exports.StatsFileName = StatsFileName;
1156
1184
  exports.assert = assert;
1157
1185
  exports.composeKeyWithSeparator = composeKeyWithSeparator;
1186
+ exports.containerPlugin = ContainerPlugin;
1187
+ exports.containerReferencePlugin = ContainerReferencePlugin;
1158
1188
  exports.createLink = createLink;
1159
1189
  exports.createScript = createScript;
1160
1190
  exports.createScriptNode = createScriptNode;
@@ -1173,7 +1203,9 @@ exports.isStaticResourcesEqual = isStaticResourcesEqual;
1173
1203
  exports.loadScript = loadScript;
1174
1204
  exports.loadScriptNode = loadScriptNode;
1175
1205
  exports.logger = logger;
1206
+ exports.moduleFederationPlugin = ModuleFederationPlugin;
1176
1207
  exports.parseEntry = parseEntry;
1177
1208
  exports.safeWrapper = safeWrapper;
1209
+ exports.sharePlugin = SharePlugin;
1178
1210
  exports.simpleJoinRemoteEntry = simpleJoinRemoteEntry;
1179
1211
  exports.warn = warn;
package/dist/index.esm.js CHANGED
@@ -25,6 +25,28 @@ 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 MFModuleType = {
31
+ NPM: "npm",
32
+ APP: "app"
33
+ };
34
+
35
+ var ContainerPlugin = /*#__PURE__*/Object.freeze({
36
+ __proto__: null
37
+ });
38
+
39
+ var ContainerReferencePlugin = /*#__PURE__*/Object.freeze({
40
+ __proto__: null
41
+ });
42
+
43
+ var ModuleFederationPlugin = /*#__PURE__*/Object.freeze({
44
+ __proto__: null
45
+ });
46
+
47
+ var SharePlugin = /*#__PURE__*/Object.freeze({
48
+ __proto__: null
49
+ });
28
50
 
29
51
  function isBrowserEnv() {
30
52
  return typeof window !== "undefined";
@@ -219,7 +241,8 @@ var LOG_CATEGORY = "[ Federation Runtime ]";
219
241
  // entry: name:version version : 1.0.0 | ^1.2.3
220
242
  // entry: name:entry entry: https://localhost:9000/federation-manifest.json
221
243
  var parseEntry = function(str, devVerOrUrl) {
222
- var strSplit = str.split(SEPARATOR);
244
+ var separator = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : SEPARATOR;
245
+ var strSplit = str.split(separator);
223
246
  var devVersionOrUrl = getProcessEnv()["NODE_ENV"] === "development" && devVerOrUrl;
224
247
  var defaultVersion = "*";
225
248
  var isEntry = function(s) {
@@ -228,7 +251,7 @@ var parseEntry = function(str, devVerOrUrl) {
228
251
  // Check if the string starts with a type
229
252
  if (strSplit.length >= 2) {
230
253
  var _strSplit = _to_array(strSplit), name = _strSplit[0], versionOrEntryArr = _strSplit.slice(1);
231
- var versionOrEntry = devVersionOrUrl || versionOrEntryArr.join(SEPARATOR);
254
+ var versionOrEntry = devVersionOrUrl || versionOrEntryArr.join(separator);
232
255
  if (isEntry(versionOrEntry)) {
233
256
  return {
234
257
  name: name,
@@ -763,7 +786,8 @@ function createScript(url, cb, attrs, createScriptHook) {
763
786
  needAttach: needAttach
764
787
  };
765
788
  }
766
- function createLink(url, cb, attrs, createLinkHook) {
789
+ function createLink(url, cb) {
790
+ var attrs = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}, createLinkHook = arguments.length > 3 ? arguments[3] : void 0;
767
791
  // <link rel="preload" href="script.js" as="script">
768
792
  // Retrieve the existing script element by its src attribute
769
793
  var link = null;
@@ -772,7 +796,8 @@ function createLink(url, cb, attrs, createLinkHook) {
772
796
  for(var i = 0; i < links.length; i++){
773
797
  var l = links[i];
774
798
  var linkHref = l.getAttribute("href");
775
- if (linkHref && isStaticResourcesEqual(linkHref, url)) {
799
+ var linkRef = l.getAttribute("ref");
800
+ if (linkHref && isStaticResourcesEqual(linkHref, url) && linkRef === attrs["ref"]) {
776
801
  link = l;
777
802
  needAttach = false;
778
803
  break;
@@ -1140,4 +1165,4 @@ function loadScriptNode(url, info) {
1140
1165
  });
1141
1166
  }
1142
1167
 
1143
- export { BROWSER_LOG_KEY, BROWSER_LOG_VALUE, EncodedNameTransformMap, FederationModuleManifest, Logger, MANIFEST_EXT, NameTransformMap, NameTransformSymbol, SEPARATOR, assert, composeKeyWithSeparator, createLink, createScript, createScriptNode, decodeName, encodeName, error, generateExposeFilename, generateShareFilename, generateSnapshotFromManifest, getProcessEnv, getResourceUrl, isBrowserEnv, isDebugMode, isManifestProvider, isStaticResourcesEqual, loadScript, loadScriptNode, logger, parseEntry, safeWrapper, simpleJoinRemoteEntry, warn };
1168
+ export { BROWSER_LOG_KEY, BROWSER_LOG_VALUE, EncodedNameTransformMap, FederationModuleManifest, Logger, MANIFEST_EXT, MFModuleType, ManifestFileName, 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.14",
3
+ "version": "0.0.15",
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 const MFModuleType: {
20
+ NPM: string;
21
+ APP: string;
22
+ };
package/dist/src/dom.d.ts CHANGED
@@ -4,7 +4,7 @@ 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): {
7
+ export declare function createLink(url: string, cb: (value: void | PromiseLike<void>) => void, attrs?: Record<string, string>, createLinkHook?: (url: string) => HTMLLinkElement | void): {
8
8
  link: HTMLLinkElement;
9
9
  needAttach: boolean;
10
10
  };
@@ -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,287 @@
1
+ import type webpack from 'webpack';
2
+ import { Stats } from '../stats';
3
+ /**
4
+ * 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.
5
+ */
6
+ export type Exposes = (ExposesItem | ExposesObject)[] | ExposesObject;
7
+ /**
8
+ * Module that should be exposed by this container.
9
+ */
10
+ export type ExposesItem = string;
11
+ /**
12
+ * Modules that should be exposed by this container.
13
+ */
14
+ export type ExposesItems = ExposesItem[];
15
+ /**
16
+ * Add a container for define/require functions in the AMD module.
17
+ */
18
+ export type AmdContainer = string;
19
+ /**
20
+ * Add a comment in the UMD wrapper.
21
+ */
22
+ export type AuxiliaryComment = string | LibraryCustomUmdCommentObject;
23
+ /**
24
+ * Specify which export should be exposed as library.
25
+ */
26
+ export type LibraryExport = string[] | string;
27
+ /**
28
+ * The name of the library (some types allow unnamed libraries too).
29
+ */
30
+ export type LibraryName = string[] | string | LibraryCustomUmdObject;
31
+ /**
32
+ * 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).
33
+ */
34
+ 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;
35
+ /**
36
+ * If `output.libraryTarget` is set to umd and `output.library` is set, setting this to true will name the AMD module.
37
+ */
38
+ export type UmdNamedDefine = boolean;
39
+ /**
40
+ * Specifies the default type of externals ('amd*', 'umd*', 'system' and 'jsonp' depend on output.libraryTarget set to the same value).
41
+ */
42
+ 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';
43
+ /**
44
+ * 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.
45
+ */
46
+ export type Remotes = (RemotesItem | RemotesObject)[] | RemotesObject;
47
+ /**
48
+ * Container location from which modules should be resolved and loaded at runtime.
49
+ */
50
+ export type RemotesItem = string;
51
+ /**
52
+ * Container locations from which modules should be resolved and loaded at runtime.
53
+ */
54
+ export type RemotesItems = RemotesItem[];
55
+ /**
56
+ * The name of the runtime chunk. If set a runtime chunk with this name is created or an existing entrypoint is used as runtime.
57
+ */
58
+ export type EntryRuntime = false | string;
59
+ /**
60
+ * Modules that should be shared in the share scope. When provided, property names are used to match requested modules in this compilation.
61
+ */
62
+ export type Shared = (SharedItem | SharedObject)[] | SharedObject;
63
+ /**
64
+ * A module that should be shared in the share scope.
65
+ */
66
+ export type SharedItem = string;
67
+ export interface AdditionalDataOptions {
68
+ stats: Stats;
69
+ pluginOptions: ModuleFederationPluginOptions;
70
+ compiler: webpack.Compiler;
71
+ compilation: webpack.Compilation;
72
+ bundler: 'webpack' | 'rspack';
73
+ }
74
+ export interface PluginManifestOptions {
75
+ filePath?: string;
76
+ disableAssetsAnalyze?: boolean;
77
+ fileName?: string;
78
+ additionalData?: (options: AdditionalDataOptions) => Promise<Stats | void> | Stats | void;
79
+ }
80
+ export interface ModuleFederationPluginOptions {
81
+ /**
82
+ * 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.
83
+ */
84
+ exposes?: Exposes;
85
+ /**
86
+ * The filename of the container as relative path inside the `output.path` directory.
87
+ */
88
+ filename?: string;
89
+ /**
90
+ * Options for library.
91
+ */
92
+ library?: LibraryOptions;
93
+ /**
94
+ * The name of the container.
95
+ */
96
+ name?: string;
97
+ /**
98
+ * The external type of the remote containers.
99
+ */
100
+ remoteType?: ExternalsType;
101
+ /**
102
+ * 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.
103
+ */
104
+ remotes?: Remotes;
105
+ /**
106
+ * The name of the runtime chunk. If set a runtime chunk with this name is created or an existing entrypoint is used as runtime.
107
+ */
108
+ runtime?: EntryRuntime;
109
+ /**
110
+ * Share scope name used for all shared modules (defaults to 'default').
111
+ */
112
+ shareScope?: string;
113
+ /**
114
+ * Modules that should be shared in the share scope. When provided, property names are used to match requested modules in this compilation.
115
+ */
116
+ shared?: Shared;
117
+ /**
118
+ * Runtime plugin file paths or package name.
119
+ */
120
+ runtimePlugins?: string[];
121
+ /**
122
+ * Bundler runtime path
123
+ */
124
+ implementation?: string;
125
+ manifest?: boolean | PluginManifestOptions;
126
+ }
127
+ /**
128
+ * Modules that should be exposed by this container. Property names are used as public paths.
129
+ */
130
+ export interface ExposesObject {
131
+ /**
132
+ * Modules that should be exposed by this container.
133
+ */
134
+ [k: string]: ExposesConfig | ExposesItem | ExposesItems;
135
+ }
136
+ /**
137
+ * Advanced configuration for modules that should be exposed by this container.
138
+ */
139
+ export interface ExposesConfig {
140
+ /**
141
+ * Request to a module that should be exposed by this container.
142
+ */
143
+ import: ExposesItem | ExposesItems;
144
+ /**
145
+ * Custom chunk name for the exposed module.
146
+ */
147
+ name?: string;
148
+ }
149
+ /**
150
+ * Options for library.
151
+ */
152
+ export interface LibraryOptions {
153
+ /**
154
+ * Add a container for define/require functions in the AMD module.
155
+ */
156
+ amdContainer?: AmdContainer;
157
+ /**
158
+ * Add a comment in the UMD wrapper.
159
+ */
160
+ auxiliaryComment?: AuxiliaryComment;
161
+ /**
162
+ * Specify which export should be exposed as library.
163
+ */
164
+ export?: LibraryExport;
165
+ /**
166
+ * The name of the library (some types allow unnamed libraries too).
167
+ */
168
+ name?: LibraryName;
169
+ /**
170
+ * 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).
171
+ */
172
+ type: LibraryType;
173
+ /**
174
+ * If `output.libraryTarget` is set to umd and `output.library` is set, setting this to true will name the AMD module.
175
+ */
176
+ umdNamedDefine?: UmdNamedDefine;
177
+ }
178
+ /**
179
+ * Set explicit comments for `commonjs`, `commonjs2`, `amd`, and `root`.
180
+ */
181
+ export interface LibraryCustomUmdCommentObject {
182
+ /**
183
+ * Set comment for `amd` section in UMD.
184
+ */
185
+ amd?: string;
186
+ /**
187
+ * Set comment for `commonjs` (exports) section in UMD.
188
+ */
189
+ commonjs?: string;
190
+ /**
191
+ * Set comment for `commonjs2` (module.exports) section in UMD.
192
+ */
193
+ commonjs2?: string;
194
+ /**
195
+ * Set comment for `root` (global variable) section in UMD.
196
+ */
197
+ root?: string;
198
+ }
199
+ /**
200
+ * Description object for all UMD variants of the library name.
201
+ */
202
+ export interface LibraryCustomUmdObject {
203
+ /**
204
+ * Name of the exposed AMD library in the UMD.
205
+ */
206
+ amd?: string;
207
+ /**
208
+ * Name of the exposed commonjs export in the UMD.
209
+ */
210
+ commonjs?: string;
211
+ /**
212
+ * Name of the property exposed globally by a UMD library.
213
+ */
214
+ root?: string[] | string;
215
+ }
216
+ /**
217
+ * Container locations from which modules should be resolved and loaded at runtime. Property names are used as request scopes.
218
+ */
219
+ export interface RemotesObject {
220
+ /**
221
+ * Container locations from which modules should be resolved and loaded at runtime.
222
+ */
223
+ [k: string]: RemotesConfig | RemotesItem | RemotesItems;
224
+ }
225
+ /**
226
+ * Advanced configuration for container locations from which modules should be resolved and loaded at runtime.
227
+ */
228
+ export interface RemotesConfig {
229
+ /**
230
+ * Container locations from which modules should be resolved and loaded at runtime.
231
+ */
232
+ external: RemotesItem | RemotesItems;
233
+ /**
234
+ * The name of the share scope shared with this remote.
235
+ */
236
+ shareScope?: string;
237
+ }
238
+ /**
239
+ * 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.
240
+ */
241
+ export interface SharedObject {
242
+ /**
243
+ * Modules that should be shared in the share scope.
244
+ */
245
+ [k: string]: SharedConfig | SharedItem;
246
+ }
247
+ /**
248
+ * Advanced configuration for modules that should be shared in the share scope.
249
+ */
250
+ export interface SharedConfig {
251
+ /**
252
+ * 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.
253
+ */
254
+ eager?: boolean;
255
+ /**
256
+ * 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.
257
+ */
258
+ import?: false | SharedItem;
259
+ /**
260
+ * Package name to determine required version from description file. This is only needed when package name can't be automatically determined from request.
261
+ */
262
+ packageName?: string;
263
+ /**
264
+ * Version requirement from module in share scope.
265
+ */
266
+ requiredVersion?: false | string;
267
+ /**
268
+ * Module is looked up under this key from the share scope.
269
+ */
270
+ shareKey?: string;
271
+ /**
272
+ * Share scope name.
273
+ */
274
+ shareScope?: string;
275
+ /**
276
+ * Allow only a single version of the shared module in share scope (disabled by default).
277
+ */
278
+ singleton?: boolean;
279
+ /**
280
+ * 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).
281
+ */
282
+ strictVersion?: boolean;
283
+ /**
284
+ * Version of the provided module. Will replace lower matching versions, but not higher.
285
+ */
286
+ version?: false | string;
287
+ }
@@ -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';
@@ -14,8 +14,10 @@ export interface BasicStatsMetaData {
14
14
  globalName: string;
15
15
  buildInfo: StatsBuildInfo;
16
16
  remoteEntry: ResourceInfo;
17
- prefetchEntry: ResourceInfo;
17
+ prefetchEntry?: ResourceInfo;
18
18
  types: Omit<ResourceInfo, 'type'>;
19
+ type: string;
20
+ pluginVersion: string;
19
21
  }
20
22
  type StatsMetaDataWithGetPublicPath<T = BasicStatsMetaData> = T & {
21
23
  getPublicPath: string;
@@ -55,7 +57,7 @@ export type StatsRemoteWithVersion<T = StatsRemoteVal> = T & Omit<RemoteWithVers
55
57
  export type StatsRemote<T = StatsRemoteVal> = StatsRemoteWithEntry<T> | StatsRemoteWithVersion<T>;
56
58
  export interface StatsModuleInfo {
57
59
  name: string;
58
- file: string;
60
+ file: string[];
59
61
  }
60
62
  export interface ManifestModuleInfos {
61
63
  [exposeModuleName: string]: StatsModuleInfo;
@@ -1,6 +1,6 @@
1
1
  import { RemoteEntryInfo, ModuleInfo } from './types';
2
2
  import { Logger } from './logger';
3
- declare const parseEntry: (str: string, devVerOrUrl?: string) => RemoteEntryInfo;
3
+ declare const parseEntry: (str: string, devVerOrUrl?: string, separator?: string) => RemoteEntryInfo;
4
4
  declare global {
5
5
  var FEDERATION_DEBUG: string | undefined;
6
6
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/sdk",
3
- "version": "0.0.14",
3
+ "version": "0.0.15",
4
4
  "license": "MIT",
5
5
  "description": "A sdk for support module federation",
6
6
  "keywords": [