Socket
Socket
Sign inDemoInstall

@module-federation/webpack-bundler-runtime

Package Overview
Dependencies
Maintainers
8
Versions
519
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@module-federation/webpack-bundler-runtime - npm Package Compare versions

Comparing version 0.0.0-next-20231221095908 to 0.0.0-next-20231222073352

dist/constant.cjs.d.ts

94

dist/index.cjs.js
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var runtime = require('@module-federation/runtime');
var sdk = require('@module-federation/sdk');
var constant = require('./constant.cjs.js');

@@ -36,53 +35,2 @@ function _interopNamespace(e) {

var FEDERATION_SUPPORTED_TYPES = [
"script"
];
var ENCODE_NAME_PREFIX = "ENCODE_NAME_PREFIX";
function _array_like_to_array(arr, len) {
if (len == null || len > arr.length) len = arr.length;
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
return arr2;
}
function _array_with_holes(arr) {
if (Array.isArray(arr)) return arr;
}
function _iterable_to_array_limit(arr, i) {
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
if (_i == null) return;
var _arr = [];
var _n = true;
var _d = false;
var _s, _e;
try {
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
_arr.push(_s.value);
if (i && _arr.length === i) break;
}
} catch (err) {
_d = true;
_e = err;
} finally{
try {
if (!_n && _i["return"] != null) _i["return"]();
} finally{
if (_d) throw _e;
}
}
return _arr;
}
function _non_iterable_rest() {
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
function _sliced_to_array(arr, i) {
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
}
function _unsupported_iterable_to_array(o, minLen) {
if (!o) return;
if (typeof o === "string") return _array_like_to_array(o, minLen);
var n = Object.prototype.toString.call(o).slice(8, -1);
if (n === "Object" && o.constructor) n = o.constructor.name;
if (n === "Map" || n === "Set") return Array.from(n);
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
}
function remotes(options) {

@@ -153,16 +101,5 @@ var chunkId = options.chunkId, promises = options.promises, chunkMapping = options.chunkMapping, idToExternalAndNameMapping = options.idToExternalAndNameMapping, webpackRequire = options.webpackRequire, idToRemoteMap = options.idToRemoteMap;

};
var extractUrlAndGlobal = function(urlAndGlobal) {
var index = urlAndGlobal.indexOf("@");
if (index <= 0 || index === urlAndGlobal.length - 1) {
throw new Error('Invalid request "'.concat(urlAndGlobal, '"'));
}
return [
urlAndGlobal.substring(index + 1),
urlAndGlobal.substring(0, index)
];
};
var onRemoteLoaded = function() {
try {
var _extractUrlAndGlobal = _sliced_to_array(extractUrlAndGlobal(remoteInfos[0].request), 2), _entryUrl = _extractUrlAndGlobal[0], globalName = _extractUrlAndGlobal[1];
var remoteName = sdk.decodeName(globalName, ENCODE_NAME_PREFIX);
var remoteName = sdk.decodeName(remoteInfos[0].name, constant.ENCODE_NAME_PREFIX);
var remoteModuleName = remoteName + data[1].slice(1);

@@ -178,3 +115,3 @@ return webpackRequire.federation.instance.loadRemote(remoteModuleName, {

"script"
].includes(remoteInfos[0].externalType) && remoteInfos[0].request;
].includes(remoteInfos[0].externalType) && remoteInfos[0].name;
if (useRuntimeLoad) {

@@ -279,3 +216,3 @@ handleFunction(onRemoteLoaded, data[2], 0, 0, onFactory, 1);

var remoteInfo = info[0];
if (!FEDERATION_SUPPORTED_TYPES.includes(remoteInfo.externalType)) {
if (!constant.FEDERATION_SUPPORTED_TYPES.includes(remoteInfo.externalType)) {
initExternal(externalModuleId);

@@ -326,2 +263,11 @@ }

function isLegacyHost(shareScope) {
if ("version" in shareScope && typeof shareScope["version"] !== "object") {
return true;
}
if ("region" in shareScope && typeof shareScope["region"] !== "object") {
return true;
}
return false;
}
function initContainerEntry(options) {

@@ -336,6 +282,9 @@ var webpackRequire = options.webpackRequire, shareScope = options.shareScope, initScope = options.initScope, shareScopeKey = options.shareScopeKey;

});
webpackRequire.federation.instance.initShareScopeMap(name, shareScope);
var prevShareScope = globalThis.__FEDERATION__.__SHARE__["default"];
if (prevShareScope) {
webpackRequire.federation.instance.initShareScopeMap(name, prevShareScope);
if (isLegacyHost(shareScope)) {
var prevShareScope = globalThis.__FEDERATION__.__SHARE__["default"];
if (prevShareScope) {
webpackRequire.federation.instance.initShareScopeMap(name, prevShareScope);
}
} else {
webpackRequire.federation.instance.initShareScopeMap(name, shareScope);
}

@@ -366,3 +315,2 @@ webpackRequire.S[name] = shareScope;

exports.ENCODE_NAME_PREFIX = ENCODE_NAME_PREFIX;
exports["default"] = federation;
module.exports = federation;
import * as runtime from '@module-federation/runtime';
import { decodeName } from '@module-federation/sdk';
import { ENCODE_NAME_PREFIX, FEDERATION_SUPPORTED_TYPES } from './constant.esm.js';

@@ -12,53 +13,2 @@ function attachShareScopeMap(webpackRequire) {

var FEDERATION_SUPPORTED_TYPES = [
"script"
];
var ENCODE_NAME_PREFIX = "ENCODE_NAME_PREFIX";
function _array_like_to_array(arr, len) {
if (len == null || len > arr.length) len = arr.length;
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
return arr2;
}
function _array_with_holes(arr) {
if (Array.isArray(arr)) return arr;
}
function _iterable_to_array_limit(arr, i) {
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
if (_i == null) return;
var _arr = [];
var _n = true;
var _d = false;
var _s, _e;
try {
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
_arr.push(_s.value);
if (i && _arr.length === i) break;
}
} catch (err) {
_d = true;
_e = err;
} finally{
try {
if (!_n && _i["return"] != null) _i["return"]();
} finally{
if (_d) throw _e;
}
}
return _arr;
}
function _non_iterable_rest() {
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
function _sliced_to_array(arr, i) {
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
}
function _unsupported_iterable_to_array(o, minLen) {
if (!o) return;
if (typeof o === "string") return _array_like_to_array(o, minLen);
var n = Object.prototype.toString.call(o).slice(8, -1);
if (n === "Object" && o.constructor) n = o.constructor.name;
if (n === "Map" || n === "Set") return Array.from(n);
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
}
function remotes(options) {

@@ -129,16 +79,5 @@ var chunkId = options.chunkId, promises = options.promises, chunkMapping = options.chunkMapping, idToExternalAndNameMapping = options.idToExternalAndNameMapping, webpackRequire = options.webpackRequire, idToRemoteMap = options.idToRemoteMap;

};
var extractUrlAndGlobal = function(urlAndGlobal) {
var index = urlAndGlobal.indexOf("@");
if (index <= 0 || index === urlAndGlobal.length - 1) {
throw new Error('Invalid request "'.concat(urlAndGlobal, '"'));
}
return [
urlAndGlobal.substring(index + 1),
urlAndGlobal.substring(0, index)
];
};
var onRemoteLoaded = function() {
try {
var _extractUrlAndGlobal = _sliced_to_array(extractUrlAndGlobal(remoteInfos[0].request), 2), _entryUrl = _extractUrlAndGlobal[0], globalName = _extractUrlAndGlobal[1];
var remoteName = decodeName(globalName, ENCODE_NAME_PREFIX);
var remoteName = decodeName(remoteInfos[0].name, ENCODE_NAME_PREFIX);
var remoteModuleName = remoteName + data[1].slice(1);

@@ -154,3 +93,3 @@ return webpackRequire.federation.instance.loadRemote(remoteModuleName, {

"script"
].includes(remoteInfos[0].externalType) && remoteInfos[0].request;
].includes(remoteInfos[0].externalType) && remoteInfos[0].name;
if (useRuntimeLoad) {

@@ -301,2 +240,11 @@ handleFunction(onRemoteLoaded, data[2], 0, 0, onFactory, 1);

function isLegacyHost(shareScope) {
if ("version" in shareScope && typeof shareScope["version"] !== "object") {
return true;
}
if ("region" in shareScope && typeof shareScope["region"] !== "object") {
return true;
}
return false;
}
function initContainerEntry(options) {

@@ -311,6 +259,9 @@ var webpackRequire = options.webpackRequire, shareScope = options.shareScope, initScope = options.initScope, shareScopeKey = options.shareScopeKey;

});
webpackRequire.federation.instance.initShareScopeMap(name, shareScope);
var prevShareScope = globalThis.__FEDERATION__.__SHARE__["default"];
if (prevShareScope) {
webpackRequire.federation.instance.initShareScopeMap(name, prevShareScope);
if (isLegacyHost(shareScope)) {
var prevShareScope = globalThis.__FEDERATION__.__SHARE__["default"];
if (prevShareScope) {
webpackRequire.federation.instance.initShareScopeMap(name, prevShareScope);
}
} else {
webpackRequire.federation.instance.initShareScopeMap(name, shareScope);
}

@@ -341,2 +292,2 @@ webpackRequire.S[name] = shareScope;

export { ENCODE_NAME_PREFIX, federation as default };
export { federation as default };

@@ -25,3 +25,24 @@ {

"@module-federation/sdk": "workspace:*"
},
"exports": {
".": {
"import": "./dist/index.esm.js",
"require": "./dist/index.cjs.js"
},
"./constant": {
"import": "./dist/constant.esm.js",
"require": "./dist/constant.cjs.js"
},
"./*": "./*"
},
"typesVersions": {
"*": {
".": [
"./dist/index.cjs.d.ts"
],
"constant": [
"./dist/constant.cjs.d.ts"
]
}
}
}
import { Federation } from './types';
export * from './types';
export { ENCODE_NAME_PREFIX } from './constant';
declare const federation: Federation;
export default federation;

@@ -55,3 +55,3 @@ import * as runtime from '@module-federation/runtime';

externalType: string;
request: string;
name: string;
externalModuleId?: string | number;

@@ -58,0 +58,0 @@ }

{
"public": true,
"name": "@module-federation/webpack-bundler-runtime",
"version": "0.0.0-next-20231221095908",
"version": "0.0.0-next-20231222073352",
"license": "MIT",

@@ -23,5 +23,26 @@ "description": "Module Federation Runtime for webpack",

"dependencies": {
"@module-federation/runtime": "0.0.0-next-20231221095908",
"@module-federation/sdk": "0.0.0-next-20231221095908"
"@module-federation/runtime": "0.0.0-next-20231222073352",
"@module-federation/sdk": "0.0.0-next-20231222073352"
},
"exports": {
".": {
"import": "./dist/index.esm.js",
"require": "./dist/index.cjs.js"
},
"./constant": {
"import": "./dist/constant.esm.js",
"require": "./dist/constant.cjs.js"
},
"./*": "./*"
},
"typesVersions": {
"*": {
".": [
"./dist/index.cjs.d.ts"
],
"constant": [
"./dist/constant.cjs.d.ts"
]
}
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc