@module-federation/managers
Advanced tools
Comparing version 0.0.0-next-20240511031741 to 0.0.0-next-20240514062402
@@ -84,4 +84,85 @@ 'use strict'; | ||
var LOCAL_BUILD_VERSION = "local"; | ||
function _class_call_check$3(instance, Constructor) { | ||
if (!(instance instanceof Constructor)) { | ||
throw new TypeError("Cannot call a class as a function"); | ||
} | ||
} | ||
function _defineProperties$3(target, props) { | ||
for(var i = 0; i < props.length; i++){ | ||
var descriptor = props[i]; | ||
descriptor.enumerable = descriptor.enumerable || false; | ||
descriptor.configurable = true; | ||
if ("value" in descriptor) descriptor.writable = true; | ||
Object.defineProperty(target, descriptor.key, descriptor); | ||
} | ||
} | ||
function _create_class$3(Constructor, protoProps, staticProps) { | ||
if (protoProps) _defineProperties$3(Constructor.prototype, protoProps); | ||
if (staticProps) _defineProperties$3(Constructor, staticProps); | ||
return Constructor; | ||
} | ||
function _define_property$3(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; | ||
} | ||
var PKGJsonManager = /*#__PURE__*/ function() { | ||
function PKGJsonManager() { | ||
_class_call_check$3(this, PKGJsonManager); | ||
_define_property$3(this, "_pkg", void 0); | ||
} | ||
_create_class$3(PKGJsonManager, [ | ||
{ | ||
key: "setPKGJson", | ||
value: function setPKGJson(pkg) { | ||
this._pkg = pkg; | ||
} | ||
}, | ||
{ | ||
key: "readPKGJson", | ||
value: function readPKGJson() { | ||
var ctx = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : process.cwd(); | ||
if (this._pkg) { | ||
return this._pkg; | ||
} | ||
try { | ||
// eslint-disable-next-line no-restricted-globals | ||
var pkg = JSON.parse(fs__default["default"].readFileSync(path__default["default"].resolve(ctx, 'package.json'), 'utf8')); | ||
this._pkg = pkg; | ||
return pkg; | ||
} catch (_err) { | ||
try { | ||
var pkg1 = finder__default["default"].sync(ctx); | ||
this._pkg = pkg1; | ||
return pkg1; | ||
} catch (err) { | ||
console.error(err); | ||
return {}; | ||
} | ||
} | ||
} | ||
}, | ||
{ | ||
key: "getExposeGarfishModuleType", | ||
value: function getExposeGarfishModuleType() { | ||
var ctx = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : process.cwd(); | ||
var _pkg_mf; | ||
var pkg = this.readPKGJson(ctx); | ||
return (pkg === null || pkg === void 0 ? void 0 : (_pkg_mf = pkg['mf']) === null || _pkg_mf === void 0 ? void 0 : _pkg_mf.type) === sdk.MFModuleType.NPM ? sdk.MFModuleType.NPM : sdk.MFModuleType.APP; | ||
} | ||
} | ||
]); | ||
return PKGJsonManager; | ||
}(); | ||
var LOCAL_BUILD_VERSION = 'local'; | ||
function _array_like_to_array$2(arr, len) { | ||
@@ -139,3 +220,3 @@ if (len == null || len > arr.length) len = arr.length; | ||
var _step_value = _sliced_to_array$2(_step.value, 2), key = _step_value[0], value = _step_value[1]; | ||
if (typeof value === "string") { | ||
if (typeof value === 'string') { | ||
fn(key, normalizeSimple(value, key)); | ||
@@ -166,8 +247,8 @@ } else { | ||
var item = _step.value; | ||
if (typeof item === "string") { | ||
if (typeof item === 'string') { | ||
fn(item, normalizeSimple(item, item)); | ||
} else if (item && typeof item === "object") { | ||
} else if (item && typeof item === 'object') { | ||
object(item); | ||
} else { | ||
throw new Error("Unexpected options format"); | ||
throw new Error('Unexpected options format'); | ||
} | ||
@@ -194,6 +275,6 @@ } | ||
array(options); | ||
} else if (typeof options === "object") { | ||
} else if (typeof options === 'object') { | ||
object(options); | ||
} else { | ||
throw new Error("Unexpected options format"); | ||
throw new Error('Unexpected options format'); | ||
} | ||
@@ -212,6 +293,13 @@ } | ||
function getBuildVersion() { | ||
return process.env["MF_BUILD_VERSION"] || LOCAL_BUILD_VERSION; | ||
if (process.env['MF_BUILD_VERSION']) { | ||
return process.env['MF_BUILD_VERSION']; | ||
} | ||
var pkg = new PKGJsonManager().readPKGJson(); | ||
if ((pkg === null || pkg === void 0 ? void 0 : pkg['version']) && typeof pkg['version'] === 'string') { | ||
return pkg['version']; | ||
} | ||
return LOCAL_BUILD_VERSION; | ||
} | ||
function getBuildName() { | ||
return process.env["MF_BUILD_NAME"]; | ||
return process.env['MF_BUILD_NAME']; | ||
} | ||
@@ -249,3 +337,3 @@ // RegExp for version string | ||
} | ||
function _class_call_check$3(instance, Constructor) { | ||
function _class_call_check$2(instance, Constructor) { | ||
if (!(instance instanceof Constructor)) { | ||
@@ -255,3 +343,3 @@ throw new TypeError("Cannot call a class as a function"); | ||
} | ||
function _defineProperties$3(target, props) { | ||
function _defineProperties$2(target, props) { | ||
for(var i = 0; i < props.length; i++){ | ||
@@ -265,8 +353,8 @@ var descriptor = props[i]; | ||
} | ||
function _create_class$3(Constructor, protoProps, staticProps) { | ||
if (protoProps) _defineProperties$3(Constructor.prototype, protoProps); | ||
if (staticProps) _defineProperties$3(Constructor, staticProps); | ||
function _create_class$2(Constructor, protoProps, staticProps) { | ||
if (protoProps) _defineProperties$2(Constructor.prototype, protoProps); | ||
if (staticProps) _defineProperties$2(Constructor, staticProps); | ||
return Constructor; | ||
} | ||
function _define_property$3(obj, key, value) { | ||
function _define_property$2(obj, key, value) { | ||
if (key in obj) { | ||
@@ -392,5 +480,5 @@ Object.defineProperty(obj, key, { | ||
function normalizeExposeModuleName(exposeKey) { | ||
var relativePath = path__default["default"].relative(".", exposeKey); | ||
var relativePath = path__default["default"].relative('.', exposeKey); | ||
if (!relativePath) { | ||
return "ExposeEntry"; | ||
return 'ExposeEntry'; | ||
} | ||
@@ -403,10 +491,10 @@ return relativePath; | ||
function ContainerManager() { | ||
_class_call_check$3(this, ContainerManager); | ||
_class_call_check$2(this, ContainerManager); | ||
var _this; | ||
_this = _super.apply(this, arguments); | ||
_define_property$3(_assert_this_initialized$2(_this), "_manifestModuleInfos", void 0); | ||
_define_property$3(_assert_this_initialized$2(_this), "_parsedOptions", void 0); | ||
_define_property$2(_assert_this_initialized$2(_this), "_manifestModuleInfos", void 0); | ||
_define_property$2(_assert_this_initialized$2(_this), "_parsedOptions", void 0); | ||
return _this; | ||
} | ||
_create_class$3(ContainerManager, [ | ||
_create_class$2(ContainerManager, [ | ||
{ | ||
@@ -423,3 +511,3 @@ key: "enable", | ||
if (library) { | ||
if (typeof library.name === "string") { | ||
if (typeof library.name === 'string') { | ||
return library.name; | ||
@@ -495,3 +583,3 @@ } | ||
exposeObject.import.forEach(function(item) { | ||
var relativePath = path__default["default"].relative(".", item.replace(path__default["default"].extname(item), "")); | ||
var relativePath = path__default["default"].relative('.', item.replace(path__default["default"].extname(item), '')); | ||
sum[exposeKey].push(relativePath); | ||
@@ -540,3 +628,3 @@ }); | ||
return Object.values(this.manifestModuleInfos).reduce(function(sum, cur) { | ||
var entry = cur.name === "ExposeEntry" ? "index" : cur.name.slice(0, 1).toLowerCase() + cur.name.slice(1); | ||
var entry = cur.name === 'ExposeEntry' ? 'index' : cur.name.slice(0, 1).toLowerCase() + cur.name.slice(1); | ||
sum[entry] = cur.file; | ||
@@ -590,83 +678,2 @@ return sum; | ||
function _class_call_check$2(instance, Constructor) { | ||
if (!(instance instanceof Constructor)) { | ||
throw new TypeError("Cannot call a class as a function"); | ||
} | ||
} | ||
function _defineProperties$2(target, props) { | ||
for(var i = 0; i < props.length; i++){ | ||
var descriptor = props[i]; | ||
descriptor.enumerable = descriptor.enumerable || false; | ||
descriptor.configurable = true; | ||
if ("value" in descriptor) descriptor.writable = true; | ||
Object.defineProperty(target, descriptor.key, descriptor); | ||
} | ||
} | ||
function _create_class$2(Constructor, protoProps, staticProps) { | ||
if (protoProps) _defineProperties$2(Constructor.prototype, protoProps); | ||
if (staticProps) _defineProperties$2(Constructor, staticProps); | ||
return Constructor; | ||
} | ||
function _define_property$2(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; | ||
} | ||
var PKGJsonManager = /*#__PURE__*/ function() { | ||
function PKGJsonManager() { | ||
_class_call_check$2(this, PKGJsonManager); | ||
_define_property$2(this, "_pkg", void 0); | ||
} | ||
_create_class$2(PKGJsonManager, [ | ||
{ | ||
key: "setPKGJson", | ||
value: function setPKGJson(pkg) { | ||
this._pkg = pkg; | ||
} | ||
}, | ||
{ | ||
key: "readPKGJson", | ||
value: function readPKGJson() { | ||
var ctx = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : process.cwd(); | ||
if (this._pkg) { | ||
return this._pkg; | ||
} | ||
try { | ||
// eslint-disable-next-line no-restricted-globals | ||
var pkg = JSON.parse(fs__default["default"].readFileSync(path__default["default"].resolve(ctx, "package.json"), "utf8")); | ||
this._pkg = pkg; | ||
return pkg; | ||
} catch (_err) { | ||
try { | ||
var pkg1 = finder__default["default"].sync(ctx); | ||
this._pkg = pkg1; | ||
return pkg1; | ||
} catch (err) { | ||
console.error(err); | ||
return {}; | ||
} | ||
} | ||
} | ||
}, | ||
{ | ||
key: "getExposeGarfishModuleType", | ||
value: function getExposeGarfishModuleType() { | ||
var ctx = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : process.cwd(); | ||
var _pkg_mf; | ||
var pkg = this.readPKGJson(ctx); | ||
return (pkg === null || pkg === void 0 ? void 0 : (_pkg_mf = pkg["mf"]) === null || _pkg_mf === void 0 ? void 0 : _pkg_mf.type) === sdk.MFModuleType.NPM ? sdk.MFModuleType.NPM : sdk.MFModuleType.APP; | ||
} | ||
} | ||
]); | ||
return PKGJsonManager; | ||
}(); | ||
function _assert_this_initialized$1(self) { | ||
@@ -810,6 +817,6 @@ if (self === void 0) { | ||
function getEntry(remoteObj) { | ||
if (typeof remoteObj === "string") { | ||
if (typeof remoteObj === 'string') { | ||
return remoteObj; | ||
} | ||
if (typeof remoteObj.external === "string") { | ||
if (typeof remoteObj.external === 'string') { | ||
return remoteObj.external; | ||
@@ -844,3 +851,3 @@ } | ||
var curObj; | ||
if ("entry" in normalizedOption) { | ||
if ('entry' in normalizedOption) { | ||
curObj = { | ||
@@ -880,3 +887,3 @@ entry: normalizedOption.entry, | ||
var remoteInfo = _this.normalizedOptions[remoteAlias]; | ||
sum[remoteAlias] = sdk.composeKeyWithSeparator(remoteInfo.name, "entry" in remoteInfo ? remoteInfo.entry : remoteInfo.version); | ||
sum[remoteAlias] = sdk.composeKeyWithSeparator(remoteInfo.name, 'entry' in remoteInfo ? remoteInfo.entry : remoteInfo.version); | ||
return sum; | ||
@@ -907,3 +914,3 @@ }, {}); | ||
try { | ||
parsedOptions = sdk.parseEntry(typeof remoteInfo === "string" ? remoteInfo : getEntry(remoteInfo), "", "@"); | ||
parsedOptions = sdk.parseEntry(typeof remoteInfo === 'string' ? remoteInfo : getEntry(remoteInfo), '', '@'); | ||
} catch (e) { | ||
@@ -917,3 +924,3 @@ // noop | ||
alias: remoteAlias, | ||
shareScope: typeof remoteInfo === "object" ? remoteInfo.shareScope || "default" : "default" | ||
shareScope: typeof remoteInfo === 'object' ? remoteInfo.shareScope || 'default' : 'default' | ||
}); | ||
@@ -1152,3 +1159,3 @@ return sum; | ||
shared: shared, | ||
shareScope: this.options.shareScope || "default" | ||
shareScope: this.options.shareScope || 'default' | ||
}; | ||
@@ -1161,3 +1168,3 @@ } | ||
try { | ||
var pkgPath = ""; | ||
var pkgPath = ''; | ||
var depName = name; | ||
@@ -1167,3 +1174,3 @@ if (shareConfig.import) { | ||
pkgPath = shareConfig.import; | ||
} else if (shareConfig.import.startsWith(".")) { | ||
} else if (shareConfig.import.startsWith('.')) { | ||
pkgPath = path__default["default"].resolve(process.cwd(), shareConfig.import); | ||
@@ -1183,5 +1190,5 @@ } | ||
return { | ||
pkg: JSON.parse(fs__default$1["default"].readFileSync(pkgJsonPath, "utf-8")), | ||
path: "", | ||
pkgPath: "" | ||
pkg: JSON.parse(fs__default$1["default"].readFileSync(pkgJsonPath, 'utf-8')), | ||
path: '', | ||
pkgPath: '' | ||
}; | ||
@@ -1191,4 +1198,4 @@ } catch (err) { | ||
pkg: {}, | ||
path: "", | ||
pkgPath: "" | ||
path: '', | ||
pkgPath: '' | ||
}; | ||
@@ -1204,3 +1211,3 @@ } | ||
requiredVersion: undefined, | ||
shareScope: "default" | ||
shareScope: 'default' | ||
}; | ||
@@ -1216,3 +1223,3 @@ return _object_spread({}, defaultSharedConfig, sharedConfig); | ||
var sharedOptions = parseOptions(options, function(item, key) { | ||
if (typeof item !== "string") throw new Error("Unexpected array in shared"); | ||
if (typeof item !== 'string') throw new Error('Unexpected array in shared'); | ||
var config = item === key || !isRequiredVersion(item) ? { | ||
@@ -1233,5 +1240,5 @@ import: item | ||
normalizedShared[sharedName] = _object_spread_props(_object_spread({}, sharedConfig), { | ||
requiredVersion: typeof sharedConfig.requiredVersion !== "undefined" ? sharedConfig.requiredVersion : "^".concat(pkgInfo.pkg["version"]), | ||
requiredVersion: typeof sharedConfig.requiredVersion !== 'undefined' ? sharedConfig.requiredVersion : "^".concat(pkgInfo.pkg['version']), | ||
name: sharedName, | ||
version: pkgInfo.pkg["version"], | ||
version: pkgInfo.pkg['version'], | ||
eager: Boolean(sharedConfig.eager) | ||
@@ -1238,0 +1245,0 @@ }); |
import path from 'path'; | ||
import { generateExposeFilename, MFModuleType, composeKeyWithSeparator, parseEntry } from '@module-federation/sdk'; | ||
import { MFModuleType, generateExposeFilename, composeKeyWithSeparator, parseEntry } from '@module-federation/sdk'; | ||
import finder from 'find-pkg'; | ||
@@ -73,4 +73,85 @@ import fs from 'fs'; | ||
var LOCAL_BUILD_VERSION = "local"; | ||
function _class_call_check$3(instance, Constructor) { | ||
if (!(instance instanceof Constructor)) { | ||
throw new TypeError("Cannot call a class as a function"); | ||
} | ||
} | ||
function _defineProperties$3(target, props) { | ||
for(var i = 0; i < props.length; i++){ | ||
var descriptor = props[i]; | ||
descriptor.enumerable = descriptor.enumerable || false; | ||
descriptor.configurable = true; | ||
if ("value" in descriptor) descriptor.writable = true; | ||
Object.defineProperty(target, descriptor.key, descriptor); | ||
} | ||
} | ||
function _create_class$3(Constructor, protoProps, staticProps) { | ||
if (protoProps) _defineProperties$3(Constructor.prototype, protoProps); | ||
if (staticProps) _defineProperties$3(Constructor, staticProps); | ||
return Constructor; | ||
} | ||
function _define_property$3(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; | ||
} | ||
var PKGJsonManager = /*#__PURE__*/ function() { | ||
function PKGJsonManager() { | ||
_class_call_check$3(this, PKGJsonManager); | ||
_define_property$3(this, "_pkg", void 0); | ||
} | ||
_create_class$3(PKGJsonManager, [ | ||
{ | ||
key: "setPKGJson", | ||
value: function setPKGJson(pkg) { | ||
this._pkg = pkg; | ||
} | ||
}, | ||
{ | ||
key: "readPKGJson", | ||
value: function readPKGJson() { | ||
var ctx = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : process.cwd(); | ||
if (this._pkg) { | ||
return this._pkg; | ||
} | ||
try { | ||
// eslint-disable-next-line no-restricted-globals | ||
var pkg = JSON.parse(fs.readFileSync(path.resolve(ctx, 'package.json'), 'utf8')); | ||
this._pkg = pkg; | ||
return pkg; | ||
} catch (_err) { | ||
try { | ||
var pkg1 = finder.sync(ctx); | ||
this._pkg = pkg1; | ||
return pkg1; | ||
} catch (err) { | ||
console.error(err); | ||
return {}; | ||
} | ||
} | ||
} | ||
}, | ||
{ | ||
key: "getExposeGarfishModuleType", | ||
value: function getExposeGarfishModuleType() { | ||
var ctx = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : process.cwd(); | ||
var _pkg_mf; | ||
var pkg = this.readPKGJson(ctx); | ||
return (pkg === null || pkg === void 0 ? void 0 : (_pkg_mf = pkg['mf']) === null || _pkg_mf === void 0 ? void 0 : _pkg_mf.type) === MFModuleType.NPM ? MFModuleType.NPM : MFModuleType.APP; | ||
} | ||
} | ||
]); | ||
return PKGJsonManager; | ||
}(); | ||
var LOCAL_BUILD_VERSION = 'local'; | ||
function _array_like_to_array$2(arr, len) { | ||
@@ -128,3 +209,3 @@ if (len == null || len > arr.length) len = arr.length; | ||
var _step_value = _sliced_to_array$2(_step.value, 2), key = _step_value[0], value = _step_value[1]; | ||
if (typeof value === "string") { | ||
if (typeof value === 'string') { | ||
fn(key, normalizeSimple(value, key)); | ||
@@ -155,8 +236,8 @@ } else { | ||
var item = _step.value; | ||
if (typeof item === "string") { | ||
if (typeof item === 'string') { | ||
fn(item, normalizeSimple(item, item)); | ||
} else if (item && typeof item === "object") { | ||
} else if (item && typeof item === 'object') { | ||
object(item); | ||
} else { | ||
throw new Error("Unexpected options format"); | ||
throw new Error('Unexpected options format'); | ||
} | ||
@@ -183,6 +264,6 @@ } | ||
array(options); | ||
} else if (typeof options === "object") { | ||
} else if (typeof options === 'object') { | ||
object(options); | ||
} else { | ||
throw new Error("Unexpected options format"); | ||
throw new Error('Unexpected options format'); | ||
} | ||
@@ -201,6 +282,13 @@ } | ||
function getBuildVersion() { | ||
return process.env["MF_BUILD_VERSION"] || LOCAL_BUILD_VERSION; | ||
if (process.env['MF_BUILD_VERSION']) { | ||
return process.env['MF_BUILD_VERSION']; | ||
} | ||
var pkg = new PKGJsonManager().readPKGJson(); | ||
if ((pkg === null || pkg === void 0 ? void 0 : pkg['version']) && typeof pkg['version'] === 'string') { | ||
return pkg['version']; | ||
} | ||
return LOCAL_BUILD_VERSION; | ||
} | ||
function getBuildName() { | ||
return process.env["MF_BUILD_NAME"]; | ||
return process.env['MF_BUILD_NAME']; | ||
} | ||
@@ -238,3 +326,3 @@ // RegExp for version string | ||
} | ||
function _class_call_check$3(instance, Constructor) { | ||
function _class_call_check$2(instance, Constructor) { | ||
if (!(instance instanceof Constructor)) { | ||
@@ -244,3 +332,3 @@ throw new TypeError("Cannot call a class as a function"); | ||
} | ||
function _defineProperties$3(target, props) { | ||
function _defineProperties$2(target, props) { | ||
for(var i = 0; i < props.length; i++){ | ||
@@ -254,8 +342,8 @@ var descriptor = props[i]; | ||
} | ||
function _create_class$3(Constructor, protoProps, staticProps) { | ||
if (protoProps) _defineProperties$3(Constructor.prototype, protoProps); | ||
if (staticProps) _defineProperties$3(Constructor, staticProps); | ||
function _create_class$2(Constructor, protoProps, staticProps) { | ||
if (protoProps) _defineProperties$2(Constructor.prototype, protoProps); | ||
if (staticProps) _defineProperties$2(Constructor, staticProps); | ||
return Constructor; | ||
} | ||
function _define_property$3(obj, key, value) { | ||
function _define_property$2(obj, key, value) { | ||
if (key in obj) { | ||
@@ -381,5 +469,5 @@ Object.defineProperty(obj, key, { | ||
function normalizeExposeModuleName(exposeKey) { | ||
var relativePath = path.relative(".", exposeKey); | ||
var relativePath = path.relative('.', exposeKey); | ||
if (!relativePath) { | ||
return "ExposeEntry"; | ||
return 'ExposeEntry'; | ||
} | ||
@@ -392,10 +480,10 @@ return relativePath; | ||
function ContainerManager() { | ||
_class_call_check$3(this, ContainerManager); | ||
_class_call_check$2(this, ContainerManager); | ||
var _this; | ||
_this = _super.apply(this, arguments); | ||
_define_property$3(_assert_this_initialized$2(_this), "_manifestModuleInfos", void 0); | ||
_define_property$3(_assert_this_initialized$2(_this), "_parsedOptions", void 0); | ||
_define_property$2(_assert_this_initialized$2(_this), "_manifestModuleInfos", void 0); | ||
_define_property$2(_assert_this_initialized$2(_this), "_parsedOptions", void 0); | ||
return _this; | ||
} | ||
_create_class$3(ContainerManager, [ | ||
_create_class$2(ContainerManager, [ | ||
{ | ||
@@ -412,3 +500,3 @@ key: "enable", | ||
if (library) { | ||
if (typeof library.name === "string") { | ||
if (typeof library.name === 'string') { | ||
return library.name; | ||
@@ -484,3 +572,3 @@ } | ||
exposeObject.import.forEach(function(item) { | ||
var relativePath = path.relative(".", item.replace(path.extname(item), "")); | ||
var relativePath = path.relative('.', item.replace(path.extname(item), '')); | ||
sum[exposeKey].push(relativePath); | ||
@@ -529,3 +617,3 @@ }); | ||
return Object.values(this.manifestModuleInfos).reduce(function(sum, cur) { | ||
var entry = cur.name === "ExposeEntry" ? "index" : cur.name.slice(0, 1).toLowerCase() + cur.name.slice(1); | ||
var entry = cur.name === 'ExposeEntry' ? 'index' : cur.name.slice(0, 1).toLowerCase() + cur.name.slice(1); | ||
sum[entry] = cur.file; | ||
@@ -579,83 +667,2 @@ return sum; | ||
function _class_call_check$2(instance, Constructor) { | ||
if (!(instance instanceof Constructor)) { | ||
throw new TypeError("Cannot call a class as a function"); | ||
} | ||
} | ||
function _defineProperties$2(target, props) { | ||
for(var i = 0; i < props.length; i++){ | ||
var descriptor = props[i]; | ||
descriptor.enumerable = descriptor.enumerable || false; | ||
descriptor.configurable = true; | ||
if ("value" in descriptor) descriptor.writable = true; | ||
Object.defineProperty(target, descriptor.key, descriptor); | ||
} | ||
} | ||
function _create_class$2(Constructor, protoProps, staticProps) { | ||
if (protoProps) _defineProperties$2(Constructor.prototype, protoProps); | ||
if (staticProps) _defineProperties$2(Constructor, staticProps); | ||
return Constructor; | ||
} | ||
function _define_property$2(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; | ||
} | ||
var PKGJsonManager = /*#__PURE__*/ function() { | ||
function PKGJsonManager() { | ||
_class_call_check$2(this, PKGJsonManager); | ||
_define_property$2(this, "_pkg", void 0); | ||
} | ||
_create_class$2(PKGJsonManager, [ | ||
{ | ||
key: "setPKGJson", | ||
value: function setPKGJson(pkg) { | ||
this._pkg = pkg; | ||
} | ||
}, | ||
{ | ||
key: "readPKGJson", | ||
value: function readPKGJson() { | ||
var ctx = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : process.cwd(); | ||
if (this._pkg) { | ||
return this._pkg; | ||
} | ||
try { | ||
// eslint-disable-next-line no-restricted-globals | ||
var pkg = JSON.parse(fs.readFileSync(path.resolve(ctx, "package.json"), "utf8")); | ||
this._pkg = pkg; | ||
return pkg; | ||
} catch (_err) { | ||
try { | ||
var pkg1 = finder.sync(ctx); | ||
this._pkg = pkg1; | ||
return pkg1; | ||
} catch (err) { | ||
console.error(err); | ||
return {}; | ||
} | ||
} | ||
} | ||
}, | ||
{ | ||
key: "getExposeGarfishModuleType", | ||
value: function getExposeGarfishModuleType() { | ||
var ctx = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : process.cwd(); | ||
var _pkg_mf; | ||
var pkg = this.readPKGJson(ctx); | ||
return (pkg === null || pkg === void 0 ? void 0 : (_pkg_mf = pkg["mf"]) === null || _pkg_mf === void 0 ? void 0 : _pkg_mf.type) === MFModuleType.NPM ? MFModuleType.NPM : MFModuleType.APP; | ||
} | ||
} | ||
]); | ||
return PKGJsonManager; | ||
}(); | ||
function _assert_this_initialized$1(self) { | ||
@@ -799,6 +806,6 @@ if (self === void 0) { | ||
function getEntry(remoteObj) { | ||
if (typeof remoteObj === "string") { | ||
if (typeof remoteObj === 'string') { | ||
return remoteObj; | ||
} | ||
if (typeof remoteObj.external === "string") { | ||
if (typeof remoteObj.external === 'string') { | ||
return remoteObj.external; | ||
@@ -833,3 +840,3 @@ } | ||
var curObj; | ||
if ("entry" in normalizedOption) { | ||
if ('entry' in normalizedOption) { | ||
curObj = { | ||
@@ -869,3 +876,3 @@ entry: normalizedOption.entry, | ||
var remoteInfo = _this.normalizedOptions[remoteAlias]; | ||
sum[remoteAlias] = composeKeyWithSeparator(remoteInfo.name, "entry" in remoteInfo ? remoteInfo.entry : remoteInfo.version); | ||
sum[remoteAlias] = composeKeyWithSeparator(remoteInfo.name, 'entry' in remoteInfo ? remoteInfo.entry : remoteInfo.version); | ||
return sum; | ||
@@ -896,3 +903,3 @@ }, {}); | ||
try { | ||
parsedOptions = parseEntry(typeof remoteInfo === "string" ? remoteInfo : getEntry(remoteInfo), "", "@"); | ||
parsedOptions = parseEntry(typeof remoteInfo === 'string' ? remoteInfo : getEntry(remoteInfo), '', '@'); | ||
} catch (e) { | ||
@@ -906,3 +913,3 @@ // noop | ||
alias: remoteAlias, | ||
shareScope: typeof remoteInfo === "object" ? remoteInfo.shareScope || "default" : "default" | ||
shareScope: typeof remoteInfo === 'object' ? remoteInfo.shareScope || 'default' : 'default' | ||
}); | ||
@@ -1141,3 +1148,3 @@ return sum; | ||
shared: shared, | ||
shareScope: this.options.shareScope || "default" | ||
shareScope: this.options.shareScope || 'default' | ||
}; | ||
@@ -1150,3 +1157,3 @@ } | ||
try { | ||
var pkgPath = ""; | ||
var pkgPath = ''; | ||
var depName = name; | ||
@@ -1156,3 +1163,3 @@ if (shareConfig.import) { | ||
pkgPath = shareConfig.import; | ||
} else if (shareConfig.import.startsWith(".")) { | ||
} else if (shareConfig.import.startsWith('.')) { | ||
pkgPath = path.resolve(process.cwd(), shareConfig.import); | ||
@@ -1172,5 +1179,5 @@ } | ||
return { | ||
pkg: JSON.parse(fs$1.readFileSync(pkgJsonPath, "utf-8")), | ||
path: "", | ||
pkgPath: "" | ||
pkg: JSON.parse(fs$1.readFileSync(pkgJsonPath, 'utf-8')), | ||
path: '', | ||
pkgPath: '' | ||
}; | ||
@@ -1180,4 +1187,4 @@ } catch (err) { | ||
pkg: {}, | ||
path: "", | ||
pkgPath: "" | ||
path: '', | ||
pkgPath: '' | ||
}; | ||
@@ -1193,3 +1200,3 @@ } | ||
requiredVersion: undefined, | ||
shareScope: "default" | ||
shareScope: 'default' | ||
}; | ||
@@ -1205,3 +1212,3 @@ return _object_spread({}, defaultSharedConfig, sharedConfig); | ||
var sharedOptions = parseOptions(options, function(item, key) { | ||
if (typeof item !== "string") throw new Error("Unexpected array in shared"); | ||
if (typeof item !== 'string') throw new Error('Unexpected array in shared'); | ||
var config = item === key || !isRequiredVersion(item) ? { | ||
@@ -1222,5 +1229,5 @@ import: item | ||
normalizedShared[sharedName] = _object_spread_props(_object_spread({}, sharedConfig), { | ||
requiredVersion: typeof sharedConfig.requiredVersion !== "undefined" ? sharedConfig.requiredVersion : "^".concat(pkgInfo.pkg["version"]), | ||
requiredVersion: typeof sharedConfig.requiredVersion !== 'undefined' ? sharedConfig.requiredVersion : "^".concat(pkgInfo.pkg['version']), | ||
name: sharedName, | ||
version: pkgInfo.pkg["version"], | ||
version: pkgInfo.pkg['version'], | ||
eager: Boolean(sharedConfig.eager) | ||
@@ -1227,0 +1234,0 @@ }); |
{ | ||
"name": "@module-federation/managers", | ||
"version": "0.0.0-next-20240511031741", | ||
"version": "0.0.0-next-20240514062402", | ||
"license": "MIT", | ||
@@ -24,3 +24,3 @@ "description": "Provide managers for helping handle mf data .", | ||
"fs-extra": "9.1.0", | ||
"@module-federation/sdk": "0.0.0-next-20240511031741" | ||
"@module-federation/sdk": "0.0.0-next-20240514062402" | ||
}, | ||
@@ -27,0 +27,0 @@ "devDependencies": { |
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
102850
2548
13
+ Added@module-federation/sdk@0.0.0-next-20240514062402(transitive)
- Removed@module-federation/sdk@0.0.0-next-20240511031741(transitive)