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