Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@module-federation/sdk

Package Overview
Dependencies
Maintainers
8
Versions
630
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@module-federation/sdk - npm Package Compare versions

Comparing version 0.0.7 to 0.0.8

dist/src/node.d.ts

365

dist/index.cjs.js

@@ -46,3 +46,3 @@ 'use strict';

function _array_like_to_array$1(arr, len) {
function _array_like_to_array$2(arr, len) {
if (len == null || len > arr.length) len = arr.length;

@@ -53,3 +53,3 @@ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];

function _array_without_holes(arr) {
if (Array.isArray(arr)) return _array_like_to_array$1(arr);
if (Array.isArray(arr)) return _array_like_to_array$2(arr);
}

@@ -95,11 +95,11 @@ function _class_call_check(instance, Constructor) {

function _to_consumable_array(arr) {
return _array_without_holes(arr) || _iterable_to_array$1(arr) || _unsupported_iterable_to_array$1(arr) || _non_iterable_spread();
return _array_without_holes(arr) || _iterable_to_array$1(arr) || _unsupported_iterable_to_array$2(arr) || _non_iterable_spread();
}
function _unsupported_iterable_to_array$1(o, minLen) {
function _unsupported_iterable_to_array$2(o, minLen) {
if (!o) return;
if (typeof o === "string") return _array_like_to_array$1(o, minLen);
if (typeof o === "string") return _array_like_to_array$2(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$1(o, minLen);
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$2(o, minLen);
}

@@ -163,3 +163,3 @@ function safeToString(info) {

function _array_like_to_array(arr, len) {
function _array_like_to_array$1(arr, len) {
if (len == null || len > arr.length) len = arr.length;

@@ -169,3 +169,3 @@ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];

}
function _array_with_holes(arr) {
function _array_with_holes$1(arr) {
if (Array.isArray(arr)) return arr;

@@ -176,3 +176,3 @@ }

}
function _iterable_to_array_limit(arr, i) {
function _iterable_to_array_limit$1(arr, i) {
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];

@@ -201,18 +201,18 @@ if (_i == null) return;

}
function _non_iterable_rest() {
function _non_iterable_rest$1() {
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 _sliced_to_array$1(arr, i) {
return _array_with_holes$1(arr) || _iterable_to_array_limit$1(arr, i) || _unsupported_iterable_to_array$1(arr, i) || _non_iterable_rest$1();
}
function _to_array(arr) {
return _array_with_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_rest();
return _array_with_holes$1(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array$1(arr) || _non_iterable_rest$1();
}
function _unsupported_iterable_to_array(o, minLen) {
function _unsupported_iterable_to_array$1(o, minLen) {
if (!o) return;
if (typeof o === "string") return _array_like_to_array(o, minLen);
if (typeof o === "string") return _array_like_to_array$1(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);
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$1(o, minLen);
}

@@ -247,3 +247,3 @@ var LOG_CATEGORY = "[ Federation Runtime ]";

} else if (strSplit.length === 1) {
var _strSplit1 = _sliced_to_array(strSplit, 1), name1 = _strSplit1[0];
var _strSplit1 = _sliced_to_array$1(strSplit, 1), name1 = _strSplit1[0];
if (devVersionOrUrl && isEntry(devVersionOrUrl)) {

@@ -294,2 +294,5 @@ return {

if (prefix) {
if (!decodedName.startsWith(prefix)) {
return decodedName;
}
decodedName = decodedName.replace(new RegExp(prefix, "g"), "");

@@ -525,3 +528,3 @@ }

function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
function asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, key, arg) {
try {

@@ -540,3 +543,3 @@ var info = gen[key](arg);

}
function _async_to_generator(fn) {
function _async_to_generator$1(fn) {
return function() {

@@ -547,6 +550,6 @@ var self = this, args = arguments;

function _next(value) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "next", value);
}
function _throw(err) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "throw", err);
}

@@ -564,3 +567,3 @@ _next(undefined);

}
function _ts_generator(thisArg, body) {
function _ts_generator$1(thisArg, body) {
var f, y, t, g, _ = {

@@ -665,5 +668,5 @@ label: 0,

function _safeWrapper() {
_safeWrapper = _async_to_generator(function(callback, disableWarn) {
_safeWrapper = _async_to_generator$1(function(callback, disableWarn) {
var res, e;
return _ts_generator(this, function(_state) {
return _ts_generator$1(this, function(_state) {
switch(_state.label){

@@ -779,2 +782,314 @@ case 0:

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 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 _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 _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
};
}
}
function importNodeModule(name) {
if (!name) {
throw new Error("import specifier is required");
}
var importModule = new Function("name", "return import(name)");
return importModule(name).then(function(res) {
return res.default;
}).catch(function(error) {
console.error("Error importing module ".concat(name, ":"), error);
throw error;
});
}
function createScriptNode(url, cb, attrs, createScriptHook) {
if (createScriptHook) {
var hookResult = createScriptHook(url);
if (hookResult && typeof hookResult === "object" && "url" in hookResult) {
url = hookResult.url;
}
}
var urlObj;
try {
urlObj = new URL(url);
} catch (e) {
console.error("Error constructing URL:", e);
cb(new Error("Invalid URL: ".concat(e)));
return;
}
var getFetch = function() {
var _ref = _async_to_generator(function() {
var fetchModule;
return _ts_generator(this, function(_state) {
switch(_state.label){
case 0:
if (!(typeof fetch === "undefined")) return [
3,
2
];
return [
4,
importNodeModule("node-fetch")
];
case 1:
fetchModule = _state.sent();
//@ts-ignore
return [
2,
(fetchModule === null || fetchModule === void 0 ? void 0 : fetchModule.default) || fetchModule
];
case 2:
return [
2,
fetch
];
case 3:
return [
2
];
}
});
});
return function getFetch() {
return _ref.apply(this, arguments);
};
}();
console.log("fetching", urlObj.href);
getFetch().then(function(f) {
f(urlObj.href).then(function(res) {
return res.text();
}).then(function() {
var _ref = _async_to_generator(function(data) {
var _ref, path, vm, scriptContext, urlDirname, filename, script, exportedInterface, container;
return _ts_generator(this, function(_state) {
switch(_state.label){
case 0:
return [
4,
Promise.all([
importNodeModule("path"),
importNodeModule("vm")
])
];
case 1:
_ref = _sliced_to_array.apply(void 0, [
_state.sent(),
2
]), path = _ref[0], vm = _ref[1];
scriptContext = {
exports: {},
module: {
exports: {}
}
};
urlDirname = urlObj.pathname.split("/").slice(0, -1).join("/");
filename = path.basename(urlObj.pathname);
try {
script = new vm.Script("(function(exports, module, require, __dirname, __filename) {".concat(data, "\n})"), {
filename: filename
});
script.runInThisContext()(scriptContext.exports, scriptContext.module, eval("require"), urlDirname, filename);
exportedInterface = scriptContext.module.exports || scriptContext.exports;
if (attrs && exportedInterface && attrs["globalName"]) {
container = exportedInterface[attrs["globalName"]];
cb(undefined, container);
return [
2
];
}
cb(undefined, exportedInterface);
} catch (e) {
// console.error('Error running script:', e);
cb(new Error("Script execution error: ".concat(e)));
}
return [
2
];
}
});
});
return function(data) {
return _ref.apply(this, arguments);
};
}()).catch(function(err) {
// console.error('Error fetching script:', err);
cb(err);
});
});
}
function loadScriptNode(url, info) {
return new Promise(function(resolve, reject) {
createScriptNode(url, function(error, scriptContext) {
if (error) {
reject(error);
} else {
var _info_attrs, _info_attrs1;
var remoteEntryKey = (info === null || info === void 0 ? void 0 : (_info_attrs = info.attrs) === null || _info_attrs === void 0 ? void 0 : _info_attrs["globalName"]) || "__FEDERATION_".concat(info === null || info === void 0 ? void 0 : (_info_attrs1 = info.attrs) === null || _info_attrs1 === void 0 ? void 0 : _info_attrs1["name"], ":custom__");
var entryExports = globalThis[remoteEntryKey] = scriptContext;
resolve(entryExports);
}
}, info.attrs, info.createScriptHook);
});
}
exports.BROWSER_LOG_KEY = BROWSER_LOG_KEY;

@@ -792,2 +1107,3 @@ exports.BROWSER_LOG_VALUE = BROWSER_LOG_VALUE;

exports.createScript = createScript;
exports.createScriptNode = createScriptNode;
exports.decodeName = decodeName;

@@ -806,2 +1122,3 @@ exports.encodeName = encodeName;

exports.loadScript = loadScript;
exports.loadScriptNode = loadScriptNode;
exports.logger = logger;

@@ -808,0 +1125,0 @@ exports.parseEntry = parseEntry;

@@ -42,3 +42,3 @@ function _define_property$2(obj, key, value) {

function _array_like_to_array$1(arr, len) {
function _array_like_to_array$2(arr, len) {
if (len == null || len > arr.length) len = arr.length;

@@ -49,3 +49,3 @@ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];

function _array_without_holes(arr) {
if (Array.isArray(arr)) return _array_like_to_array$1(arr);
if (Array.isArray(arr)) return _array_like_to_array$2(arr);
}

@@ -91,11 +91,11 @@ function _class_call_check(instance, Constructor) {

function _to_consumable_array(arr) {
return _array_without_holes(arr) || _iterable_to_array$1(arr) || _unsupported_iterable_to_array$1(arr) || _non_iterable_spread();
return _array_without_holes(arr) || _iterable_to_array$1(arr) || _unsupported_iterable_to_array$2(arr) || _non_iterable_spread();
}
function _unsupported_iterable_to_array$1(o, minLen) {
function _unsupported_iterable_to_array$2(o, minLen) {
if (!o) return;
if (typeof o === "string") return _array_like_to_array$1(o, minLen);
if (typeof o === "string") return _array_like_to_array$2(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$1(o, minLen);
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$2(o, minLen);
}

@@ -159,3 +159,3 @@ function safeToString(info) {

function _array_like_to_array(arr, len) {
function _array_like_to_array$1(arr, len) {
if (len == null || len > arr.length) len = arr.length;

@@ -165,3 +165,3 @@ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];

}
function _array_with_holes(arr) {
function _array_with_holes$1(arr) {
if (Array.isArray(arr)) return arr;

@@ -172,3 +172,3 @@ }

}
function _iterable_to_array_limit(arr, i) {
function _iterable_to_array_limit$1(arr, i) {
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];

@@ -197,18 +197,18 @@ if (_i == null) return;

}
function _non_iterable_rest() {
function _non_iterable_rest$1() {
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 _sliced_to_array$1(arr, i) {
return _array_with_holes$1(arr) || _iterable_to_array_limit$1(arr, i) || _unsupported_iterable_to_array$1(arr, i) || _non_iterable_rest$1();
}
function _to_array(arr) {
return _array_with_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_rest();
return _array_with_holes$1(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array$1(arr) || _non_iterable_rest$1();
}
function _unsupported_iterable_to_array(o, minLen) {
function _unsupported_iterable_to_array$1(o, minLen) {
if (!o) return;
if (typeof o === "string") return _array_like_to_array(o, minLen);
if (typeof o === "string") return _array_like_to_array$1(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);
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$1(o, minLen);
}

@@ -243,3 +243,3 @@ var LOG_CATEGORY = "[ Federation Runtime ]";

} else if (strSplit.length === 1) {
var _strSplit1 = _sliced_to_array(strSplit, 1), name1 = _strSplit1[0];
var _strSplit1 = _sliced_to_array$1(strSplit, 1), name1 = _strSplit1[0];
if (devVersionOrUrl && isEntry(devVersionOrUrl)) {

@@ -290,2 +290,5 @@ return {

if (prefix) {
if (!decodedName.startsWith(prefix)) {
return decodedName;
}
decodedName = decodedName.replace(new RegExp(prefix, "g"), "");

@@ -521,3 +524,3 @@ }

function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
function asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, key, arg) {
try {

@@ -536,3 +539,3 @@ var info = gen[key](arg);

}
function _async_to_generator(fn) {
function _async_to_generator$1(fn) {
return function() {

@@ -543,6 +546,6 @@ var self = this, args = arguments;

function _next(value) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "next", value);
}
function _throw(err) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "throw", err);
}

@@ -560,3 +563,3 @@ _next(undefined);

}
function _ts_generator(thisArg, body) {
function _ts_generator$1(thisArg, body) {
var f, y, t, g, _ = {

@@ -661,5 +664,5 @@ label: 0,

function _safeWrapper() {
_safeWrapper = _async_to_generator(function(callback, disableWarn) {
_safeWrapper = _async_to_generator$1(function(callback, disableWarn) {
var res, e;
return _ts_generator(this, function(_state) {
return _ts_generator$1(this, function(_state) {
switch(_state.label){

@@ -775,2 +778,314 @@ case 0:

export { BROWSER_LOG_KEY, BROWSER_LOG_VALUE, EncodedNameTransformMap, FederationModuleManifest, Logger, MANIFEST_EXT, NameTransformMap, NameTransformSymbol, SEPARATOR, assert, composeKeyWithSeparator, createScript, decodeName, encodeName, error, generateExposeFilename, generateShareFilename, generateSnapshotFromManifest, getProcessEnv, getResourceUrl, isBrowserEnv, isDebugMode, isManifestProvider, isStaticResourcesEqual, loadScript, logger, parseEntry, safeWrapper, simpleJoinRemoteEntry, warn };
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 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 _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 _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
};
}
}
function importNodeModule(name) {
if (!name) {
throw new Error("import specifier is required");
}
var importModule = new Function("name", "return import(name)");
return importModule(name).then(function(res) {
return res.default;
}).catch(function(error) {
console.error("Error importing module ".concat(name, ":"), error);
throw error;
});
}
function createScriptNode(url, cb, attrs, createScriptHook) {
if (createScriptHook) {
var hookResult = createScriptHook(url);
if (hookResult && typeof hookResult === "object" && "url" in hookResult) {
url = hookResult.url;
}
}
var urlObj;
try {
urlObj = new URL(url);
} catch (e) {
console.error("Error constructing URL:", e);
cb(new Error("Invalid URL: ".concat(e)));
return;
}
var getFetch = function() {
var _ref = _async_to_generator(function() {
var fetchModule;
return _ts_generator(this, function(_state) {
switch(_state.label){
case 0:
if (!(typeof fetch === "undefined")) return [
3,
2
];
return [
4,
importNodeModule("node-fetch")
];
case 1:
fetchModule = _state.sent();
//@ts-ignore
return [
2,
(fetchModule === null || fetchModule === void 0 ? void 0 : fetchModule.default) || fetchModule
];
case 2:
return [
2,
fetch
];
case 3:
return [
2
];
}
});
});
return function getFetch() {
return _ref.apply(this, arguments);
};
}();
console.log("fetching", urlObj.href);
getFetch().then(function(f) {
f(urlObj.href).then(function(res) {
return res.text();
}).then(function() {
var _ref = _async_to_generator(function(data) {
var _ref, path, vm, scriptContext, urlDirname, filename, script, exportedInterface, container;
return _ts_generator(this, function(_state) {
switch(_state.label){
case 0:
return [
4,
Promise.all([
importNodeModule("path"),
importNodeModule("vm")
])
];
case 1:
_ref = _sliced_to_array.apply(void 0, [
_state.sent(),
2
]), path = _ref[0], vm = _ref[1];
scriptContext = {
exports: {},
module: {
exports: {}
}
};
urlDirname = urlObj.pathname.split("/").slice(0, -1).join("/");
filename = path.basename(urlObj.pathname);
try {
script = new vm.Script("(function(exports, module, require, __dirname, __filename) {".concat(data, "\n})"), {
filename: filename
});
script.runInThisContext()(scriptContext.exports, scriptContext.module, eval("require"), urlDirname, filename);
exportedInterface = scriptContext.module.exports || scriptContext.exports;
if (attrs && exportedInterface && attrs["globalName"]) {
container = exportedInterface[attrs["globalName"]];
cb(undefined, container);
return [
2
];
}
cb(undefined, exportedInterface);
} catch (e) {
// console.error('Error running script:', e);
cb(new Error("Script execution error: ".concat(e)));
}
return [
2
];
}
});
});
return function(data) {
return _ref.apply(this, arguments);
};
}()).catch(function(err) {
// console.error('Error fetching script:', err);
cb(err);
});
});
}
function loadScriptNode(url, info) {
return new Promise(function(resolve, reject) {
createScriptNode(url, function(error, scriptContext) {
if (error) {
reject(error);
} else {
var _info_attrs, _info_attrs1;
var remoteEntryKey = (info === null || info === void 0 ? void 0 : (_info_attrs = info.attrs) === null || _info_attrs === void 0 ? void 0 : _info_attrs["globalName"]) || "__FEDERATION_".concat(info === null || info === void 0 ? void 0 : (_info_attrs1 = info.attrs) === null || _info_attrs1 === void 0 ? void 0 : _info_attrs1["name"], ":custom__");
var entryExports = globalThis[remoteEntryKey] = scriptContext;
resolve(entryExports);
}
}, info.attrs, info.createScriptHook);
});
}
export { BROWSER_LOG_KEY, BROWSER_LOG_VALUE, EncodedNameTransformMap, FederationModuleManifest, Logger, MANIFEST_EXT, NameTransformMap, NameTransformSymbol, SEPARATOR, assert, composeKeyWithSeparator, createScript, createScriptNode, decodeName, encodeName, error, generateExposeFilename, generateShareFilename, generateSnapshotFromManifest, getProcessEnv, getResourceUrl, isBrowserEnv, isDebugMode, isManifestProvider, isStaticResourcesEqual, loadScript, loadScriptNode, logger, parseEntry, safeWrapper, simpleJoinRemoteEntry, warn };

@@ -12,2 +12,5 @@ 'use strict';

function getWebpackPath(compiler) {
var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {
framework: "other"
};
try {

@@ -25,2 +28,8 @@ // @ts-ignore just throw err

var webpackPath = webpackLocationWithDetail.split(":").slice(0, -2)[0];
if ((options === null || options === void 0 ? void 0 : options.framework) === "nextjs") {
if (webpackPath.endsWith("webpack.js")) {
return webpackPath.replace("webpack.js", "index.js");
}
return "";
}
return require.resolve("webpack", {

@@ -27,0 +36,0 @@ paths: [

import path from 'path';
function getWebpackPath(compiler) {
var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {
framework: "other"
};
try {

@@ -16,2 +19,8 @@ // @ts-ignore just throw err

var webpackPath = webpackLocationWithDetail.split(":").slice(0, -2)[0];
if ((options === null || options === void 0 ? void 0 : options.framework) === "nextjs") {
if (webpackPath.endsWith("webpack.js")) {
return webpackPath.replace("webpack.js", "index.js");
}
return "";
}
return require.resolve("webpack", {

@@ -18,0 +27,0 @@ paths: [

2

dist/package.json
{
"name": "@module-federation/sdk",
"version": "0.0.7",
"version": "0.0.8",
"license": "MIT",

@@ -5,0 +5,0 @@ "description": "A sdk for support module federation",

@@ -8,1 +8,2 @@ export * from './constant';

export * from './dom';
export * from './node';
import type webpack from 'webpack';
export declare function getWebpackPath(compiler: webpack.Compiler): string;
export declare function getWebpackPath(compiler: webpack.Compiler, options?: {
framework: 'nextjs' | 'other';
}): string;
export declare const normalizeWebpackPath: (fullPath: string) => string;
{
"name": "@module-federation/sdk",
"version": "0.0.7",
"version": "0.0.8",
"license": "MIT",

@@ -5,0 +5,0 @@ "description": "A sdk for support module federation",

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