@module-federation/webpack-bundler-runtime 0.6.6 → 0.6.8

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.
@@ -1,14 +1,12 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
3
  var sdk = require('@module-federation/sdk');
6
4
 
7
- var FEDERATION_SUPPORTED_TYPES = [
5
+ const FEDERATION_SUPPORTED_TYPES = [
8
6
  'script'
9
7
  ];
10
8
 
11
- Object.defineProperty(exports, 'ENCODE_NAME_PREFIX', {
9
+ Object.defineProperty(exports, "ENCODE_NAME_PREFIX", {
12
10
  enumerable: true,
13
11
  get: function () { return sdk.ENCODE_NAME_PREFIX; }
14
12
  });
@@ -0,0 +1 @@
1
+ export * from "./src/constant";
@@ -1,6 +1,6 @@
1
1
  export { ENCODE_NAME_PREFIX } from '@module-federation/sdk';
2
2
 
3
- var FEDERATION_SUPPORTED_TYPES = [
3
+ const FEDERATION_SUPPORTED_TYPES = [
4
4
  'script'
5
5
  ];
6
6
 
@@ -1,160 +1,30 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
3
  var index = require('./index.cjs.js');
6
4
  require('@module-federation/runtime');
7
5
  require('./constant.cjs.js');
8
6
  require('@module-federation/sdk');
7
+ require('./polyfills.cjs.js');
9
8
 
10
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
11
- try {
12
- var info = gen[key](arg);
13
- var value = info.value;
14
- } catch (error) {
15
- reject(error);
16
- return;
17
- }
18
- if (info.done) {
19
- resolve(value);
20
- } else {
21
- Promise.resolve(value).then(_next, _throw);
22
- }
23
- }
24
- function _async_to_generator(fn) {
25
- return function() {
26
- var self = this, args = arguments;
27
- return new Promise(function(resolve, reject) {
28
- var gen = fn.apply(self, args);
29
- function _next(value) {
30
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
31
- }
32
- function _throw(err) {
33
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
34
- }
35
- _next(undefined);
36
- });
37
- };
38
- }
39
- function _type_of(obj) {
40
- "@swc/helpers - typeof";
41
- return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
42
- }
43
- function _ts_generator(thisArg, body) {
44
- var f, y, t, g, _ = {
45
- label: 0,
46
- sent: function() {
47
- if (t[0] & 1) throw t[1];
48
- return t[1];
49
- },
50
- trys: [],
51
- ops: []
52
- };
53
- return g = {
54
- next: verb(0),
55
- "throw": verb(1),
56
- "return": verb(2)
57
- }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
58
- return this;
59
- }), g;
60
- function verb(n) {
61
- return function(v) {
62
- return step([
63
- n,
64
- v
65
- ]);
66
- };
67
- }
68
- function step(op) {
69
- if (f) throw new TypeError("Generator is already executing.");
70
- while(_)try {
71
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
72
- if (y = 0, t) op = [
73
- op[0] & 2,
74
- t.value
75
- ];
76
- switch(op[0]){
77
- case 0:
78
- case 1:
79
- t = op;
80
- break;
81
- case 4:
82
- _.label++;
83
- return {
84
- value: op[1],
85
- done: false
86
- };
87
- case 5:
88
- _.label++;
89
- y = op[1];
90
- op = [
91
- 0
92
- ];
93
- continue;
94
- case 7:
95
- op = _.ops.pop();
96
- _.trys.pop();
97
- continue;
98
- default:
99
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
100
- _ = 0;
101
- continue;
102
- }
103
- if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
104
- _.label = op[1];
105
- break;
106
- }
107
- if (op[0] === 6 && _.label < t[1]) {
108
- _.label = t[1];
109
- t = op;
110
- break;
111
- }
112
- if (t && _.label < t[2]) {
113
- _.label = t[2];
114
- _.ops.push(op);
115
- break;
116
- }
117
- if (t[2]) _.ops.pop();
118
- _.trys.pop();
119
- continue;
120
- }
121
- op = body.call(thisArg, _);
122
- } catch (e) {
123
- op = [
124
- 6,
125
- e
126
- ];
127
- y = 0;
128
- } finally{
129
- f = t = 0;
130
- }
131
- if (op[0] & 5) throw op[1];
132
- return {
133
- value: op[0] ? op[1] : void 0,
134
- done: true
135
- };
136
- }
137
- }
138
- var _this = undefined;
139
- var createContainer = function(federationOptions) {
140
- var exposes = federationOptions.exposes, name = federationOptions.name, _federationOptions_remotes = federationOptions.remotes, remotes = _federationOptions_remotes === void 0 ? [] : _federationOptions_remotes, shared = federationOptions.shared, plugins = federationOptions.plugins;
141
- var __webpack_modules__ = {
142
- './node_modules/.federation/entry.1f2288102e035e2ed66b2efaf60ad043.js': function(//@ts-ignore
9
+ const createContainer = (federationOptions)=>{
10
+ const { exposes, name, remotes = [], shared, plugins } = federationOptions;
11
+ const __webpack_modules__ = {
12
+ './node_modules/.federation/entry.1f2288102e035e2ed66b2efaf60ad043.js': (//@ts-ignore
143
13
  module, //@ts-ignore
144
14
  __webpack_exports__, //@ts-ignore
145
- __webpack_require__) {
15
+ __webpack_require__)=>{
146
16
  __webpack_require__.r(__webpack_exports__);
147
- var bundler_runtime = __webpack_require__.n(index);
148
- var prevFederation = __webpack_require__.federation;
17
+ const bundler_runtime = __webpack_require__.n(index);
18
+ const prevFederation = __webpack_require__.federation;
149
19
  __webpack_require__.federation = {};
150
- for(var key in bundler_runtime()){
20
+ for(const key in bundler_runtime()){
151
21
  __webpack_require__.federation[key] = bundler_runtime()[key];
152
22
  }
153
- for(var key1 in prevFederation){
154
- __webpack_require__.federation[key1] = prevFederation[key1];
23
+ for(const key in prevFederation){
24
+ __webpack_require__.federation[key] = prevFederation[key];
155
25
  }
156
26
  if (!__webpack_require__.federation.instance) {
157
- var pluginsToAdd = plugins || [];
27
+ const pluginsToAdd = plugins || [];
158
28
  __webpack_require__.federation.initOptions.plugins = __webpack_require__.federation.initOptions.plugins ? __webpack_require__.federation.initOptions.plugins.concat(pluginsToAdd) : pluginsToAdd;
159
29
  __webpack_require__.federation.instance = __webpack_require__.federation.runtime.init(__webpack_require__.federation.initOptions);
160
30
  if (__webpack_require__.federation.attachShareScopeMap) {
@@ -166,35 +36,28 @@ var createContainer = function(federationOptions) {
166
36
  }
167
37
  },
168
38
  //@ts-ignore
169
- 'webpack/container/entry/createContainer': function(//@ts-ignore
39
+ 'webpack/container/entry/createContainer': (//@ts-ignore
170
40
  module, //@ts-ignore
171
41
  exports, //@ts-ignore
172
- __webpack_require__) {
173
- var _loop = function(key) {
42
+ __webpack_require__)=>{
43
+ const moduleMap = {};
44
+ for(const key in exposes){
174
45
  if (Object.prototype.hasOwnProperty.call(exposes, key)) {
175
46
  //@ts-ignore
176
- moduleMap[key] = function() {
177
- return Promise.resolve(exposes[key]()).then(function(m) {
178
- return function() {
179
- return m;
180
- };
181
- });
182
- };
47
+ moduleMap[key] = ()=>Promise.resolve(exposes[key]()).then((m)=>()=>m);
183
48
  }
184
- };
185
- var moduleMap = {};
186
- for(var key in exposes)_loop(key);
49
+ }
187
50
  //@ts-ignore
188
- var get = function(module, getScope) {
51
+ const get = (module, getScope)=>{
189
52
  __webpack_require__.R = getScope;
190
- getScope = __webpack_require__.o(moduleMap, module) ? moduleMap[module]() : Promise.resolve().then(function() {
191
- throw new Error('Module "'.concat(module, '" does not exist in container.'));
53
+ getScope = __webpack_require__.o(moduleMap, module) ? moduleMap[module]() : Promise.resolve().then(()=>{
54
+ throw new Error(`Module "${module}" does not exist in container.`);
192
55
  });
193
56
  __webpack_require__.R = undefined;
194
57
  return getScope;
195
58
  };
196
59
  //@ts-ignore
197
- var init = function(shareScope, initScope, remoteEntryInitOptions) {
60
+ const init = (shareScope, initScope, remoteEntryInitOptions)=>{
198
61
  return __webpack_require__.federation.bundlerRuntime.initContainerEntry({
199
62
  webpackRequire: __webpack_require__,
200
63
  shareScope: shareScope,
@@ -206,40 +69,34 @@ var createContainer = function(federationOptions) {
206
69
  __webpack_require__('./node_modules/.federation/entry.1f2288102e035e2ed66b2efaf60ad043.js');
207
70
  // This exports getters to disallow modifications
208
71
  __webpack_require__.d(exports, {
209
- get: function() {
210
- return get;
211
- },
212
- init: function() {
213
- return init;
214
- },
215
- moduleMap: function() {
216
- return moduleMap;
217
- }
72
+ get: ()=>get,
73
+ init: ()=>init,
74
+ moduleMap: ()=>moduleMap
218
75
  });
219
76
  }
220
77
  };
221
- var __webpack_module_cache__ = {};
78
+ const __webpack_module_cache__ = {};
222
79
  //@ts-ignore
223
- var __webpack_require__ = function(moduleId) {
80
+ const __webpack_require__ = (moduleId)=>{
224
81
  //@ts-ignore
225
- var cachedModule = __webpack_module_cache__[moduleId];
82
+ let cachedModule = __webpack_module_cache__[moduleId];
226
83
  if (cachedModule !== undefined) {
227
84
  return cachedModule.exports;
228
85
  }
229
86
  //@ts-ignore
230
- var module = __webpack_module_cache__[moduleId] = {
87
+ let module = __webpack_module_cache__[moduleId] = {
231
88
  id: moduleId,
232
89
  loaded: false,
233
90
  exports: {}
234
91
  };
235
- var execOptions = {
92
+ const execOptions = {
236
93
  id: moduleId,
237
94
  module: module,
238
95
  //@ts-ignore
239
96
  factory: __webpack_modules__[moduleId],
240
97
  require: __webpack_require__
241
98
  };
242
- __webpack_require__.i.forEach(function(handler) {
99
+ __webpack_require__.i.forEach((handler)=>{
243
100
  handler(execOptions);
244
101
  });
245
102
  module = execOptions.module;
@@ -257,40 +114,32 @@ var createContainer = function(federationOptions) {
257
114
  initOptions: {
258
115
  name: name,
259
116
  //@ts-ignore
260
- remotes: remotes.map(function(remote) {
261
- return {
117
+ remotes: remotes.map((remote)=>({
262
118
  type: remote.type,
263
119
  alias: remote.alias,
264
120
  name: remote.name,
265
121
  //@ts-ignore
266
122
  entry: remote.entry,
267
123
  shareScope: remote.shareScope || 'default'
268
- };
269
- })
270
- },
271
- chunkMatcher: function() {
272
- return true;
124
+ }))
273
125
  },
126
+ chunkMatcher: ()=>true,
274
127
  rootOutputDir: '',
275
128
  initialConsumes: undefined,
276
129
  bundlerRuntimeOptions: {}
277
130
  };
278
131
  }
279
132
  //@ts-ignore
280
- __webpack_require__.n = function(module) {
281
- var getter = module && module.__esModule ? function() {
282
- return module['default'];
283
- } : function() {
284
- return module;
285
- };
133
+ __webpack_require__.n = (module)=>{
134
+ const getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
286
135
  __webpack_require__.d(getter, {
287
136
  a: getter
288
137
  });
289
138
  return getter;
290
139
  };
291
140
  //@ts-ignore
292
- __webpack_require__.d = function(exports, definition) {
293
- for(var key in definition){
141
+ __webpack_require__.d = (exports, definition)=>{
142
+ for(const key in definition){
294
143
  if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
295
144
  Object.defineProperty(exports, key, {
296
145
  enumerable: true,
@@ -300,20 +149,18 @@ var createContainer = function(federationOptions) {
300
149
  }
301
150
  };
302
151
  __webpack_require__.f = {};
303
- __webpack_require__.g = function() {
304
- if ((typeof globalThis === "undefined" ? "undefined" : _type_of(globalThis)) === 'object') return globalThis;
152
+ __webpack_require__.g = (()=>{
153
+ if (typeof globalThis === 'object') return globalThis;
305
154
  try {
306
- return _this || new Function('return this')();
155
+ return undefined || new Function('return this')();
307
156
  } catch (e) {
308
- if ((typeof window === "undefined" ? "undefined" : _type_of(window)) === 'object') return window;
157
+ if (typeof window === 'object') return window;
309
158
  }
310
- }();
159
+ })();
311
160
  //@ts-ignore
312
- __webpack_require__.o = function(obj, prop) {
313
- return Object.prototype.hasOwnProperty.call(obj, prop);
314
- };
161
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
315
162
  //@ts-ignore
316
- __webpack_require__.r = function(exports) {
163
+ __webpack_require__.r = (exports)=>{
317
164
  if (typeof Symbol !== 'undefined' && Symbol.toStringTag) {
318
165
  Object.defineProperty(exports, Symbol.toStringTag, {
319
166
  value: 'Module'
@@ -326,10 +173,10 @@ var createContainer = function(federationOptions) {
326
173
  //@ts-ignore
327
174
  __webpack_require__.federation.initOptions.shared = shared;
328
175
  __webpack_require__.S = {};
329
- var initPromises = {};
330
- var initTokens = {};
176
+ const initPromises = {};
177
+ const initTokens = {};
331
178
  //@ts-ignore
332
- __webpack_require__.I = function(name, initScope) {
179
+ __webpack_require__.I = (name, initScope)=>{
333
180
  //@ts-ignore
334
181
  return __webpack_require__.federation.bundlerRuntime.I({
335
182
  shareScopeName: name,
@@ -339,25 +186,15 @@ var createContainer = function(federationOptions) {
339
186
  initScope: initScope
340
187
  });
341
188
  };
342
- var __webpack_exports__ = __webpack_require__('webpack/container/entry/createContainer');
189
+ const __webpack_exports__ = __webpack_require__('webpack/container/entry/createContainer');
343
190
  __webpack_exports__.get;
344
191
  __webpack_exports__.init;
345
192
  return __webpack_exports__;
346
193
  };
347
- var createContainerAsync = function() {
348
- var _ref = _async_to_generator(function(federationOptions) {
349
- return _ts_generator(this, function(_state) {
350
- // todo: consider async startup options here, for "async boundary" provision.
351
- return [
352
- 2,
353
- createContainer(federationOptions)
354
- ];
355
- });
356
- });
357
- return function createContainerAsync(federationOptions) {
358
- return _ref.apply(this, arguments);
359
- };
360
- }();
194
+ const createContainerAsync = async (federationOptions)=>{
195
+ // todo: consider async startup options here, for "async boundary" provision.
196
+ return createContainer(federationOptions);
197
+ };
361
198
 
362
199
  exports.createContainer = createContainer;
363
200
  exports.createContainerAsync = createContainerAsync;
@@ -0,0 +1 @@
1
+ export * from "./src/container";