@module-federation/webpack-bundler-runtime
Advanced tools
Comparing version 0.0.0-next-20240930091801 to 0.0.0-next-20241002194835
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
var sdk = require('@module-federation/sdk'); | ||
var FEDERATION_SUPPORTED_TYPES = [ | ||
const FEDERATION_SUPPORTED_TYPES = [ | ||
'script' | ||
]; | ||
Object.defineProperty(exports, 'ENCODE_NAME_PREFIX', { | ||
Object.defineProperty(exports, "ENCODE_NAME_PREFIX", { | ||
enumerable: true, | ||
@@ -13,0 +11,0 @@ get: function () { return sdk.ENCODE_NAME_PREFIX; } |
export { ENCODE_NAME_PREFIX } from '@module-federation/sdk'; | ||
var FEDERATION_SUPPORTED_TYPES = [ | ||
const FEDERATION_SUPPORTED_TYPES = [ | ||
'script' | ||
@@ -5,0 +5,0 @@ ]; |
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
var index = require('./index.cjs.js'); | ||
@@ -9,151 +7,23 @@ require('@module-federation/runtime'); | ||
require('@module-federation/sdk'); | ||
require('./polyfills.cjs.js'); | ||
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { | ||
try { | ||
var info = gen[key](arg); | ||
var value = info.value; | ||
} catch (error) { | ||
reject(error); | ||
return; | ||
} | ||
if (info.done) { | ||
resolve(value); | ||
} else { | ||
Promise.resolve(value).then(_next, _throw); | ||
} | ||
} | ||
function _async_to_generator(fn) { | ||
return function() { | ||
var self = this, args = arguments; | ||
return new Promise(function(resolve, reject) { | ||
var gen = fn.apply(self, args); | ||
function _next(value) { | ||
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); | ||
} | ||
function _throw(err) { | ||
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); | ||
} | ||
_next(undefined); | ||
}); | ||
}; | ||
} | ||
function _type_of(obj) { | ||
"@swc/helpers - typeof"; | ||
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj; | ||
} | ||
function _ts_generator(thisArg, body) { | ||
var f, y, t, g, _ = { | ||
label: 0, | ||
sent: function() { | ||
if (t[0] & 1) throw t[1]; | ||
return t[1]; | ||
}, | ||
trys: [], | ||
ops: [] | ||
}; | ||
return g = { | ||
next: verb(0), | ||
"throw": verb(1), | ||
"return": verb(2) | ||
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() { | ||
return this; | ||
}), g; | ||
function verb(n) { | ||
return function(v) { | ||
return step([ | ||
n, | ||
v | ||
]); | ||
}; | ||
} | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while(_)try { | ||
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; | ||
if (y = 0, t) op = [ | ||
op[0] & 2, | ||
t.value | ||
]; | ||
switch(op[0]){ | ||
case 0: | ||
case 1: | ||
t = op; | ||
break; | ||
case 4: | ||
_.label++; | ||
return { | ||
value: op[1], | ||
done: false | ||
}; | ||
case 5: | ||
_.label++; | ||
y = op[1]; | ||
op = [ | ||
0 | ||
]; | ||
continue; | ||
case 7: | ||
op = _.ops.pop(); | ||
_.trys.pop(); | ||
continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { | ||
_ = 0; | ||
continue; | ||
} | ||
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) { | ||
_.label = op[1]; | ||
break; | ||
} | ||
if (op[0] === 6 && _.label < t[1]) { | ||
_.label = t[1]; | ||
t = op; | ||
break; | ||
} | ||
if (t && _.label < t[2]) { | ||
_.label = t[2]; | ||
_.ops.push(op); | ||
break; | ||
} | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); | ||
continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { | ||
op = [ | ||
6, | ||
e | ||
]; | ||
y = 0; | ||
} finally{ | ||
f = t = 0; | ||
} | ||
if (op[0] & 5) throw op[1]; | ||
return { | ||
value: op[0] ? op[1] : void 0, | ||
done: true | ||
}; | ||
} | ||
} | ||
var _this = undefined; | ||
var createContainer = function(federationOptions) { | ||
var exposes = federationOptions.exposes, name = federationOptions.name, _federationOptions_remotes = federationOptions.remotes, remotes = _federationOptions_remotes === void 0 ? [] : _federationOptions_remotes, shared = federationOptions.shared, plugins = federationOptions.plugins; | ||
var __webpack_modules__ = { | ||
'./node_modules/.federation/entry.1f2288102e035e2ed66b2efaf60ad043.js': function(//@ts-ignore | ||
const createContainer = (federationOptions)=>{ | ||
const { exposes, name, remotes = [], shared, plugins } = federationOptions; | ||
const __webpack_modules__ = { | ||
'./node_modules/.federation/entry.1f2288102e035e2ed66b2efaf60ad043.js': (//@ts-ignore | ||
module, //@ts-ignore | ||
__webpack_exports__, //@ts-ignore | ||
__webpack_require__) { | ||
__webpack_require__)=>{ | ||
__webpack_require__.r(__webpack_exports__); | ||
var bundler_runtime = __webpack_require__.n(index); | ||
var prevFederation = __webpack_require__.federation; | ||
const bundler_runtime = __webpack_require__.n(index); | ||
const prevFederation = __webpack_require__.federation; | ||
__webpack_require__.federation = {}; | ||
for(var key in bundler_runtime()){ | ||
for(const key in bundler_runtime()){ | ||
__webpack_require__.federation[key] = bundler_runtime()[key]; | ||
} | ||
for(var key1 in prevFederation){ | ||
__webpack_require__.federation[key1] = prevFederation[key1]; | ||
for(const key in prevFederation){ | ||
__webpack_require__.federation[key] = prevFederation[key]; | ||
} | ||
if (!__webpack_require__.federation.instance) { | ||
var pluginsToAdd = plugins || []; | ||
const pluginsToAdd = plugins || []; | ||
__webpack_require__.federation.initOptions.plugins = __webpack_require__.federation.initOptions.plugins ? __webpack_require__.federation.initOptions.plugins.concat(pluginsToAdd) : pluginsToAdd; | ||
@@ -170,25 +40,18 @@ __webpack_require__.federation.instance = __webpack_require__.federation.runtime.init(__webpack_require__.federation.initOptions); | ||
//@ts-ignore | ||
'webpack/container/entry/createContainer': function(//@ts-ignore | ||
'webpack/container/entry/createContainer': (//@ts-ignore | ||
module, //@ts-ignore | ||
exports, //@ts-ignore | ||
__webpack_require__) { | ||
var _loop = function(key) { | ||
__webpack_require__)=>{ | ||
const moduleMap = {}; | ||
for(const key in exposes){ | ||
if (Object.prototype.hasOwnProperty.call(exposes, key)) { | ||
//@ts-ignore | ||
moduleMap[key] = function() { | ||
return Promise.resolve(exposes[key]()).then(function(m) { | ||
return function() { | ||
return m; | ||
}; | ||
}); | ||
}; | ||
moduleMap[key] = ()=>Promise.resolve(exposes[key]()).then((m)=>()=>m); | ||
} | ||
}; | ||
var moduleMap = {}; | ||
for(var key in exposes)_loop(key); | ||
} | ||
//@ts-ignore | ||
var get = function(module, getScope) { | ||
const get = (module, getScope)=>{ | ||
__webpack_require__.R = getScope; | ||
getScope = __webpack_require__.o(moduleMap, module) ? moduleMap[module]() : Promise.resolve().then(function() { | ||
throw new Error('Module "'.concat(module, '" does not exist in container.')); | ||
getScope = __webpack_require__.o(moduleMap, module) ? moduleMap[module]() : Promise.resolve().then(()=>{ | ||
throw new Error(`Module "${module}" does not exist in container.`); | ||
}); | ||
@@ -199,3 +62,3 @@ __webpack_require__.R = undefined; | ||
//@ts-ignore | ||
var init = function(shareScope, initScope, remoteEntryInitOptions) { | ||
const init = (shareScope, initScope, remoteEntryInitOptions)=>{ | ||
return __webpack_require__.federation.bundlerRuntime.initContainerEntry({ | ||
@@ -212,19 +75,13 @@ webpackRequire: __webpack_require__, | ||
__webpack_require__.d(exports, { | ||
get: function() { | ||
return get; | ||
}, | ||
init: function() { | ||
return init; | ||
}, | ||
moduleMap: function() { | ||
return moduleMap; | ||
} | ||
get: ()=>get, | ||
init: ()=>init, | ||
moduleMap: ()=>moduleMap | ||
}); | ||
} | ||
}; | ||
var __webpack_module_cache__ = {}; | ||
const __webpack_module_cache__ = {}; | ||
//@ts-ignore | ||
var __webpack_require__ = function(moduleId) { | ||
const __webpack_require__ = (moduleId)=>{ | ||
//@ts-ignore | ||
var cachedModule = __webpack_module_cache__[moduleId]; | ||
let cachedModule = __webpack_module_cache__[moduleId]; | ||
if (cachedModule !== undefined) { | ||
@@ -234,3 +91,3 @@ return cachedModule.exports; | ||
//@ts-ignore | ||
var module = __webpack_module_cache__[moduleId] = { | ||
let module = __webpack_module_cache__[moduleId] = { | ||
id: moduleId, | ||
@@ -240,3 +97,3 @@ loaded: false, | ||
}; | ||
var execOptions = { | ||
const execOptions = { | ||
id: moduleId, | ||
@@ -248,3 +105,3 @@ module: module, | ||
}; | ||
__webpack_require__.i.forEach(function(handler) { | ||
__webpack_require__.i.forEach((handler)=>{ | ||
handler(execOptions); | ||
@@ -267,4 +124,3 @@ }); | ||
//@ts-ignore | ||
remotes: remotes.map(function(remote) { | ||
return { | ||
remotes: remotes.map((remote)=>({ | ||
type: remote.type, | ||
@@ -276,8 +132,5 @@ alias: remote.alias, | ||
shareScope: remote.shareScope || 'default' | ||
}; | ||
}) | ||
})) | ||
}, | ||
chunkMatcher: function() { | ||
return true; | ||
}, | ||
chunkMatcher: ()=>true, | ||
rootOutputDir: '', | ||
@@ -289,8 +142,4 @@ initialConsumes: undefined, | ||
//@ts-ignore | ||
__webpack_require__.n = function(module) { | ||
var getter = module && module.__esModule ? function() { | ||
return module['default']; | ||
} : function() { | ||
return module; | ||
}; | ||
__webpack_require__.n = (module)=>{ | ||
const getter = module && module.__esModule ? ()=>module['default'] : ()=>module; | ||
__webpack_require__.d(getter, { | ||
@@ -302,4 +151,4 @@ a: getter | ||
//@ts-ignore | ||
__webpack_require__.d = function(exports, definition) { | ||
for(var key in definition){ | ||
__webpack_require__.d = (exports, definition)=>{ | ||
for(const key in definition){ | ||
if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { | ||
@@ -314,16 +163,14 @@ Object.defineProperty(exports, key, { | ||
__webpack_require__.f = {}; | ||
__webpack_require__.g = function() { | ||
if ((typeof globalThis === "undefined" ? "undefined" : _type_of(globalThis)) === 'object') return globalThis; | ||
__webpack_require__.g = (()=>{ | ||
if (typeof globalThis === 'object') return globalThis; | ||
try { | ||
return _this || new Function('return this')(); | ||
return undefined || new Function('return this')(); | ||
} catch (e) { | ||
if ((typeof window === "undefined" ? "undefined" : _type_of(window)) === 'object') return window; | ||
if (typeof window === 'object') return window; | ||
} | ||
}(); | ||
})(); | ||
//@ts-ignore | ||
__webpack_require__.o = function(obj, prop) { | ||
return Object.prototype.hasOwnProperty.call(obj, prop); | ||
}; | ||
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop); | ||
//@ts-ignore | ||
__webpack_require__.r = function(exports) { | ||
__webpack_require__.r = (exports)=>{ | ||
if (typeof Symbol !== 'undefined' && Symbol.toStringTag) { | ||
@@ -341,6 +188,6 @@ Object.defineProperty(exports, Symbol.toStringTag, { | ||
__webpack_require__.S = {}; | ||
var initPromises = {}; | ||
var initTokens = {}; | ||
const initPromises = {}; | ||
const initTokens = {}; | ||
//@ts-ignore | ||
__webpack_require__.I = function(name, initScope) { | ||
__webpack_require__.I = (name, initScope)=>{ | ||
//@ts-ignore | ||
@@ -355,3 +202,3 @@ return __webpack_require__.federation.bundlerRuntime.I({ | ||
}; | ||
var __webpack_exports__ = __webpack_require__('webpack/container/entry/createContainer'); | ||
const __webpack_exports__ = __webpack_require__('webpack/container/entry/createContainer'); | ||
__webpack_exports__.get; | ||
@@ -361,18 +208,8 @@ __webpack_exports__.init; | ||
}; | ||
var createContainerAsync = function() { | ||
var _ref = _async_to_generator(function(federationOptions) { | ||
return _ts_generator(this, function(_state) { | ||
// todo: consider async startup options here, for "async boundary" provision. | ||
return [ | ||
2, | ||
createContainer(federationOptions) | ||
]; | ||
}); | ||
}); | ||
return function createContainerAsync(federationOptions) { | ||
return _ref.apply(this, arguments); | ||
}; | ||
}(); | ||
const createContainerAsync = async (federationOptions)=>{ | ||
// todo: consider async startup options here, for "async boundary" provision. | ||
return createContainer(federationOptions); | ||
}; | ||
exports.createContainer = createContainer; | ||
exports.createContainerAsync = createContainerAsync; |
@@ -5,151 +5,23 @@ import federation from './index.esm.js'; | ||
import '@module-federation/sdk'; | ||
import './polyfills.esm.js'; | ||
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { | ||
try { | ||
var info = gen[key](arg); | ||
var value = info.value; | ||
} catch (error) { | ||
reject(error); | ||
return; | ||
} | ||
if (info.done) { | ||
resolve(value); | ||
} else { | ||
Promise.resolve(value).then(_next, _throw); | ||
} | ||
} | ||
function _async_to_generator(fn) { | ||
return function() { | ||
var self = this, args = arguments; | ||
return new Promise(function(resolve, reject) { | ||
var gen = fn.apply(self, args); | ||
function _next(value) { | ||
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); | ||
} | ||
function _throw(err) { | ||
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); | ||
} | ||
_next(undefined); | ||
}); | ||
}; | ||
} | ||
function _type_of(obj) { | ||
"@swc/helpers - typeof"; | ||
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj; | ||
} | ||
function _ts_generator(thisArg, body) { | ||
var f, y, t, g, _ = { | ||
label: 0, | ||
sent: function() { | ||
if (t[0] & 1) throw t[1]; | ||
return t[1]; | ||
}, | ||
trys: [], | ||
ops: [] | ||
}; | ||
return g = { | ||
next: verb(0), | ||
"throw": verb(1), | ||
"return": verb(2) | ||
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() { | ||
return this; | ||
}), g; | ||
function verb(n) { | ||
return function(v) { | ||
return step([ | ||
n, | ||
v | ||
]); | ||
}; | ||
} | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while(_)try { | ||
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; | ||
if (y = 0, t) op = [ | ||
op[0] & 2, | ||
t.value | ||
]; | ||
switch(op[0]){ | ||
case 0: | ||
case 1: | ||
t = op; | ||
break; | ||
case 4: | ||
_.label++; | ||
return { | ||
value: op[1], | ||
done: false | ||
}; | ||
case 5: | ||
_.label++; | ||
y = op[1]; | ||
op = [ | ||
0 | ||
]; | ||
continue; | ||
case 7: | ||
op = _.ops.pop(); | ||
_.trys.pop(); | ||
continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { | ||
_ = 0; | ||
continue; | ||
} | ||
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) { | ||
_.label = op[1]; | ||
break; | ||
} | ||
if (op[0] === 6 && _.label < t[1]) { | ||
_.label = t[1]; | ||
t = op; | ||
break; | ||
} | ||
if (t && _.label < t[2]) { | ||
_.label = t[2]; | ||
_.ops.push(op); | ||
break; | ||
} | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); | ||
continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { | ||
op = [ | ||
6, | ||
e | ||
]; | ||
y = 0; | ||
} finally{ | ||
f = t = 0; | ||
} | ||
if (op[0] & 5) throw op[1]; | ||
return { | ||
value: op[0] ? op[1] : void 0, | ||
done: true | ||
}; | ||
} | ||
} | ||
var _this = undefined; | ||
var createContainer = function(federationOptions) { | ||
var exposes = federationOptions.exposes, name = federationOptions.name, _federationOptions_remotes = federationOptions.remotes, remotes = _federationOptions_remotes === void 0 ? [] : _federationOptions_remotes, shared = federationOptions.shared, plugins = federationOptions.plugins; | ||
var __webpack_modules__ = { | ||
'./node_modules/.federation/entry.1f2288102e035e2ed66b2efaf60ad043.js': function(//@ts-ignore | ||
const createContainer = (federationOptions)=>{ | ||
const { exposes, name, remotes = [], shared, plugins } = federationOptions; | ||
const __webpack_modules__ = { | ||
'./node_modules/.federation/entry.1f2288102e035e2ed66b2efaf60ad043.js': (//@ts-ignore | ||
module, //@ts-ignore | ||
__webpack_exports__, //@ts-ignore | ||
__webpack_require__) { | ||
__webpack_require__)=>{ | ||
__webpack_require__.r(__webpack_exports__); | ||
var bundler_runtime = __webpack_require__.n(federation); | ||
var prevFederation = __webpack_require__.federation; | ||
const bundler_runtime = __webpack_require__.n(federation); | ||
const prevFederation = __webpack_require__.federation; | ||
__webpack_require__.federation = {}; | ||
for(var key in bundler_runtime()){ | ||
for(const key in bundler_runtime()){ | ||
__webpack_require__.federation[key] = bundler_runtime()[key]; | ||
} | ||
for(var key1 in prevFederation){ | ||
__webpack_require__.federation[key1] = prevFederation[key1]; | ||
for(const key in prevFederation){ | ||
__webpack_require__.federation[key] = prevFederation[key]; | ||
} | ||
if (!__webpack_require__.federation.instance) { | ||
var pluginsToAdd = plugins || []; | ||
const pluginsToAdd = plugins || []; | ||
__webpack_require__.federation.initOptions.plugins = __webpack_require__.federation.initOptions.plugins ? __webpack_require__.federation.initOptions.plugins.concat(pluginsToAdd) : pluginsToAdd; | ||
@@ -166,25 +38,18 @@ __webpack_require__.federation.instance = __webpack_require__.federation.runtime.init(__webpack_require__.federation.initOptions); | ||
//@ts-ignore | ||
'webpack/container/entry/createContainer': function(//@ts-ignore | ||
'webpack/container/entry/createContainer': (//@ts-ignore | ||
module, //@ts-ignore | ||
exports, //@ts-ignore | ||
__webpack_require__) { | ||
var _loop = function(key) { | ||
__webpack_require__)=>{ | ||
const moduleMap = {}; | ||
for(const key in exposes){ | ||
if (Object.prototype.hasOwnProperty.call(exposes, key)) { | ||
//@ts-ignore | ||
moduleMap[key] = function() { | ||
return Promise.resolve(exposes[key]()).then(function(m) { | ||
return function() { | ||
return m; | ||
}; | ||
}); | ||
}; | ||
moduleMap[key] = ()=>Promise.resolve(exposes[key]()).then((m)=>()=>m); | ||
} | ||
}; | ||
var moduleMap = {}; | ||
for(var key in exposes)_loop(key); | ||
} | ||
//@ts-ignore | ||
var get = function(module, getScope) { | ||
const get = (module, getScope)=>{ | ||
__webpack_require__.R = getScope; | ||
getScope = __webpack_require__.o(moduleMap, module) ? moduleMap[module]() : Promise.resolve().then(function() { | ||
throw new Error('Module "'.concat(module, '" does not exist in container.')); | ||
getScope = __webpack_require__.o(moduleMap, module) ? moduleMap[module]() : Promise.resolve().then(()=>{ | ||
throw new Error(`Module "${module}" does not exist in container.`); | ||
}); | ||
@@ -195,3 +60,3 @@ __webpack_require__.R = undefined; | ||
//@ts-ignore | ||
var init = function(shareScope, initScope, remoteEntryInitOptions) { | ||
const init = (shareScope, initScope, remoteEntryInitOptions)=>{ | ||
return __webpack_require__.federation.bundlerRuntime.initContainerEntry({ | ||
@@ -208,19 +73,13 @@ webpackRequire: __webpack_require__, | ||
__webpack_require__.d(exports, { | ||
get: function() { | ||
return get; | ||
}, | ||
init: function() { | ||
return init; | ||
}, | ||
moduleMap: function() { | ||
return moduleMap; | ||
} | ||
get: ()=>get, | ||
init: ()=>init, | ||
moduleMap: ()=>moduleMap | ||
}); | ||
} | ||
}; | ||
var __webpack_module_cache__ = {}; | ||
const __webpack_module_cache__ = {}; | ||
//@ts-ignore | ||
var __webpack_require__ = function(moduleId) { | ||
const __webpack_require__ = (moduleId)=>{ | ||
//@ts-ignore | ||
var cachedModule = __webpack_module_cache__[moduleId]; | ||
let cachedModule = __webpack_module_cache__[moduleId]; | ||
if (cachedModule !== undefined) { | ||
@@ -230,3 +89,3 @@ return cachedModule.exports; | ||
//@ts-ignore | ||
var module = __webpack_module_cache__[moduleId] = { | ||
let module = __webpack_module_cache__[moduleId] = { | ||
id: moduleId, | ||
@@ -236,3 +95,3 @@ loaded: false, | ||
}; | ||
var execOptions = { | ||
const execOptions = { | ||
id: moduleId, | ||
@@ -244,3 +103,3 @@ module: module, | ||
}; | ||
__webpack_require__.i.forEach(function(handler) { | ||
__webpack_require__.i.forEach((handler)=>{ | ||
handler(execOptions); | ||
@@ -263,4 +122,3 @@ }); | ||
//@ts-ignore | ||
remotes: remotes.map(function(remote) { | ||
return { | ||
remotes: remotes.map((remote)=>({ | ||
type: remote.type, | ||
@@ -272,8 +130,5 @@ alias: remote.alias, | ||
shareScope: remote.shareScope || 'default' | ||
}; | ||
}) | ||
})) | ||
}, | ||
chunkMatcher: function() { | ||
return true; | ||
}, | ||
chunkMatcher: ()=>true, | ||
rootOutputDir: '', | ||
@@ -285,8 +140,4 @@ initialConsumes: undefined, | ||
//@ts-ignore | ||
__webpack_require__.n = function(module) { | ||
var getter = module && module.__esModule ? function() { | ||
return module['default']; | ||
} : function() { | ||
return module; | ||
}; | ||
__webpack_require__.n = (module)=>{ | ||
const getter = module && module.__esModule ? ()=>module['default'] : ()=>module; | ||
__webpack_require__.d(getter, { | ||
@@ -298,4 +149,4 @@ a: getter | ||
//@ts-ignore | ||
__webpack_require__.d = function(exports, definition) { | ||
for(var key in definition){ | ||
__webpack_require__.d = (exports, definition)=>{ | ||
for(const key in definition){ | ||
if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { | ||
@@ -310,16 +161,14 @@ Object.defineProperty(exports, key, { | ||
__webpack_require__.f = {}; | ||
__webpack_require__.g = function() { | ||
if ((typeof globalThis === "undefined" ? "undefined" : _type_of(globalThis)) === 'object') return globalThis; | ||
__webpack_require__.g = (()=>{ | ||
if (typeof globalThis === 'object') return globalThis; | ||
try { | ||
return _this || new Function('return this')(); | ||
return undefined || new Function('return this')(); | ||
} catch (e) { | ||
if ((typeof window === "undefined" ? "undefined" : _type_of(window)) === 'object') return window; | ||
if (typeof window === 'object') return window; | ||
} | ||
}(); | ||
})(); | ||
//@ts-ignore | ||
__webpack_require__.o = function(obj, prop) { | ||
return Object.prototype.hasOwnProperty.call(obj, prop); | ||
}; | ||
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop); | ||
//@ts-ignore | ||
__webpack_require__.r = function(exports) { | ||
__webpack_require__.r = (exports)=>{ | ||
if (typeof Symbol !== 'undefined' && Symbol.toStringTag) { | ||
@@ -337,6 +186,6 @@ Object.defineProperty(exports, Symbol.toStringTag, { | ||
__webpack_require__.S = {}; | ||
var initPromises = {}; | ||
var initTokens = {}; | ||
const initPromises = {}; | ||
const initTokens = {}; | ||
//@ts-ignore | ||
__webpack_require__.I = function(name, initScope) { | ||
__webpack_require__.I = (name, initScope)=>{ | ||
//@ts-ignore | ||
@@ -351,3 +200,3 @@ return __webpack_require__.federation.bundlerRuntime.I({ | ||
}; | ||
var __webpack_exports__ = __webpack_require__('webpack/container/entry/createContainer'); | ||
const __webpack_exports__ = __webpack_require__('webpack/container/entry/createContainer'); | ||
__webpack_exports__.get; | ||
@@ -357,17 +206,7 @@ __webpack_exports__.init; | ||
}; | ||
var createContainerAsync = function() { | ||
var _ref = _async_to_generator(function(federationOptions) { | ||
return _ts_generator(this, function(_state) { | ||
// todo: consider async startup options here, for "async boundary" provision. | ||
return [ | ||
2, | ||
createContainer(federationOptions) | ||
]; | ||
}); | ||
}); | ||
return function createContainerAsync(federationOptions) { | ||
return _ref.apply(this, arguments); | ||
}; | ||
}(); | ||
const createContainerAsync = async (federationOptions)=>{ | ||
// todo: consider async startup options here, for "async boundary" provision. | ||
return createContainer(federationOptions); | ||
}; | ||
export { createContainer, createContainerAsync }; |
@@ -6,5 +6,5 @@ 'use strict'; | ||
var sdk = require('@module-federation/sdk'); | ||
var polyfills = require('./polyfills.cjs.js'); | ||
function _interopNamespace(e) { | ||
if (e && e.__esModule) return e; | ||
function _interopNamespaceDefault(e) { | ||
var n = Object.create(null); | ||
@@ -22,7 +22,7 @@ if (e) { | ||
} | ||
n["default"] = e; | ||
n.default = e; | ||
return Object.freeze(n); | ||
} | ||
var runtime__namespace = /*#__PURE__*/_interopNamespace(runtime); | ||
var runtime__namespace = /*#__PURE__*/_interopNamespaceDefault(runtime); | ||
@@ -38,12 +38,12 @@ function attachShareScopeMap(webpackRequire) { | ||
function remotes(options) { | ||
var chunkId = options.chunkId, promises = options.promises, chunkMapping = options.chunkMapping, idToExternalAndNameMapping = options.idToExternalAndNameMapping, webpackRequire = options.webpackRequire, idToRemoteMap = options.idToRemoteMap; | ||
const { chunkId, promises, chunkMapping, idToExternalAndNameMapping, webpackRequire, idToRemoteMap } = options; | ||
attachShareScopeMap(webpackRequire); | ||
if (webpackRequire.o(chunkMapping, chunkId)) { | ||
chunkMapping[chunkId].forEach(function(id) { | ||
var getScope = webpackRequire.R; | ||
chunkMapping[chunkId].forEach((id)=>{ | ||
let getScope = webpackRequire.R; | ||
if (!getScope) { | ||
getScope = []; | ||
} | ||
var data = idToExternalAndNameMapping[id]; | ||
var remoteInfos = idToRemoteMap[id]; | ||
const data = idToExternalAndNameMapping[id]; | ||
const remoteInfos = idToRemoteMap[id]; | ||
// @ts-ignore seems not work | ||
@@ -58,3 +58,3 @@ if (getScope.indexOf(data) >= 0) { | ||
} | ||
var onError = function(error) { | ||
const onError = (error)=>{ | ||
if (!error) { | ||
@@ -64,5 +64,5 @@ error = new Error('Container missing'); | ||
if (typeof error.message === 'string') { | ||
error.message += '\nwhile loading "'.concat(data[1], '" from ').concat(data[2]); | ||
error.message += `\nwhile loading "${data[1]}" from ${data[2]}`; | ||
} | ||
webpackRequire.m[id] = function() { | ||
webpackRequire.m[id] = ()=>{ | ||
throw error; | ||
@@ -72,9 +72,7 @@ }; | ||
}; | ||
var handleFunction = function(fn, arg1, arg2, d, next, first) { | ||
const handleFunction = (fn, arg1, arg2, d, next, first)=>{ | ||
try { | ||
var promise = fn(arg1, arg2); | ||
const promise = fn(arg1, arg2); | ||
if (promise && promise.then) { | ||
var p = promise.then(function(result) { | ||
return next(result, d); | ||
}, onError); | ||
const p = promise.then((result)=>next(result, d), onError); | ||
if (first) { | ||
@@ -92,20 +90,16 @@ promises.push(data.p = p); | ||
}; | ||
var onExternal = function(external, _, first) { | ||
return external ? handleFunction(webpackRequire.I, data[0], 0, external, onInitialized, first) : onError(); | ||
}; | ||
const onExternal = (external, _, first)=>external ? handleFunction(webpackRequire.I, data[0], 0, external, onInitialized, first) : onError(); | ||
// eslint-disable-next-line no-var | ||
var onInitialized = function(_, external, first) { | ||
return handleFunction(external.get, data[1], getScope, 0, onFactory, first); | ||
}; | ||
var onInitialized = (_, external, first)=>handleFunction(external.get, data[1], getScope, 0, onFactory, first); | ||
// eslint-disable-next-line no-var | ||
var onFactory = function(factory) { | ||
var onFactory = (factory)=>{ | ||
data.p = 1; | ||
webpackRequire.m[id] = function(module) { | ||
webpackRequire.m[id] = (module)=>{ | ||
module.exports = factory(); | ||
}; | ||
}; | ||
var onRemoteLoaded = function() { | ||
const onRemoteLoaded = ()=>{ | ||
try { | ||
var remoteName = sdk.decodeName(remoteInfos[0].name, sdk.ENCODE_NAME_PREFIX); | ||
var remoteModuleName = remoteName + data[1].slice(1); | ||
const remoteName = sdk.decodeName(remoteInfos[0].name, sdk.ENCODE_NAME_PREFIX); | ||
const remoteModuleName = remoteName + data[1].slice(1); | ||
return webpackRequire.federation.instance.loadRemote(remoteModuleName, { | ||
@@ -119,3 +113,3 @@ loadFactory: false, | ||
}; | ||
var useRuntimeLoad = remoteInfos.length === 1 && constant.FEDERATION_SUPPORTED_TYPES.includes(remoteInfos[0].externalType) && remoteInfos[0].name; | ||
const useRuntimeLoad = remoteInfos.length === 1 && constant.FEDERATION_SUPPORTED_TYPES.includes(remoteInfos[0].externalType) && remoteInfos[0].name; | ||
if (useRuntimeLoad) { | ||
@@ -131,12 +125,12 @@ handleFunction(onRemoteLoaded, data[2], 0, 0, onFactory, 1); | ||
function consumes(options) { | ||
var chunkId = options.chunkId, promises = options.promises, chunkMapping = options.chunkMapping, installedModules = options.installedModules, moduleToHandlerMapping = options.moduleToHandlerMapping, webpackRequire = options.webpackRequire; | ||
const { chunkId, promises, chunkMapping, installedModules, moduleToHandlerMapping, webpackRequire } = options; | ||
attachShareScopeMap(webpackRequire); | ||
if (webpackRequire.o(chunkMapping, chunkId)) { | ||
chunkMapping[chunkId].forEach(function(id) { | ||
chunkMapping[chunkId].forEach((id)=>{ | ||
if (webpackRequire.o(installedModules, id)) { | ||
return promises.push(installedModules[id]); | ||
} | ||
var onFactory = function(factory) { | ||
const onFactory = (factory)=>{ | ||
installedModules[id] = 0; | ||
webpackRequire.m[id] = function(module) { | ||
webpackRequire.m[id] = (module)=>{ | ||
delete webpackRequire.c[id]; | ||
@@ -146,5 +140,5 @@ module.exports = factory(); | ||
}; | ||
var onError = function(error) { | ||
const onError = (error)=>{ | ||
delete installedModules[id]; | ||
webpackRequire.m[id] = function(module) { | ||
webpackRequire.m[id] = (module)=>{ | ||
delete webpackRequire.c[id]; | ||
@@ -155,10 +149,10 @@ throw error; | ||
try { | ||
var federationInstance = webpackRequire.federation.instance; | ||
const federationInstance = webpackRequire.federation.instance; | ||
if (!federationInstance) { | ||
throw new Error('Federation instance not found!'); | ||
} | ||
var _moduleToHandlerMapping_id = moduleToHandlerMapping[id], shareKey = _moduleToHandlerMapping_id.shareKey, getter = _moduleToHandlerMapping_id.getter, shareInfo = _moduleToHandlerMapping_id.shareInfo; | ||
var promise = federationInstance.loadShare(shareKey, { | ||
const { shareKey, getter, shareInfo } = moduleToHandlerMapping[id]; | ||
const promise = federationInstance.loadShare(shareKey, { | ||
customShareInfo: shareInfo | ||
}).then(function(factory) { | ||
}).then((factory)=>{ | ||
if (factory === false) { | ||
@@ -182,6 +176,5 @@ return getter(); | ||
function initializeSharing(param) { | ||
var shareScopeName = param.shareScopeName, webpackRequire = param.webpackRequire, initPromises = param.initPromises, initTokens = param.initTokens, initScope = param.initScope; | ||
function initializeSharing({ shareScopeName, webpackRequire, initPromises, initTokens, initScope }) { | ||
if (!initScope) initScope = []; | ||
var mfInstance = webpackRequire.federation.instance; | ||
const mfInstance = webpackRequire.federation.instance; | ||
// handling circular init calls | ||
@@ -194,18 +187,12 @@ var initToken = initTokens[shareScopeName]; | ||
initScope.push(initToken); | ||
var promise = initPromises[shareScopeName]; | ||
const promise = initPromises[shareScopeName]; | ||
if (promise) return promise; | ||
var warn = function(msg) { | ||
return typeof console !== 'undefined' && console.warn && console.warn(msg); | ||
}; | ||
var initExternal = function(id) { | ||
var handleError = function(err) { | ||
return warn('Initialization of sharing external failed: ' + err); | ||
}; | ||
var warn = (msg)=>typeof console !== 'undefined' && console.warn && console.warn(msg); | ||
var initExternal = (id)=>{ | ||
var handleError = (err)=>warn('Initialization of sharing external failed: ' + err); | ||
try { | ||
var module = webpackRequire(id); | ||
if (!module) return; | ||
var initFn = function(module) { | ||
return module && module.init && // @ts-ignore compat legacy mf shared behavior | ||
var initFn = (module)=>module && module.init && // @ts-ignore compat legacy mf shared behavior | ||
module.init(webpackRequire.S[shareScopeName], initScope); | ||
}; | ||
if (module.then) return promises.push(module.then(initFn, handleError)); | ||
@@ -220,17 +207,17 @@ var initResult = initFn(module); | ||
}; | ||
var promises = mfInstance.initializeSharing(shareScopeName, { | ||
const promises = mfInstance.initializeSharing(shareScopeName, { | ||
strategy: mfInstance.options.shareStrategy, | ||
initScope: initScope, | ||
initScope, | ||
from: 'build' | ||
}); | ||
attachShareScopeMap(webpackRequire); | ||
var bundlerRuntimeRemotesOptions = webpackRequire.federation.bundlerRuntimeOptions.remotes; | ||
const bundlerRuntimeRemotesOptions = webpackRequire.federation.bundlerRuntimeOptions.remotes; | ||
if (bundlerRuntimeRemotesOptions) { | ||
Object.keys(bundlerRuntimeRemotesOptions.idToRemoteMap).forEach(function(moduleId) { | ||
var info = bundlerRuntimeRemotesOptions.idToRemoteMap[moduleId]; | ||
var externalModuleId = bundlerRuntimeRemotesOptions.idToExternalAndNameMapping[moduleId][2]; | ||
Object.keys(bundlerRuntimeRemotesOptions.idToRemoteMap).forEach((moduleId)=>{ | ||
const info = bundlerRuntimeRemotesOptions.idToRemoteMap[moduleId]; | ||
const externalModuleId = bundlerRuntimeRemotesOptions.idToExternalAndNameMapping[moduleId][2]; | ||
if (info.length > 1) { | ||
initExternal(externalModuleId); | ||
} else if (info.length === 1) { | ||
var remoteInfo = info[0]; | ||
const remoteInfo = info[0]; | ||
if (!constant.FEDERATION_SUPPORTED_TYPES.includes(remoteInfo.externalType)) { | ||
@@ -245,14 +232,12 @@ initExternal(externalModuleId); | ||
} | ||
return initPromises[shareScopeName] = Promise.all(promises).then(function() { | ||
return initPromises[shareScopeName] = true; | ||
}); | ||
return initPromises[shareScopeName] = Promise.all(promises).then(()=>initPromises[shareScopeName] = true); | ||
} | ||
function handleInitialConsumes(options) { | ||
var moduleId = options.moduleId, moduleToHandlerMapping = options.moduleToHandlerMapping, webpackRequire = options.webpackRequire; | ||
var federationInstance = webpackRequire.federation.instance; | ||
const { moduleId, moduleToHandlerMapping, webpackRequire } = options; | ||
const federationInstance = webpackRequire.federation.instance; | ||
if (!federationInstance) { | ||
throw new Error('Federation instance not found!'); | ||
} | ||
var _moduleToHandlerMapping_moduleId = moduleToHandlerMapping[moduleId], shareKey = _moduleToHandlerMapping_moduleId.shareKey, shareInfo = _moduleToHandlerMapping_moduleId.shareInfo; | ||
const { shareKey, shareInfo } = moduleToHandlerMapping[moduleId]; | ||
try { | ||
@@ -269,15 +254,15 @@ return federationInstance.loadShareSync(shareKey, { | ||
function installInitialConsumes(options) { | ||
var moduleToHandlerMapping = options.moduleToHandlerMapping, webpackRequire = options.webpackRequire, installedModules = options.installedModules, initialConsumes = options.initialConsumes; | ||
initialConsumes.forEach(function(id) { | ||
webpackRequire.m[id] = function(module) { | ||
const { moduleToHandlerMapping, webpackRequire, installedModules, initialConsumes } = options; | ||
initialConsumes.forEach((id)=>{ | ||
webpackRequire.m[id] = (module)=>{ | ||
// Handle scenario when module is used synchronously | ||
installedModules[id] = 0; | ||
delete webpackRequire.c[id]; | ||
var factory = handleInitialConsumes({ | ||
const factory = handleInitialConsumes({ | ||
moduleId: id, | ||
moduleToHandlerMapping: moduleToHandlerMapping, | ||
webpackRequire: webpackRequire | ||
moduleToHandlerMapping, | ||
webpackRequire | ||
}); | ||
if (typeof factory !== 'function') { | ||
throw new Error("Shared module is not available for eager consumption: ".concat(id)); | ||
throw new Error(`Shared module is not available for eager consumption: ${id}`); | ||
} | ||
@@ -289,37 +274,9 @@ module.exports = factory(); | ||
function _define_property(obj, key, value) { | ||
if (key in obj) { | ||
Object.defineProperty(obj, key, { | ||
value: value, | ||
enumerable: true, | ||
configurable: true, | ||
writable: true | ||
}); | ||
} else { | ||
obj[key] = value; | ||
} | ||
return obj; | ||
} | ||
function _object_spread(target) { | ||
for(var i = 1; i < arguments.length; i++){ | ||
var source = arguments[i] != null ? arguments[i] : {}; | ||
var ownKeys = Object.keys(source); | ||
if (typeof Object.getOwnPropertySymbols === "function") { | ||
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) { | ||
return Object.getOwnPropertyDescriptor(source, sym).enumerable; | ||
})); | ||
} | ||
ownKeys.forEach(function(key) { | ||
_define_property(target, key, source[key]); | ||
}); | ||
} | ||
return target; | ||
} | ||
function initContainerEntry(options) { | ||
var webpackRequire = options.webpackRequire, shareScope = options.shareScope, initScope = options.initScope, shareScopeKey = options.shareScopeKey, remoteEntryInitOptions = options.remoteEntryInitOptions; | ||
const { webpackRequire, shareScope, initScope, shareScopeKey, remoteEntryInitOptions } = options; | ||
if (!webpackRequire.S) return; | ||
if (!webpackRequire.federation || !webpackRequire.federation.instance || !webpackRequire.federation.initOptions) return; | ||
var federationInstance = webpackRequire.federation.instance; | ||
const federationInstance = webpackRequire.federation.instance; | ||
var name = shareScopeKey || 'default'; | ||
federationInstance.initOptions(_object_spread({ | ||
federationInstance.initOptions(polyfills._extends({ | ||
name: webpackRequire.federation.initOptions.name, | ||
@@ -329,3 +286,3 @@ remotes: [] | ||
federationInstance.initShareScopeMap(name, shareScope, { | ||
hostShareScopeMap: (remoteEntryInitOptions === null || remoteEntryInitOptions === void 0 ? void 0 : remoteEntryInitOptions.shareScopeMap) || {} | ||
hostShareScopeMap: (remoteEntryInitOptions == null ? void 0 : remoteEntryInitOptions.shareScopeMap) || {} | ||
}); | ||
@@ -342,3 +299,3 @@ if (webpackRequire.federation.attachShareScopeMap) { | ||
var federation = { | ||
const federation = { | ||
runtime: runtime__namespace, | ||
@@ -348,10 +305,10 @@ instance: undefined, | ||
bundlerRuntime: { | ||
remotes: remotes, | ||
consumes: consumes, | ||
remotes, | ||
consumes, | ||
I: initializeSharing, | ||
S: {}, | ||
installInitialConsumes: installInitialConsumes, | ||
initContainerEntry: initContainerEntry | ||
installInitialConsumes, | ||
initContainerEntry | ||
}, | ||
attachShareScopeMap: attachShareScopeMap, | ||
attachShareScopeMap, | ||
bundlerRuntimeOptions: {} | ||
@@ -358,0 +315,0 @@ }; |
import * as runtime from '@module-federation/runtime'; | ||
import { FEDERATION_SUPPORTED_TYPES } from './constant.esm.js'; | ||
import { decodeName, ENCODE_NAME_PREFIX } from '@module-federation/sdk'; | ||
import { _ as _extends } from './polyfills.esm.js'; | ||
@@ -14,12 +15,12 @@ function attachShareScopeMap(webpackRequire) { | ||
function remotes(options) { | ||
var chunkId = options.chunkId, promises = options.promises, chunkMapping = options.chunkMapping, idToExternalAndNameMapping = options.idToExternalAndNameMapping, webpackRequire = options.webpackRequire, idToRemoteMap = options.idToRemoteMap; | ||
const { chunkId, promises, chunkMapping, idToExternalAndNameMapping, webpackRequire, idToRemoteMap } = options; | ||
attachShareScopeMap(webpackRequire); | ||
if (webpackRequire.o(chunkMapping, chunkId)) { | ||
chunkMapping[chunkId].forEach(function(id) { | ||
var getScope = webpackRequire.R; | ||
chunkMapping[chunkId].forEach((id)=>{ | ||
let getScope = webpackRequire.R; | ||
if (!getScope) { | ||
getScope = []; | ||
} | ||
var data = idToExternalAndNameMapping[id]; | ||
var remoteInfos = idToRemoteMap[id]; | ||
const data = idToExternalAndNameMapping[id]; | ||
const remoteInfos = idToRemoteMap[id]; | ||
// @ts-ignore seems not work | ||
@@ -34,3 +35,3 @@ if (getScope.indexOf(data) >= 0) { | ||
} | ||
var onError = function(error) { | ||
const onError = (error)=>{ | ||
if (!error) { | ||
@@ -40,5 +41,5 @@ error = new Error('Container missing'); | ||
if (typeof error.message === 'string') { | ||
error.message += '\nwhile loading "'.concat(data[1], '" from ').concat(data[2]); | ||
error.message += `\nwhile loading "${data[1]}" from ${data[2]}`; | ||
} | ||
webpackRequire.m[id] = function() { | ||
webpackRequire.m[id] = ()=>{ | ||
throw error; | ||
@@ -48,9 +49,7 @@ }; | ||
}; | ||
var handleFunction = function(fn, arg1, arg2, d, next, first) { | ||
const handleFunction = (fn, arg1, arg2, d, next, first)=>{ | ||
try { | ||
var promise = fn(arg1, arg2); | ||
const promise = fn(arg1, arg2); | ||
if (promise && promise.then) { | ||
var p = promise.then(function(result) { | ||
return next(result, d); | ||
}, onError); | ||
const p = promise.then((result)=>next(result, d), onError); | ||
if (first) { | ||
@@ -68,20 +67,16 @@ promises.push(data.p = p); | ||
}; | ||
var onExternal = function(external, _, first) { | ||
return external ? handleFunction(webpackRequire.I, data[0], 0, external, onInitialized, first) : onError(); | ||
}; | ||
const onExternal = (external, _, first)=>external ? handleFunction(webpackRequire.I, data[0], 0, external, onInitialized, first) : onError(); | ||
// eslint-disable-next-line no-var | ||
var onInitialized = function(_, external, first) { | ||
return handleFunction(external.get, data[1], getScope, 0, onFactory, first); | ||
}; | ||
var onInitialized = (_, external, first)=>handleFunction(external.get, data[1], getScope, 0, onFactory, first); | ||
// eslint-disable-next-line no-var | ||
var onFactory = function(factory) { | ||
var onFactory = (factory)=>{ | ||
data.p = 1; | ||
webpackRequire.m[id] = function(module) { | ||
webpackRequire.m[id] = (module)=>{ | ||
module.exports = factory(); | ||
}; | ||
}; | ||
var onRemoteLoaded = function() { | ||
const onRemoteLoaded = ()=>{ | ||
try { | ||
var remoteName = decodeName(remoteInfos[0].name, ENCODE_NAME_PREFIX); | ||
var remoteModuleName = remoteName + data[1].slice(1); | ||
const remoteName = decodeName(remoteInfos[0].name, ENCODE_NAME_PREFIX); | ||
const remoteModuleName = remoteName + data[1].slice(1); | ||
return webpackRequire.federation.instance.loadRemote(remoteModuleName, { | ||
@@ -95,3 +90,3 @@ loadFactory: false, | ||
}; | ||
var useRuntimeLoad = remoteInfos.length === 1 && FEDERATION_SUPPORTED_TYPES.includes(remoteInfos[0].externalType) && remoteInfos[0].name; | ||
const useRuntimeLoad = remoteInfos.length === 1 && FEDERATION_SUPPORTED_TYPES.includes(remoteInfos[0].externalType) && remoteInfos[0].name; | ||
if (useRuntimeLoad) { | ||
@@ -107,12 +102,12 @@ handleFunction(onRemoteLoaded, data[2], 0, 0, onFactory, 1); | ||
function consumes(options) { | ||
var chunkId = options.chunkId, promises = options.promises, chunkMapping = options.chunkMapping, installedModules = options.installedModules, moduleToHandlerMapping = options.moduleToHandlerMapping, webpackRequire = options.webpackRequire; | ||
const { chunkId, promises, chunkMapping, installedModules, moduleToHandlerMapping, webpackRequire } = options; | ||
attachShareScopeMap(webpackRequire); | ||
if (webpackRequire.o(chunkMapping, chunkId)) { | ||
chunkMapping[chunkId].forEach(function(id) { | ||
chunkMapping[chunkId].forEach((id)=>{ | ||
if (webpackRequire.o(installedModules, id)) { | ||
return promises.push(installedModules[id]); | ||
} | ||
var onFactory = function(factory) { | ||
const onFactory = (factory)=>{ | ||
installedModules[id] = 0; | ||
webpackRequire.m[id] = function(module) { | ||
webpackRequire.m[id] = (module)=>{ | ||
delete webpackRequire.c[id]; | ||
@@ -122,5 +117,5 @@ module.exports = factory(); | ||
}; | ||
var onError = function(error) { | ||
const onError = (error)=>{ | ||
delete installedModules[id]; | ||
webpackRequire.m[id] = function(module) { | ||
webpackRequire.m[id] = (module)=>{ | ||
delete webpackRequire.c[id]; | ||
@@ -131,10 +126,10 @@ throw error; | ||
try { | ||
var federationInstance = webpackRequire.federation.instance; | ||
const federationInstance = webpackRequire.federation.instance; | ||
if (!federationInstance) { | ||
throw new Error('Federation instance not found!'); | ||
} | ||
var _moduleToHandlerMapping_id = moduleToHandlerMapping[id], shareKey = _moduleToHandlerMapping_id.shareKey, getter = _moduleToHandlerMapping_id.getter, shareInfo = _moduleToHandlerMapping_id.shareInfo; | ||
var promise = federationInstance.loadShare(shareKey, { | ||
const { shareKey, getter, shareInfo } = moduleToHandlerMapping[id]; | ||
const promise = federationInstance.loadShare(shareKey, { | ||
customShareInfo: shareInfo | ||
}).then(function(factory) { | ||
}).then((factory)=>{ | ||
if (factory === false) { | ||
@@ -158,6 +153,5 @@ return getter(); | ||
function initializeSharing(param) { | ||
var shareScopeName = param.shareScopeName, webpackRequire = param.webpackRequire, initPromises = param.initPromises, initTokens = param.initTokens, initScope = param.initScope; | ||
function initializeSharing({ shareScopeName, webpackRequire, initPromises, initTokens, initScope }) { | ||
if (!initScope) initScope = []; | ||
var mfInstance = webpackRequire.federation.instance; | ||
const mfInstance = webpackRequire.federation.instance; | ||
// handling circular init calls | ||
@@ -170,18 +164,12 @@ var initToken = initTokens[shareScopeName]; | ||
initScope.push(initToken); | ||
var promise = initPromises[shareScopeName]; | ||
const promise = initPromises[shareScopeName]; | ||
if (promise) return promise; | ||
var warn = function(msg) { | ||
return typeof console !== 'undefined' && console.warn && console.warn(msg); | ||
}; | ||
var initExternal = function(id) { | ||
var handleError = function(err) { | ||
return warn('Initialization of sharing external failed: ' + err); | ||
}; | ||
var warn = (msg)=>typeof console !== 'undefined' && console.warn && console.warn(msg); | ||
var initExternal = (id)=>{ | ||
var handleError = (err)=>warn('Initialization of sharing external failed: ' + err); | ||
try { | ||
var module = webpackRequire(id); | ||
if (!module) return; | ||
var initFn = function(module) { | ||
return module && module.init && // @ts-ignore compat legacy mf shared behavior | ||
var initFn = (module)=>module && module.init && // @ts-ignore compat legacy mf shared behavior | ||
module.init(webpackRequire.S[shareScopeName], initScope); | ||
}; | ||
if (module.then) return promises.push(module.then(initFn, handleError)); | ||
@@ -196,17 +184,17 @@ var initResult = initFn(module); | ||
}; | ||
var promises = mfInstance.initializeSharing(shareScopeName, { | ||
const promises = mfInstance.initializeSharing(shareScopeName, { | ||
strategy: mfInstance.options.shareStrategy, | ||
initScope: initScope, | ||
initScope, | ||
from: 'build' | ||
}); | ||
attachShareScopeMap(webpackRequire); | ||
var bundlerRuntimeRemotesOptions = webpackRequire.federation.bundlerRuntimeOptions.remotes; | ||
const bundlerRuntimeRemotesOptions = webpackRequire.federation.bundlerRuntimeOptions.remotes; | ||
if (bundlerRuntimeRemotesOptions) { | ||
Object.keys(bundlerRuntimeRemotesOptions.idToRemoteMap).forEach(function(moduleId) { | ||
var info = bundlerRuntimeRemotesOptions.idToRemoteMap[moduleId]; | ||
var externalModuleId = bundlerRuntimeRemotesOptions.idToExternalAndNameMapping[moduleId][2]; | ||
Object.keys(bundlerRuntimeRemotesOptions.idToRemoteMap).forEach((moduleId)=>{ | ||
const info = bundlerRuntimeRemotesOptions.idToRemoteMap[moduleId]; | ||
const externalModuleId = bundlerRuntimeRemotesOptions.idToExternalAndNameMapping[moduleId][2]; | ||
if (info.length > 1) { | ||
initExternal(externalModuleId); | ||
} else if (info.length === 1) { | ||
var remoteInfo = info[0]; | ||
const remoteInfo = info[0]; | ||
if (!FEDERATION_SUPPORTED_TYPES.includes(remoteInfo.externalType)) { | ||
@@ -221,14 +209,12 @@ initExternal(externalModuleId); | ||
} | ||
return initPromises[shareScopeName] = Promise.all(promises).then(function() { | ||
return initPromises[shareScopeName] = true; | ||
}); | ||
return initPromises[shareScopeName] = Promise.all(promises).then(()=>initPromises[shareScopeName] = true); | ||
} | ||
function handleInitialConsumes(options) { | ||
var moduleId = options.moduleId, moduleToHandlerMapping = options.moduleToHandlerMapping, webpackRequire = options.webpackRequire; | ||
var federationInstance = webpackRequire.federation.instance; | ||
const { moduleId, moduleToHandlerMapping, webpackRequire } = options; | ||
const federationInstance = webpackRequire.federation.instance; | ||
if (!federationInstance) { | ||
throw new Error('Federation instance not found!'); | ||
} | ||
var _moduleToHandlerMapping_moduleId = moduleToHandlerMapping[moduleId], shareKey = _moduleToHandlerMapping_moduleId.shareKey, shareInfo = _moduleToHandlerMapping_moduleId.shareInfo; | ||
const { shareKey, shareInfo } = moduleToHandlerMapping[moduleId]; | ||
try { | ||
@@ -245,15 +231,15 @@ return federationInstance.loadShareSync(shareKey, { | ||
function installInitialConsumes(options) { | ||
var moduleToHandlerMapping = options.moduleToHandlerMapping, webpackRequire = options.webpackRequire, installedModules = options.installedModules, initialConsumes = options.initialConsumes; | ||
initialConsumes.forEach(function(id) { | ||
webpackRequire.m[id] = function(module) { | ||
const { moduleToHandlerMapping, webpackRequire, installedModules, initialConsumes } = options; | ||
initialConsumes.forEach((id)=>{ | ||
webpackRequire.m[id] = (module)=>{ | ||
// Handle scenario when module is used synchronously | ||
installedModules[id] = 0; | ||
delete webpackRequire.c[id]; | ||
var factory = handleInitialConsumes({ | ||
const factory = handleInitialConsumes({ | ||
moduleId: id, | ||
moduleToHandlerMapping: moduleToHandlerMapping, | ||
webpackRequire: webpackRequire | ||
moduleToHandlerMapping, | ||
webpackRequire | ||
}); | ||
if (typeof factory !== 'function') { | ||
throw new Error("Shared module is not available for eager consumption: ".concat(id)); | ||
throw new Error(`Shared module is not available for eager consumption: ${id}`); | ||
} | ||
@@ -265,37 +251,9 @@ module.exports = factory(); | ||
function _define_property(obj, key, value) { | ||
if (key in obj) { | ||
Object.defineProperty(obj, key, { | ||
value: value, | ||
enumerable: true, | ||
configurable: true, | ||
writable: true | ||
}); | ||
} else { | ||
obj[key] = value; | ||
} | ||
return obj; | ||
} | ||
function _object_spread(target) { | ||
for(var i = 1; i < arguments.length; i++){ | ||
var source = arguments[i] != null ? arguments[i] : {}; | ||
var ownKeys = Object.keys(source); | ||
if (typeof Object.getOwnPropertySymbols === "function") { | ||
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) { | ||
return Object.getOwnPropertyDescriptor(source, sym).enumerable; | ||
})); | ||
} | ||
ownKeys.forEach(function(key) { | ||
_define_property(target, key, source[key]); | ||
}); | ||
} | ||
return target; | ||
} | ||
function initContainerEntry(options) { | ||
var webpackRequire = options.webpackRequire, shareScope = options.shareScope, initScope = options.initScope, shareScopeKey = options.shareScopeKey, remoteEntryInitOptions = options.remoteEntryInitOptions; | ||
const { webpackRequire, shareScope, initScope, shareScopeKey, remoteEntryInitOptions } = options; | ||
if (!webpackRequire.S) return; | ||
if (!webpackRequire.federation || !webpackRequire.federation.instance || !webpackRequire.federation.initOptions) return; | ||
var federationInstance = webpackRequire.federation.instance; | ||
const federationInstance = webpackRequire.federation.instance; | ||
var name = shareScopeKey || 'default'; | ||
federationInstance.initOptions(_object_spread({ | ||
federationInstance.initOptions(_extends({ | ||
name: webpackRequire.federation.initOptions.name, | ||
@@ -305,3 +263,3 @@ remotes: [] | ||
federationInstance.initShareScopeMap(name, shareScope, { | ||
hostShareScopeMap: (remoteEntryInitOptions === null || remoteEntryInitOptions === void 0 ? void 0 : remoteEntryInitOptions.shareScopeMap) || {} | ||
hostShareScopeMap: (remoteEntryInitOptions == null ? void 0 : remoteEntryInitOptions.shareScopeMap) || {} | ||
}); | ||
@@ -318,15 +276,15 @@ if (webpackRequire.federation.attachShareScopeMap) { | ||
var federation = { | ||
runtime: runtime, | ||
const federation = { | ||
runtime, | ||
instance: undefined, | ||
initOptions: undefined, | ||
bundlerRuntime: { | ||
remotes: remotes, | ||
consumes: consumes, | ||
remotes, | ||
consumes, | ||
I: initializeSharing, | ||
S: {}, | ||
installInitialConsumes: installInitialConsumes, | ||
initContainerEntry: initContainerEntry | ||
installInitialConsumes, | ||
initContainerEntry | ||
}, | ||
attachShareScopeMap: attachShareScopeMap, | ||
attachShareScopeMap, | ||
bundlerRuntimeOptions: {} | ||
@@ -333,0 +291,0 @@ }; |
{ | ||
"public": true, | ||
"name": "@module-federation/webpack-bundler-runtime", | ||
"version": "0.6.6", | ||
"version": "0.6.8", | ||
"license": "MIT", | ||
@@ -54,2 +54,2 @@ "description": "Module Federation Runtime for webpack", | ||
} | ||
} | ||
} |
{ | ||
"public": true, | ||
"name": "@module-federation/webpack-bundler-runtime", | ||
"version": "0.0.0-next-20240930091801", | ||
"version": "0.0.0-next-20241002194835", | ||
"license": "MIT", | ||
@@ -23,4 +23,4 @@ "description": "Module Federation Runtime for webpack", | ||
"dependencies": { | ||
"@module-federation/runtime": "0.0.0-next-20240930091801", | ||
"@module-federation/sdk": "0.0.0-next-20240930091801" | ||
"@module-federation/runtime": "0.0.0-next-20241002194835", | ||
"@module-federation/sdk": "0.0.0-next-20241002194835" | ||
}, | ||
@@ -53,4 +53,4 @@ "exports": { | ||
"devDependencies": { | ||
"@module-federation/runtime": "0.0.0-next-20240930091801" | ||
"@module-federation/runtime": "0.0.0-next-20241002194835" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
29
52330
1129
+ Added@module-federation/runtime@0.0.0-next-20241002194835(transitive)
+ Added@module-federation/sdk@0.0.0-next-20241002194835(transitive)
- Removed@module-federation/runtime@0.0.0-next-20240930091801(transitive)
- Removed@module-federation/sdk@0.0.0-next-20240930091801(transitive)