@module-federation/webpack-bundler-runtime 0.0.0-next-20231225095220 → 0.0.0-next-20231229025030

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
@@ -1,8 +1,6 @@
1
1
  'use strict';
2
2
 
3
3
  var runtime = require('@module-federation/runtime');
4
- var sdk = require('@module-federation/sdk');
5
- var constant = require('./constant.cjs.js');
6
4
 
7
5
  function _interopNamespace(e) {
8
6
  if (e && e.__esModule) return e;
@@ -24,17 +22,8 @@ function _interopNamespace(e) {
24
22
 
25
23
  var runtime__namespace = /*#__PURE__*/_interopNamespace(runtime);
26
24
 
27
- function attachShareScopeMap(webpackRequire) {
28
- if (!webpackRequire.S || webpackRequire.federation.hasAttachShareScopeMap || !webpackRequire.federation.instance || !webpackRequire.federation.instance.shareScopeMap) {
29
- return;
30
- }
31
- webpackRequire.S = webpackRequire.federation.instance.shareScopeMap;
32
- webpackRequire.federation.hasAttachShareScopeMap = true;
33
- }
34
-
35
25
  function remotes(options) {
36
- var chunkId = options.chunkId, promises = options.promises, chunkMapping = options.chunkMapping, idToExternalAndNameMapping = options.idToExternalAndNameMapping, webpackRequire = options.webpackRequire, idToRemoteMap = options.idToRemoteMap;
37
- attachShareScopeMap(webpackRequire);
26
+ var chunkId = options.chunkId, promises = options.promises, chunkMapping = options.chunkMapping, idToExternalAndNameMapping = options.idToExternalAndNameMapping, webpackRequire = options.webpackRequire;
38
27
  if (webpackRequire.o(chunkMapping, chunkId)) {
39
28
  chunkMapping[chunkId].forEach(function(id) {
40
29
  var getScope = webpackRequire.R;
@@ -42,7 +31,6 @@ function remotes(options) {
42
31
  getScope = [];
43
32
  }
44
33
  var data = idToExternalAndNameMapping[id];
45
- var remoteInfos = idToRemoteMap[id];
46
34
  // @ts-ignore seems not work
47
35
  if (getScope.indexOf(data) >= 0) {
48
36
  return;
@@ -90,6 +78,9 @@ function remotes(options) {
90
78
  var onInitialized = function(_, external, first) {
91
79
  return handleFunction(external.get, data[1], getScope, 0, onFactory, first);
92
80
  };
81
+ var useRuntimeLoad = [
82
+ "script"
83
+ ].includes(data[3]) && data[4];
93
84
  // eslint-disable-next-line no-var
94
85
  var onFactory = function(factory) {
95
86
  data.p = 1;
@@ -99,8 +90,7 @@ function remotes(options) {
99
90
  };
100
91
  var onRemoteLoaded = function() {
101
92
  try {
102
- var remoteName = sdk.decodeName(remoteInfos[0].name, constant.ENCODE_NAME_PREFIX);
103
- var remoteModuleName = remoteName + data[1].slice(1);
93
+ var remoteModuleName = data[4] + data[1].slice(1);
104
94
  return webpackRequire.federation.instance.loadRemote(remoteModuleName, {
105
95
  loadFactory: false
106
96
  });
@@ -108,9 +98,6 @@ function remotes(options) {
108
98
  onError(error);
109
99
  }
110
100
  };
111
- var useRuntimeLoad = remoteInfos.length === 1 && [
112
- "script"
113
- ].includes(remoteInfos[0].externalType) && remoteInfos[0].name;
114
101
  if (useRuntimeLoad) {
115
102
  handleFunction(onRemoteLoaded, data[2], 0, 0, onFactory, 1);
116
103
  } else {
@@ -120,9 +107,25 @@ function remotes(options) {
120
107
  }
121
108
  }
122
109
 
110
+ function proxyShareScopeMap(__webpack_require__) {
111
+ if (!__webpack_require__.S) {
112
+ return;
113
+ }
114
+ // @ts-ignore FIXME: ideal situation is import type from @module-federation/runtime/type ,but the compile will throw error
115
+ __webpack_require__.S = new Proxy(globalThis.__VMOK__.__SHARE__, {
116
+ get: function get(target, prop, receiver) {
117
+ return globalThis.__VMOK__.__SHARE__[prop];
118
+ },
119
+ set: function set(target, prop, value) {
120
+ globalThis.__VMOK__.__SHARE__[prop] = value;
121
+ return true;
122
+ }
123
+ });
124
+ }
125
+
123
126
  function consumes(options) {
124
127
  var chunkId = options.chunkId, promises = options.promises, chunkMapping = options.chunkMapping, installedModules = options.installedModules, moduleToHandlerMapping = options.moduleToHandlerMapping, webpackRequire = options.webpackRequire;
125
- attachShareScopeMap(webpackRequire);
128
+ proxyShareScopeMap(webpackRequire);
126
129
  if (webpackRequire.o(chunkMapping, chunkId)) {
127
130
  chunkMapping[chunkId].forEach(function(id) {
128
131
  if (webpackRequire.o(installedModules, id)) {
@@ -167,61 +170,8 @@ function consumes(options) {
167
170
  }
168
171
  }
169
172
 
170
- function initializeSharing(param) {
171
- var shareScopeName = param.shareScopeName, webpackRequire = param.webpackRequire, initPromises = param.initPromises, initTokens = param.initTokens, initScope = param.initScope;
172
- if (!initScope) initScope = [];
173
- // handling circular init calls
174
- var initToken = initTokens[shareScopeName];
175
- if (!initToken) initToken = initTokens[shareScopeName] = {};
176
- if (initScope.indexOf(initToken) >= 0) return;
177
- initScope.push(initToken);
178
- var promise = initPromises[shareScopeName];
179
- if (promise) return promise;
180
- var warn = function(msg) {
181
- return typeof console !== "undefined" && console.warn && console.warn(msg);
182
- };
183
- var initExternal = function(id) {
184
- var handleError = function(err) {
185
- return warn("Initialization of sharing external failed: " + err);
186
- };
187
- try {
188
- var module = webpackRequire(id);
189
- if (!module) return;
190
- var initFn = function(module) {
191
- return module && module.init && module.init(webpackRequire.S[shareScopeName], initScope);
192
- };
193
- if (module.then) return promises.push(module.then(initFn, handleError));
194
- var initResult = initFn(module);
195
- // @ts-ignore
196
- if (initResult && typeof initResult !== "boolean" && initResult.then) // @ts-ignore
197
- return promises.push(initResult["catch"](handleError));
198
- } catch (err) {
199
- handleError(err);
200
- }
201
- };
202
- var promises = webpackRequire.federation.instance.initializeSharing(shareScopeName);
203
- attachShareScopeMap(webpackRequire);
204
- var bundlerRuntimeRemotesOptions = webpackRequire.federation.bundlerRuntimeOptions.remotes;
205
- if (bundlerRuntimeRemotesOptions) {
206
- Object.keys(bundlerRuntimeRemotesOptions.idToRemoteMap).forEach(function(moduleId) {
207
- var info = bundlerRuntimeRemotesOptions.idToRemoteMap[moduleId];
208
- var externalModuleId = bundlerRuntimeRemotesOptions.idToExternalAndNameMapping[moduleId][2];
209
- if (info.length > 1) {
210
- initExternal(externalModuleId);
211
- } else if (info.length === 1) {
212
- var remoteInfo = info[0];
213
- if (!constant.FEDERATION_SUPPORTED_TYPES.includes(remoteInfo.externalType)) {
214
- initExternal(externalModuleId);
215
- }
216
- }
217
- });
218
- }
219
- if (!promises.length) {
220
- return initPromises[shareScopeName] = true;
221
- }
222
- return initPromises[shareScopeName] = Promise.all(promises).then(function() {
223
- return initPromises[shareScopeName] = true;
224
- });
173
+ function initializeSharing(shareScopeName, webpackRequire) {
174
+ return webpackRequire.federation.instance.initializeSharing(shareScopeName);
225
175
  }
226
176
 
227
177
  function handleInitialConsumes(options) {
@@ -256,40 +206,6 @@ function installInitialConsumes(options) {
256
206
  });
257
207
  }
258
208
 
259
- function isLegacyHost(shareScope) {
260
- if ("version" in shareScope && typeof shareScope["version"] !== "object") {
261
- return true;
262
- }
263
- if ("region" in shareScope && typeof shareScope["region"] !== "object") {
264
- return true;
265
- }
266
- return false;
267
- }
268
- function initContainerEntry(options) {
269
- var webpackRequire = options.webpackRequire, shareScope = options.shareScope, initScope = options.initScope, shareScopeKey = options.shareScopeKey;
270
- if (!webpackRequire.S) return;
271
- if (!webpackRequire.federation || !webpackRequire.federation.instance || !webpackRequire.federation.initOptions) return;
272
- var name = shareScopeKey || "default";
273
- webpackRequire.federation.instance.initOptions({
274
- name: webpackRequire.federation.initOptions.name,
275
- remotes: []
276
- });
277
- if (isLegacyHost(shareScope)) {
278
- var prevShareScope = globalThis.__FEDERATION__.__SHARE__["default"];
279
- if (prevShareScope) {
280
- webpackRequire.federation.instance.initShareScopeMap(name, prevShareScope);
281
- }
282
- } else {
283
- webpackRequire.federation.instance.initShareScopeMap(name, shareScope);
284
- }
285
- webpackRequire.S[name] = shareScope;
286
- if (webpackRequire.federation.attachShareScopeMap) {
287
- webpackRequire.federation.attachShareScopeMap(webpackRequire);
288
- }
289
- // @ts-ignore
290
- return webpackRequire.I(name, initScope);
291
- }
292
-
293
209
  var federation = {
294
210
  runtime: runtime__namespace,
295
211
  instance: undefined,
@@ -299,11 +215,8 @@ var federation = {
299
215
  consumes: consumes,
300
216
  I: initializeSharing,
301
217
  S: {},
302
- installInitialConsumes: installInitialConsumes,
303
- initContainerEntry: initContainerEntry
304
- },
305
- attachShareScopeMap: attachShareScopeMap,
306
- bundlerRuntimeOptions: {}
218
+ installInitialConsumes: installInitialConsumes
219
+ }
307
220
  };
308
221
 
309
222
  module.exports = federation;
package/dist/index.esm.js CHANGED
@@ -1,18 +1,7 @@
1
1
  import * as runtime from '@module-federation/runtime';
2
- import { decodeName } from '@module-federation/sdk';
3
- import { ENCODE_NAME_PREFIX, FEDERATION_SUPPORTED_TYPES } from './constant.esm.js';
4
-
5
- function attachShareScopeMap(webpackRequire) {
6
- if (!webpackRequire.S || webpackRequire.federation.hasAttachShareScopeMap || !webpackRequire.federation.instance || !webpackRequire.federation.instance.shareScopeMap) {
7
- return;
8
- }
9
- webpackRequire.S = webpackRequire.federation.instance.shareScopeMap;
10
- webpackRequire.federation.hasAttachShareScopeMap = true;
11
- }
12
2
 
13
3
  function remotes(options) {
14
- var chunkId = options.chunkId, promises = options.promises, chunkMapping = options.chunkMapping, idToExternalAndNameMapping = options.idToExternalAndNameMapping, webpackRequire = options.webpackRequire, idToRemoteMap = options.idToRemoteMap;
15
- attachShareScopeMap(webpackRequire);
4
+ var chunkId = options.chunkId, promises = options.promises, chunkMapping = options.chunkMapping, idToExternalAndNameMapping = options.idToExternalAndNameMapping, webpackRequire = options.webpackRequire;
16
5
  if (webpackRequire.o(chunkMapping, chunkId)) {
17
6
  chunkMapping[chunkId].forEach(function(id) {
18
7
  var getScope = webpackRequire.R;
@@ -20,7 +9,6 @@ function remotes(options) {
20
9
  getScope = [];
21
10
  }
22
11
  var data = idToExternalAndNameMapping[id];
23
- var remoteInfos = idToRemoteMap[id];
24
12
  // @ts-ignore seems not work
25
13
  if (getScope.indexOf(data) >= 0) {
26
14
  return;
@@ -68,6 +56,9 @@ function remotes(options) {
68
56
  var onInitialized = function(_, external, first) {
69
57
  return handleFunction(external.get, data[1], getScope, 0, onFactory, first);
70
58
  };
59
+ var useRuntimeLoad = [
60
+ "script"
61
+ ].includes(data[3]) && data[4];
71
62
  // eslint-disable-next-line no-var
72
63
  var onFactory = function(factory) {
73
64
  data.p = 1;
@@ -77,8 +68,7 @@ function remotes(options) {
77
68
  };
78
69
  var onRemoteLoaded = function() {
79
70
  try {
80
- var remoteName = decodeName(remoteInfos[0].name, ENCODE_NAME_PREFIX);
81
- var remoteModuleName = remoteName + data[1].slice(1);
71
+ var remoteModuleName = data[4] + data[1].slice(1);
82
72
  return webpackRequire.federation.instance.loadRemote(remoteModuleName, {
83
73
  loadFactory: false
84
74
  });
@@ -86,9 +76,6 @@ function remotes(options) {
86
76
  onError(error);
87
77
  }
88
78
  };
89
- var useRuntimeLoad = remoteInfos.length === 1 && [
90
- "script"
91
- ].includes(remoteInfos[0].externalType) && remoteInfos[0].name;
92
79
  if (useRuntimeLoad) {
93
80
  handleFunction(onRemoteLoaded, data[2], 0, 0, onFactory, 1);
94
81
  } else {
@@ -98,9 +85,25 @@ function remotes(options) {
98
85
  }
99
86
  }
100
87
 
88
+ function proxyShareScopeMap(__webpack_require__) {
89
+ if (!__webpack_require__.S) {
90
+ return;
91
+ }
92
+ // @ts-ignore FIXME: ideal situation is import type from @module-federation/runtime/type ,but the compile will throw error
93
+ __webpack_require__.S = new Proxy(globalThis.__VMOK__.__SHARE__, {
94
+ get: function get(target, prop, receiver) {
95
+ return globalThis.__VMOK__.__SHARE__[prop];
96
+ },
97
+ set: function set(target, prop, value) {
98
+ globalThis.__VMOK__.__SHARE__[prop] = value;
99
+ return true;
100
+ }
101
+ });
102
+ }
103
+
101
104
  function consumes(options) {
102
105
  var chunkId = options.chunkId, promises = options.promises, chunkMapping = options.chunkMapping, installedModules = options.installedModules, moduleToHandlerMapping = options.moduleToHandlerMapping, webpackRequire = options.webpackRequire;
103
- attachShareScopeMap(webpackRequire);
106
+ proxyShareScopeMap(webpackRequire);
104
107
  if (webpackRequire.o(chunkMapping, chunkId)) {
105
108
  chunkMapping[chunkId].forEach(function(id) {
106
109
  if (webpackRequire.o(installedModules, id)) {
@@ -145,61 +148,8 @@ function consumes(options) {
145
148
  }
146
149
  }
147
150
 
148
- function initializeSharing(param) {
149
- var shareScopeName = param.shareScopeName, webpackRequire = param.webpackRequire, initPromises = param.initPromises, initTokens = param.initTokens, initScope = param.initScope;
150
- if (!initScope) initScope = [];
151
- // handling circular init calls
152
- var initToken = initTokens[shareScopeName];
153
- if (!initToken) initToken = initTokens[shareScopeName] = {};
154
- if (initScope.indexOf(initToken) >= 0) return;
155
- initScope.push(initToken);
156
- var promise = initPromises[shareScopeName];
157
- if (promise) return promise;
158
- var warn = function(msg) {
159
- return typeof console !== "undefined" && console.warn && console.warn(msg);
160
- };
161
- var initExternal = function(id) {
162
- var handleError = function(err) {
163
- return warn("Initialization of sharing external failed: " + err);
164
- };
165
- try {
166
- var module = webpackRequire(id);
167
- if (!module) return;
168
- var initFn = function(module) {
169
- return module && module.init && module.init(webpackRequire.S[shareScopeName], initScope);
170
- };
171
- if (module.then) return promises.push(module.then(initFn, handleError));
172
- var initResult = initFn(module);
173
- // @ts-ignore
174
- if (initResult && typeof initResult !== "boolean" && initResult.then) // @ts-ignore
175
- return promises.push(initResult["catch"](handleError));
176
- } catch (err) {
177
- handleError(err);
178
- }
179
- };
180
- var promises = webpackRequire.federation.instance.initializeSharing(shareScopeName);
181
- attachShareScopeMap(webpackRequire);
182
- var bundlerRuntimeRemotesOptions = webpackRequire.federation.bundlerRuntimeOptions.remotes;
183
- if (bundlerRuntimeRemotesOptions) {
184
- Object.keys(bundlerRuntimeRemotesOptions.idToRemoteMap).forEach(function(moduleId) {
185
- var info = bundlerRuntimeRemotesOptions.idToRemoteMap[moduleId];
186
- var externalModuleId = bundlerRuntimeRemotesOptions.idToExternalAndNameMapping[moduleId][2];
187
- if (info.length > 1) {
188
- initExternal(externalModuleId);
189
- } else if (info.length === 1) {
190
- var remoteInfo = info[0];
191
- if (!FEDERATION_SUPPORTED_TYPES.includes(remoteInfo.externalType)) {
192
- initExternal(externalModuleId);
193
- }
194
- }
195
- });
196
- }
197
- if (!promises.length) {
198
- return initPromises[shareScopeName] = true;
199
- }
200
- return initPromises[shareScopeName] = Promise.all(promises).then(function() {
201
- return initPromises[shareScopeName] = true;
202
- });
151
+ function initializeSharing(shareScopeName, webpackRequire) {
152
+ return webpackRequire.federation.instance.initializeSharing(shareScopeName);
203
153
  }
204
154
 
205
155
  function handleInitialConsumes(options) {
@@ -234,40 +184,6 @@ function installInitialConsumes(options) {
234
184
  });
235
185
  }
236
186
 
237
- function isLegacyHost(shareScope) {
238
- if ("version" in shareScope && typeof shareScope["version"] !== "object") {
239
- return true;
240
- }
241
- if ("region" in shareScope && typeof shareScope["region"] !== "object") {
242
- return true;
243
- }
244
- return false;
245
- }
246
- function initContainerEntry(options) {
247
- var webpackRequire = options.webpackRequire, shareScope = options.shareScope, initScope = options.initScope, shareScopeKey = options.shareScopeKey;
248
- if (!webpackRequire.S) return;
249
- if (!webpackRequire.federation || !webpackRequire.federation.instance || !webpackRequire.federation.initOptions) return;
250
- var name = shareScopeKey || "default";
251
- webpackRequire.federation.instance.initOptions({
252
- name: webpackRequire.federation.initOptions.name,
253
- remotes: []
254
- });
255
- if (isLegacyHost(shareScope)) {
256
- var prevShareScope = globalThis.__FEDERATION__.__SHARE__["default"];
257
- if (prevShareScope) {
258
- webpackRequire.federation.instance.initShareScopeMap(name, prevShareScope);
259
- }
260
- } else {
261
- webpackRequire.federation.instance.initShareScopeMap(name, shareScope);
262
- }
263
- webpackRequire.S[name] = shareScope;
264
- if (webpackRequire.federation.attachShareScopeMap) {
265
- webpackRequire.federation.attachShareScopeMap(webpackRequire);
266
- }
267
- // @ts-ignore
268
- return webpackRequire.I(name, initScope);
269
- }
270
-
271
187
  var federation = {
272
188
  runtime: runtime,
273
189
  instance: undefined,
@@ -277,11 +193,8 @@ var federation = {
277
193
  consumes: consumes,
278
194
  I: initializeSharing,
279
195
  S: {},
280
- installInitialConsumes: installInitialConsumes,
281
- initContainerEntry: initContainerEntry
282
- },
283
- attachShareScopeMap: attachShareScopeMap,
284
- bundlerRuntimeOptions: {}
196
+ installInitialConsumes: installInitialConsumes
197
+ }
285
198
  };
286
199
 
287
200
  export { federation as default };
package/dist/package.json CHANGED
@@ -18,30 +18,8 @@
18
18
  "author": "zhanghang <hanric.zhang@gmail.com>",
19
19
  "main": "./index.cjs.js",
20
20
  "module": "./index.esm.js",
21
- "types": "./dist/index.cjs.d.ts",
21
+ "types": "./index.cjs.d.ts",
22
22
  "dependencies": {
23
- "@module-federation/runtime": "workspace:*",
24
- "@module-federation/sdk": "workspace:*"
25
- },
26
- "exports": {
27
- ".": {
28
- "import": "./dist/index.esm.js",
29
- "require": "./dist/index.cjs.js"
30
- },
31
- "./constant": {
32
- "import": "./dist/constant.esm.js",
33
- "require": "./dist/constant.cjs.js"
34
- },
35
- "./*": "./*"
36
- },
37
- "typesVersions": {
38
- "*": {
39
- ".": [
40
- "./dist/index.cjs.d.ts"
41
- ],
42
- "constant": [
43
- "./dist/constant.cjs.d.ts"
44
- ]
45
- }
23
+ "@module-federation/runtime": "workspace:*"
46
24
  }
47
25
  }
@@ -1,4 +1,3 @@
1
1
  import { Federation } from './types';
2
- export * from './types';
3
2
  declare const federation: Federation;
4
3
  export default federation;
@@ -1,2 +1,2 @@
1
- import { InitializeSharingOptions } from './types';
2
- export declare function initializeSharing({ shareScopeName, webpackRequire, initPromises, initTokens, initScope, }: InitializeSharingOptions): Promise<boolean> | boolean | void;
1
+ import { WebpackRequire } from './types';
2
+ export declare function initializeSharing(shareScopeName: string, webpackRequire: WebpackRequire): Promise<boolean> | boolean;
@@ -1,7 +1,5 @@
1
1
  import * as runtime from '@module-federation/runtime';
2
2
  import { initializeSharing } from './initializeSharing';
3
- import { attachShareScopeMap } from './attachShareScopeMap';
4
- import { initContainerEntry } from './initContainerEntry';
5
3
  type ExcludeUndefined<T> = T extends undefined ? never : T;
6
4
  type NonUndefined<T = Shared> = ExcludeUndefined<T>;
7
5
  type InitOptions = Parameters<typeof runtime.init>[0];
@@ -10,15 +8,6 @@ type SharedConfig = NonUndefined<NonUndefined[string]['shareConfig']>;
10
8
  type ModuleCache = runtime.FederationHost['moduleCache'];
11
9
  type InferModule<T> = T extends Map<string, infer U> ? U : never;
12
10
  type InferredModule = InferModule<ModuleCache>;
13
- export type ShareScopeMap = runtime.FederationHost['shareScopeMap'];
14
- type InitToken = Record<string, Record<string, any>>;
15
- export interface InitializeSharingOptions {
16
- shareScopeName: string;
17
- webpackRequire: WebpackRequire;
18
- initPromises: Record<string, Promise<boolean> | boolean>;
19
- initTokens: InitToken;
20
- initScope: InitToken[];
21
- }
22
11
  export type RemoteEntryExports = NonUndefined<InferredModule['remoteEntryExports']>;
23
12
  type ExtractInitParameters<T> = T extends {
24
13
  init: (shareScope: infer U, ...args: any[]) => void;
@@ -27,7 +16,13 @@ type InferredShareScope = ExtractInitParameters<RemoteEntryExports>;
27
16
  type InferredGlobalShareScope = {
28
17
  [scope: string]: InferredShareScope;
29
18
  };
30
- type IdToExternalAndNameMappingItem = [string, string, string | number];
19
+ type IdToExternalAndNameMappingItem = [
20
+ string,
21
+ string,
22
+ string | number,
23
+ string,
24
+ string
25
+ ];
31
26
  interface IdToExternalAndNameMappingItemWithPromise extends IdToExternalAndNameMappingItem {
32
27
  p?: Promise<any> | number;
33
28
  }
@@ -37,7 +32,7 @@ export interface WebpackRequire {
37
32
  R: Array<string | number>;
38
33
  m: Record<string, (mod: any) => any>;
39
34
  c: Record<string, any>;
40
- I: (scopeName: string, initScope?: InitializeSharingOptions['initScope']) => ReturnType<typeof initializeSharing>;
35
+ I: typeof initializeSharing;
41
36
  S?: InferredGlobalShareScope;
42
37
  federation: Federation;
43
38
  }
@@ -50,17 +45,11 @@ interface ModuleToHandlerMappingItem {
50
45
  shareInfo: ShareInfo;
51
46
  shareKey: string;
52
47
  }
53
- interface IdToRemoteMapItem {
54
- externalType: string;
55
- name: string;
56
- externalModuleId?: string | number;
57
- }
58
48
  export interface RemotesOptions {
59
49
  chunkId: string | number;
60
50
  promises: Promise<any>[];
61
51
  chunkMapping: Record<string, Array<string | number>>;
62
52
  idToExternalAndNameMapping: Record<string, IdToExternalAndNameMappingItemWithPromise>;
63
- idToRemoteMap: Record<string, IdToRemoteMapItem[]>;
64
53
  webpackRequire: WebpackRequire;
65
54
  }
66
55
  export interface HandleInitialConsumesOptions {
@@ -82,12 +71,6 @@ export interface ConsumesOptions {
82
71
  moduleToHandlerMapping: Record<string, ModuleToHandlerMappingItem>;
83
72
  webpackRequire: WebpackRequire;
84
73
  }
85
- export interface InitContainerEntryOptions {
86
- shareScope: ShareScopeMap[string];
87
- shareScopeKey: string;
88
- webpackRequire: WebpackRequire;
89
- initScope?: InitializeSharingOptions['initScope'];
90
- }
91
74
  export interface Federation {
92
75
  runtime?: typeof runtime;
93
76
  instance?: runtime.FederationHost;
@@ -96,15 +79,9 @@ export interface Federation {
96
79
  bundlerRuntime?: {
97
80
  remotes: (options: RemotesOptions) => void;
98
81
  consumes: (options: ConsumesOptions) => void;
99
- I: typeof initializeSharing;
82
+ I: (name: string, webpackRequire: WebpackRequire) => Promise<boolean> | boolean;
100
83
  S: InferredGlobalShareScope;
101
84
  installInitialConsumes: (options: InstallInitialConsumesOptions) => any;
102
- initContainerEntry: typeof initContainerEntry;
103
- };
104
- bundlerRuntimeOptions: {
105
- remotes?: Exclude<RemotesOptions, 'chunkId' | 'promises'>;
106
85
  };
107
- attachShareScopeMap?: typeof attachShareScopeMap;
108
- hasAttachShareScopeMap?: boolean;
109
86
  }
110
87
  export {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "public": true,
3
3
  "name": "@module-federation/webpack-bundler-runtime",
4
- "version": "0.0.0-next-20231225095220",
4
+ "version": "0.0.0-next-20231229025030",
5
5
  "license": "MIT",
6
6
  "description": "Module Federation Runtime for webpack",
7
7
  "keywords": [
@@ -16,32 +16,10 @@
16
16
  "access": "public"
17
17
  },
18
18
  "author": "zhanghang <hanric.zhang@gmail.com>",
19
- "main": "./dist/index.cjs.js",
20
- "module": "./dist/index.esm.js",
21
- "types": "./dist/index.cjs.d.ts",
19
+ "main": "./index.cjs.js",
20
+ "module": "./index.esm.js",
21
+ "types": "./index.cjs.d.ts",
22
22
  "dependencies": {
23
- "@module-federation/runtime": "0.0.0-next-20231225095220",
24
- "@module-federation/sdk": "0.0.0-next-20231225095220"
25
- },
26
- "exports": {
27
- ".": {
28
- "import": "./dist/index.esm.js",
29
- "require": "./dist/index.cjs.js"
30
- },
31
- "./constant": {
32
- "import": "./dist/constant.esm.js",
33
- "require": "./dist/constant.cjs.js"
34
- },
35
- "./*": "./*"
36
- },
37
- "typesVersions": {
38
- "*": {
39
- ".": [
40
- "./dist/index.cjs.d.ts"
41
- ],
42
- "constant": [
43
- "./dist/constant.cjs.d.ts"
44
- ]
45
- }
23
+ "@module-federation/runtime": "0.0.0-next-20231229025030"
46
24
  }
47
25
  }
package/dist/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2023-present zhanghang(2heal1)
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
@@ -1 +0,0 @@
1
- export * from "./src/constant";
@@ -1,11 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var FEDERATION_SUPPORTED_TYPES = [
6
- "script"
7
- ];
8
- var ENCODE_NAME_PREFIX = "ENCODE_NAME_PREFIX";
9
-
10
- exports.ENCODE_NAME_PREFIX = ENCODE_NAME_PREFIX;
11
- exports.FEDERATION_SUPPORTED_TYPES = FEDERATION_SUPPORTED_TYPES;
@@ -1,6 +0,0 @@
1
- var FEDERATION_SUPPORTED_TYPES = [
2
- "script"
3
- ];
4
- var ENCODE_NAME_PREFIX = "ENCODE_NAME_PREFIX";
5
-
6
- export { ENCODE_NAME_PREFIX, FEDERATION_SUPPORTED_TYPES };
@@ -1,2 +0,0 @@
1
- import { WebpackRequire } from './types';
2
- export declare function attachShareScopeMap(webpackRequire: WebpackRequire): void;
@@ -1,2 +0,0 @@
1
- export declare const FEDERATION_SUPPORTED_TYPES: string[];
2
- export declare const ENCODE_NAME_PREFIX = "ENCODE_NAME_PREFIX";
@@ -1,2 +0,0 @@
1
- import { InitContainerEntryOptions, WebpackRequire } from './types';
2
- export declare function initContainerEntry(options: InitContainerEntryOptions): WebpackRequire['I'] | void;