@module-federation/webpack-bundler-runtime 0.0.0-next-20240930063850 → 0.0.0-next-20240930091801

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.esm.js CHANGED
@@ -1,7 +1,6 @@
1
1
  import * as runtime from '@module-federation/runtime';
2
2
  import { FEDERATION_SUPPORTED_TYPES } from './constant.esm.js';
3
3
  import { decodeName, ENCODE_NAME_PREFIX } from '@module-federation/sdk';
4
- import { _ as _extends } from './polyfills.esm.js';
5
4
 
6
5
  function attachShareScopeMap(webpackRequire) {
7
6
  if (!webpackRequire.S || webpackRequire.federation.hasAttachShareScopeMap || !webpackRequire.federation.instance || !webpackRequire.federation.instance.shareScopeMap) {
@@ -12,16 +11,16 @@ function attachShareScopeMap(webpackRequire) {
12
11
  }
13
12
 
14
13
  function remotes(options) {
15
- const { chunkId, promises, chunkMapping, idToExternalAndNameMapping, webpackRequire, idToRemoteMap } = options;
14
+ var chunkId = options.chunkId, promises = options.promises, chunkMapping = options.chunkMapping, idToExternalAndNameMapping = options.idToExternalAndNameMapping, webpackRequire = options.webpackRequire, idToRemoteMap = options.idToRemoteMap;
16
15
  attachShareScopeMap(webpackRequire);
17
16
  if (webpackRequire.o(chunkMapping, chunkId)) {
18
- chunkMapping[chunkId].forEach((id)=>{
19
- let getScope = webpackRequire.R;
17
+ chunkMapping[chunkId].forEach(function(id) {
18
+ var getScope = webpackRequire.R;
20
19
  if (!getScope) {
21
20
  getScope = [];
22
21
  }
23
- const data = idToExternalAndNameMapping[id];
24
- const remoteInfos = idToRemoteMap[id];
22
+ var data = idToExternalAndNameMapping[id];
23
+ var remoteInfos = idToRemoteMap[id];
25
24
  // @ts-ignore seems not work
26
25
  if (getScope.indexOf(data) >= 0) {
27
26
  return;
@@ -31,23 +30,25 @@ function remotes(options) {
31
30
  if (data.p) {
32
31
  return promises.push(data.p);
33
32
  }
34
- const onError = (error)=>{
33
+ var onError = function(error) {
35
34
  if (!error) {
36
35
  error = new Error('Container missing');
37
36
  }
38
37
  if (typeof error.message === 'string') {
39
- error.message += `\nwhile loading "${data[1]}" from ${data[2]}`;
38
+ error.message += '\nwhile loading "'.concat(data[1], '" from ').concat(data[2]);
40
39
  }
41
- webpackRequire.m[id] = ()=>{
40
+ webpackRequire.m[id] = function() {
42
41
  throw error;
43
42
  };
44
43
  data.p = 0;
45
44
  };
46
- const handleFunction = (fn, arg1, arg2, d, next, first)=>{
45
+ var handleFunction = function(fn, arg1, arg2, d, next, first) {
47
46
  try {
48
- const promise = fn(arg1, arg2);
47
+ var promise = fn(arg1, arg2);
49
48
  if (promise && promise.then) {
50
- const p = promise.then((result)=>next(result, d), onError);
49
+ var p = promise.then(function(result) {
50
+ return next(result, d);
51
+ }, onError);
51
52
  if (first) {
52
53
  promises.push(data.p = p);
53
54
  } else {
@@ -60,20 +61,24 @@ function remotes(options) {
60
61
  onError(error);
61
62
  }
62
63
  };
63
- const onExternal = (external, _, first)=>external ? handleFunction(webpackRequire.I, data[0], 0, external, onInitialized, first) : onError();
64
+ var onExternal = function(external, _, first) {
65
+ return external ? handleFunction(webpackRequire.I, data[0], 0, external, onInitialized, first) : onError();
66
+ };
64
67
  // eslint-disable-next-line no-var
65
- var onInitialized = (_, external, first)=>handleFunction(external.get, data[1], getScope, 0, onFactory, first);
68
+ var onInitialized = function(_, external, first) {
69
+ return handleFunction(external.get, data[1], getScope, 0, onFactory, first);
70
+ };
66
71
  // eslint-disable-next-line no-var
67
- var onFactory = (factory)=>{
72
+ var onFactory = function(factory) {
68
73
  data.p = 1;
69
- webpackRequire.m[id] = (module)=>{
74
+ webpackRequire.m[id] = function(module) {
70
75
  module.exports = factory();
71
76
  };
72
77
  };
73
- const onRemoteLoaded = ()=>{
78
+ var onRemoteLoaded = function() {
74
79
  try {
75
- const remoteName = decodeName(remoteInfos[0].name, ENCODE_NAME_PREFIX);
76
- const remoteModuleName = remoteName + data[1].slice(1);
80
+ var remoteName = decodeName(remoteInfos[0].name, ENCODE_NAME_PREFIX);
81
+ var remoteModuleName = remoteName + data[1].slice(1);
77
82
  return webpackRequire.federation.instance.loadRemote(remoteModuleName, {
78
83
  loadFactory: false,
79
84
  from: 'build'
@@ -82,7 +87,7 @@ function remotes(options) {
82
87
  onError(error);
83
88
  }
84
89
  };
85
- const useRuntimeLoad = remoteInfos.length === 1 && FEDERATION_SUPPORTED_TYPES.includes(remoteInfos[0].externalType) && remoteInfos[0].name;
90
+ var useRuntimeLoad = remoteInfos.length === 1 && FEDERATION_SUPPORTED_TYPES.includes(remoteInfos[0].externalType) && remoteInfos[0].name;
86
91
  if (useRuntimeLoad) {
87
92
  handleFunction(onRemoteLoaded, data[2], 0, 0, onFactory, 1);
88
93
  } else {
@@ -93,36 +98,36 @@ function remotes(options) {
93
98
  }
94
99
 
95
100
  function consumes(options) {
96
- const { chunkId, promises, chunkMapping, installedModules, moduleToHandlerMapping, webpackRequire } = options;
101
+ var chunkId = options.chunkId, promises = options.promises, chunkMapping = options.chunkMapping, installedModules = options.installedModules, moduleToHandlerMapping = options.moduleToHandlerMapping, webpackRequire = options.webpackRequire;
97
102
  attachShareScopeMap(webpackRequire);
98
103
  if (webpackRequire.o(chunkMapping, chunkId)) {
99
- chunkMapping[chunkId].forEach((id)=>{
104
+ chunkMapping[chunkId].forEach(function(id) {
100
105
  if (webpackRequire.o(installedModules, id)) {
101
106
  return promises.push(installedModules[id]);
102
107
  }
103
- const onFactory = (factory)=>{
108
+ var onFactory = function(factory) {
104
109
  installedModules[id] = 0;
105
- webpackRequire.m[id] = (module)=>{
110
+ webpackRequire.m[id] = function(module) {
106
111
  delete webpackRequire.c[id];
107
112
  module.exports = factory();
108
113
  };
109
114
  };
110
- const onError = (error)=>{
115
+ var onError = function(error) {
111
116
  delete installedModules[id];
112
- webpackRequire.m[id] = (module)=>{
117
+ webpackRequire.m[id] = function(module) {
113
118
  delete webpackRequire.c[id];
114
119
  throw error;
115
120
  };
116
121
  };
117
122
  try {
118
- const federationInstance = webpackRequire.federation.instance;
123
+ var federationInstance = webpackRequire.federation.instance;
119
124
  if (!federationInstance) {
120
125
  throw new Error('Federation instance not found!');
121
126
  }
122
- const { shareKey, getter, shareInfo } = moduleToHandlerMapping[id];
123
- const promise = federationInstance.loadShare(shareKey, {
127
+ var _moduleToHandlerMapping_id = moduleToHandlerMapping[id], shareKey = _moduleToHandlerMapping_id.shareKey, getter = _moduleToHandlerMapping_id.getter, shareInfo = _moduleToHandlerMapping_id.shareInfo;
128
+ var promise = federationInstance.loadShare(shareKey, {
124
129
  customShareInfo: shareInfo
125
- }).then((factory)=>{
130
+ }).then(function(factory) {
126
131
  if (factory === false) {
127
132
  return getter();
128
133
  }
@@ -141,9 +146,10 @@ function consumes(options) {
141
146
  }
142
147
  }
143
148
 
144
- function initializeSharing({ shareScopeName, webpackRequire, initPromises, initTokens, initScope }) {
149
+ function initializeSharing(param) {
150
+ var shareScopeName = param.shareScopeName, webpackRequire = param.webpackRequire, initPromises = param.initPromises, initTokens = param.initTokens, initScope = param.initScope;
145
151
  if (!initScope) initScope = [];
146
- const mfInstance = webpackRequire.federation.instance;
152
+ var mfInstance = webpackRequire.federation.instance;
147
153
  // handling circular init calls
148
154
  var initToken = initTokens[shareScopeName];
149
155
  if (!initToken) initToken = initTokens[shareScopeName] = {
@@ -151,16 +157,22 @@ function initializeSharing({ shareScopeName, webpackRequire, initPromises, initT
151
157
  };
152
158
  if (initScope.indexOf(initToken) >= 0) return;
153
159
  initScope.push(initToken);
154
- const promise = initPromises[shareScopeName];
160
+ var promise = initPromises[shareScopeName];
155
161
  if (promise) return promise;
156
- var warn = (msg)=>typeof console !== 'undefined' && console.warn && console.warn(msg);
157
- var initExternal = (id)=>{
158
- var handleError = (err)=>warn('Initialization of sharing external failed: ' + err);
162
+ var warn = function(msg) {
163
+ return typeof console !== 'undefined' && console.warn && console.warn(msg);
164
+ };
165
+ var initExternal = function(id) {
166
+ var handleError = function(err) {
167
+ return warn('Initialization of sharing external failed: ' + err);
168
+ };
159
169
  try {
160
170
  var module = webpackRequire(id);
161
171
  if (!module) return;
162
- var initFn = (module)=>module && module.init && // @ts-ignore compat legacy mf shared behavior
172
+ var initFn = function(module) {
173
+ return module && module.init && // @ts-ignore compat legacy mf shared behavior
163
174
  module.init(webpackRequire.S[shareScopeName], initScope);
175
+ };
164
176
  if (module.then) return promises.push(module.then(initFn, handleError));
165
177
  var initResult = initFn(module);
166
178
  // @ts-ignore
@@ -170,21 +182,21 @@ function initializeSharing({ shareScopeName, webpackRequire, initPromises, initT
170
182
  handleError(err);
171
183
  }
172
184
  };
173
- const promises = mfInstance.initializeSharing(shareScopeName, {
185
+ var promises = mfInstance.initializeSharing(shareScopeName, {
174
186
  strategy: mfInstance.options.shareStrategy,
175
- initScope,
187
+ initScope: initScope,
176
188
  from: 'build'
177
189
  });
178
190
  attachShareScopeMap(webpackRequire);
179
- const bundlerRuntimeRemotesOptions = webpackRequire.federation.bundlerRuntimeOptions.remotes;
191
+ var bundlerRuntimeRemotesOptions = webpackRequire.federation.bundlerRuntimeOptions.remotes;
180
192
  if (bundlerRuntimeRemotesOptions) {
181
- Object.keys(bundlerRuntimeRemotesOptions.idToRemoteMap).forEach((moduleId)=>{
182
- const info = bundlerRuntimeRemotesOptions.idToRemoteMap[moduleId];
183
- const externalModuleId = bundlerRuntimeRemotesOptions.idToExternalAndNameMapping[moduleId][2];
193
+ Object.keys(bundlerRuntimeRemotesOptions.idToRemoteMap).forEach(function(moduleId) {
194
+ var info = bundlerRuntimeRemotesOptions.idToRemoteMap[moduleId];
195
+ var externalModuleId = bundlerRuntimeRemotesOptions.idToExternalAndNameMapping[moduleId][2];
184
196
  if (info.length > 1) {
185
197
  initExternal(externalModuleId);
186
198
  } else if (info.length === 1) {
187
- const remoteInfo = info[0];
199
+ var remoteInfo = info[0];
188
200
  if (!FEDERATION_SUPPORTED_TYPES.includes(remoteInfo.externalType)) {
189
201
  initExternal(externalModuleId);
190
202
  }
@@ -194,16 +206,18 @@ function initializeSharing({ shareScopeName, webpackRequire, initPromises, initT
194
206
  if (!promises.length) {
195
207
  return initPromises[shareScopeName] = true;
196
208
  }
197
- return initPromises[shareScopeName] = Promise.all(promises).then(()=>initPromises[shareScopeName] = true);
209
+ return initPromises[shareScopeName] = Promise.all(promises).then(function() {
210
+ return initPromises[shareScopeName] = true;
211
+ });
198
212
  }
199
213
 
200
214
  function handleInitialConsumes(options) {
201
- const { moduleId, moduleToHandlerMapping, webpackRequire } = options;
202
- const federationInstance = webpackRequire.federation.instance;
215
+ var moduleId = options.moduleId, moduleToHandlerMapping = options.moduleToHandlerMapping, webpackRequire = options.webpackRequire;
216
+ var federationInstance = webpackRequire.federation.instance;
203
217
  if (!federationInstance) {
204
218
  throw new Error('Federation instance not found!');
205
219
  }
206
- const { shareKey, shareInfo } = moduleToHandlerMapping[moduleId];
220
+ var _moduleToHandlerMapping_moduleId = moduleToHandlerMapping[moduleId], shareKey = _moduleToHandlerMapping_moduleId.shareKey, shareInfo = _moduleToHandlerMapping_moduleId.shareInfo;
207
221
  try {
208
222
  return federationInstance.loadShareSync(shareKey, {
209
223
  customShareInfo: shareInfo
@@ -215,37 +229,65 @@ function handleInitialConsumes(options) {
215
229
  }
216
230
  }
217
231
  function installInitialConsumes(options) {
218
- const { moduleToHandlerMapping, webpackRequire, installedModules, initialConsumes } = options;
219
- initialConsumes.forEach((id)=>{
220
- webpackRequire.m[id] = (module)=>{
232
+ var moduleToHandlerMapping = options.moduleToHandlerMapping, webpackRequire = options.webpackRequire, installedModules = options.installedModules, initialConsumes = options.initialConsumes;
233
+ initialConsumes.forEach(function(id) {
234
+ webpackRequire.m[id] = function(module) {
221
235
  // Handle scenario when module is used synchronously
222
236
  installedModules[id] = 0;
223
237
  delete webpackRequire.c[id];
224
- const factory = handleInitialConsumes({
238
+ var factory = handleInitialConsumes({
225
239
  moduleId: id,
226
- moduleToHandlerMapping,
227
- webpackRequire
240
+ moduleToHandlerMapping: moduleToHandlerMapping,
241
+ webpackRequire: webpackRequire
228
242
  });
229
243
  if (typeof factory !== 'function') {
230
- throw new Error(`Shared module is not available for eager consumption: ${id}`);
244
+ throw new Error("Shared module is not available for eager consumption: ".concat(id));
231
245
  }
232
246
  module.exports = factory();
233
247
  };
234
248
  });
235
249
  }
236
250
 
251
+ function _define_property(obj, key, value) {
252
+ if (key in obj) {
253
+ Object.defineProperty(obj, key, {
254
+ value: value,
255
+ enumerable: true,
256
+ configurable: true,
257
+ writable: true
258
+ });
259
+ } else {
260
+ obj[key] = value;
261
+ }
262
+ return obj;
263
+ }
264
+ function _object_spread(target) {
265
+ for(var i = 1; i < arguments.length; i++){
266
+ var source = arguments[i] != null ? arguments[i] : {};
267
+ var ownKeys = Object.keys(source);
268
+ if (typeof Object.getOwnPropertySymbols === "function") {
269
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
270
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
271
+ }));
272
+ }
273
+ ownKeys.forEach(function(key) {
274
+ _define_property(target, key, source[key]);
275
+ });
276
+ }
277
+ return target;
278
+ }
237
279
  function initContainerEntry(options) {
238
- const { webpackRequire, shareScope, initScope, shareScopeKey, remoteEntryInitOptions } = options;
280
+ var webpackRequire = options.webpackRequire, shareScope = options.shareScope, initScope = options.initScope, shareScopeKey = options.shareScopeKey, remoteEntryInitOptions = options.remoteEntryInitOptions;
239
281
  if (!webpackRequire.S) return;
240
282
  if (!webpackRequire.federation || !webpackRequire.federation.instance || !webpackRequire.federation.initOptions) return;
241
- const federationInstance = webpackRequire.federation.instance;
283
+ var federationInstance = webpackRequire.federation.instance;
242
284
  var name = shareScopeKey || 'default';
243
- federationInstance.initOptions(_extends({
285
+ federationInstance.initOptions(_object_spread({
244
286
  name: webpackRequire.federation.initOptions.name,
245
287
  remotes: []
246
288
  }, remoteEntryInitOptions));
247
289
  federationInstance.initShareScopeMap(name, shareScope, {
248
- hostShareScopeMap: (remoteEntryInitOptions == null ? void 0 : remoteEntryInitOptions.shareScopeMap) || {}
290
+ hostShareScopeMap: (remoteEntryInitOptions === null || remoteEntryInitOptions === void 0 ? void 0 : remoteEntryInitOptions.shareScopeMap) || {}
249
291
  });
250
292
  if (webpackRequire.federation.attachShareScopeMap) {
251
293
  webpackRequire.federation.attachShareScopeMap(webpackRequire);
@@ -257,19 +299,19 @@ function initContainerEntry(options) {
257
299
  return webpackRequire.I(name, initScope);
258
300
  }
259
301
 
260
- const federation = {
261
- runtime,
302
+ var federation = {
303
+ runtime: runtime,
262
304
  instance: undefined,
263
305
  initOptions: undefined,
264
306
  bundlerRuntime: {
265
- remotes,
266
- consumes,
307
+ remotes: remotes,
308
+ consumes: consumes,
267
309
  I: initializeSharing,
268
310
  S: {},
269
- installInitialConsumes,
270
- initContainerEntry
311
+ installInitialConsumes: installInitialConsumes,
312
+ initContainerEntry: initContainerEntry
271
313
  },
272
- attachShareScopeMap,
314
+ attachShareScopeMap: attachShareScopeMap,
273
315
  bundlerRuntimeOptions: {}
274
316
  };
275
317
 
package/dist/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "public": true,
3
3
  "name": "@module-federation/webpack-bundler-runtime",
4
- "version": "0.6.7",
4
+ "version": "0.6.6",
5
5
  "license": "MIT",
6
6
  "description": "Module Federation Runtime for webpack",
7
7
  "keywords": [
@@ -51,4 +51,4 @@
51
51
  "devDependencies": {
52
52
  "@module-federation/runtime": "workspace:*"
53
53
  }
54
- }
54
+ }
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-20240930063850",
4
+ "version": "0.0.0-next-20240930091801",
5
5
  "license": "MIT",
6
6
  "description": "Module Federation Runtime for webpack",
7
7
  "keywords": [
@@ -20,8 +20,8 @@
20
20
  "module": "./dist/index.esm.js",
21
21
  "types": "./dist/index.cjs.d.ts",
22
22
  "dependencies": {
23
- "@module-federation/sdk": "0.0.0-next-20240930063850",
24
- "@module-federation/runtime": "0.0.0-next-20240930063850"
23
+ "@module-federation/runtime": "0.0.0-next-20240930091801",
24
+ "@module-federation/sdk": "0.0.0-next-20240930091801"
25
25
  },
26
26
  "exports": {
27
27
  ".": {
@@ -49,6 +49,6 @@
49
49
  }
50
50
  },
51
51
  "devDependencies": {
52
- "@module-federation/runtime": "0.0.0-next-20240930063850"
52
+ "@module-federation/runtime": "0.0.0-next-20240930091801"
53
53
  }
54
54
  }
@@ -1 +0,0 @@
1
- export * from "./src/constant";
@@ -1 +0,0 @@
1
- export * from "./src/container";
@@ -1,2 +0,0 @@
1
- export * from "./src/index";
2
- export { default } from "./src/index";
@@ -1,14 +0,0 @@
1
- 'use strict';
2
-
3
- function _extends() {
4
- _extends = Object.assign || function assign(target) {
5
- for(var i = 1; i < arguments.length; i++){
6
- var source = arguments[i];
7
- for(var key in source)if (Object.prototype.hasOwnProperty.call(source, key)) target[key] = source[key];
8
- }
9
- return target;
10
- };
11
- return _extends.apply(this, arguments);
12
- }
13
-
14
- exports._extends = _extends;
@@ -1,12 +0,0 @@
1
- function _extends() {
2
- _extends = Object.assign || function assign(target) {
3
- for(var i = 1; i < arguments.length; i++){
4
- var source = arguments[i];
5
- for(var key in source)if (Object.prototype.hasOwnProperty.call(source, key)) target[key] = source[key];
6
- }
7
- return target;
8
- };
9
- return _extends.apply(this, arguments);
10
- }
11
-
12
- export { _extends as _ };