Project Init

This commit is contained in:
Muluhabt
2026-05-29 15:23:46 +03:00
commit 2fbc557aac
67387 changed files with 6063341 additions and 0 deletions

21
node_modules/@module-federation/managers/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2024-present hanric(2heal1)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

1
node_modules/@module-federation/managers/README.md generated vendored Normal file
View File

@@ -0,0 +1 @@
# `@module-federation/managers` Documentation

View File

@@ -0,0 +1,10 @@
export declare class BasicPluginOptionsManager<T> {
private _options?;
private _root;
constructor(root?: string);
get enable(): boolean;
get options(): T;
get root(): string;
init(options: T, extraArgs?: Record<string, any>): void;
setOptions(options: T): void;
}

View File

@@ -0,0 +1,10 @@
export declare class BasicPluginOptionsManager<T> {
private _options?;
private _root;
constructor(root?: string);
get enable(): boolean;
get options(): T;
get root(): string;
init(options: T, extraArgs?: Record<string, any>): void;
setOptions(options: T): void;
}

View File

@@ -0,0 +1,70 @@
"use strict";
const __rslib_import_meta_url__ = /*#__PURE__*/ (function () {
return typeof document === 'undefined'
? new (require('url'.replace('', '')).URL)('file:' + __filename).href
: (document.currentScript && document.currentScript.src) ||
new URL('main.js', document.baseURI).href;
})();
;
// The require scope
var __webpack_require__ = {};
/************************************************************************/
// webpack/runtime/define_property_getters
(() => {
__webpack_require__.d = (exports, definition) => {
for(var key in definition) {
if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
}
}
};
})();
// webpack/runtime/has_own_property
(() => {
__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
})();
// webpack/runtime/make_namespace_object
(() => {
// define __esModule on exports
__webpack_require__.r = (exports) => {
if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
}
Object.defineProperty(exports, '__esModule', { value: true });
};
})();
/************************************************************************/
var __webpack_exports__ = {};
__webpack_require__.r(__webpack_exports__);
__webpack_require__.d(__webpack_exports__, {
BasicPluginOptionsManager: () => (BasicPluginOptionsManager)
});
class BasicPluginOptionsManager {
get enable() {
return Boolean(this._options);
}
get options() {
return this._options;
}
get root() {
return this._root;
}
init(options, extraArgs) {
this._options = options;
}
setOptions(options) {
this._options = options;
}
constructor(root = process.cwd()){
this._root = root;
}
}
exports.BasicPluginOptionsManager = __webpack_exports__.BasicPluginOptionsManager;
for(var __webpack_i__ in __webpack_exports__) {
if(["BasicPluginOptionsManager"].indexOf(__webpack_i__) === -1) {
exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
}
}
Object.defineProperty(exports, '__esModule', { value: true });

View File

@@ -0,0 +1,24 @@
;// CONCATENATED MODULE: ./src/BasicPluginOptionsManager.ts
class BasicPluginOptionsManager {
get enable() {
return Boolean(this._options);
}
get options() {
return this._options;
}
get root() {
return this._root;
}
init(options, extraArgs) {
this._options = options;
}
setOptions(options) {
this._options = options;
}
constructor(root = process.cwd()){
this._root = root;
}
}
export { BasicPluginOptionsManager };

View File

@@ -0,0 +1,20 @@
import type { containerPlugin, ManifestModuleInfos, moduleFederationPlugin } from '@module-federation/sdk';
import type { EntryObject } from 'webpack';
import { BasicPluginOptionsManager } from './BasicPluginOptionsManager';
declare class ContainerManager extends BasicPluginOptionsManager<moduleFederationPlugin.ModuleFederationPluginOptions> {
private _manifestModuleInfos?;
private _parsedOptions?;
get enable(): boolean;
get globalEntryName(): string | undefined;
get containerPluginExposesOptions(): containerPlugin.ContainerPluginOptions['exposes'];
get fileExposeKeyMap(): Record<string, Set<string>>;
get exposeFileNameImportMap(): Record<string, string[]>;
get exposeObject(): Record<string, string[]>;
get exposeFiles(): string[];
get manifestModuleInfos(): ManifestModuleInfos;
get webpackEntry(): EntryObject;
private _parseOptions;
init(options: moduleFederationPlugin.ModuleFederationPluginOptions): void;
validate(name?: string): void;
}
export { ContainerManager };

View File

@@ -0,0 +1,20 @@
import type { containerPlugin, ManifestModuleInfos, moduleFederationPlugin } from '@module-federation/sdk';
import type { EntryObject } from 'webpack';
import { BasicPluginOptionsManager } from './BasicPluginOptionsManager';
declare class ContainerManager extends BasicPluginOptionsManager<moduleFederationPlugin.ModuleFederationPluginOptions> {
private _manifestModuleInfos?;
private _parsedOptions?;
get enable(): boolean;
get globalEntryName(): string | undefined;
get containerPluginExposesOptions(): containerPlugin.ContainerPluginOptions['exposes'];
get fileExposeKeyMap(): Record<string, Set<string>>;
get exposeFileNameImportMap(): Record<string, string[]>;
get exposeObject(): Record<string, string[]>;
get exposeFiles(): string[];
get manifestModuleInfos(): ManifestModuleInfos;
get webpackEntry(): EntryObject;
private _parseOptions;
init(options: moduleFederationPlugin.ModuleFederationPluginOptions): void;
validate(name?: string): void;
}
export { ContainerManager };

View File

@@ -0,0 +1,228 @@
"use strict";
const __rslib_import_meta_url__ = /*#__PURE__*/ (function () {
return typeof document === 'undefined'
? new (require('url'.replace('', '')).URL)('file:' + __filename).href
: (document.currentScript && document.currentScript.src) ||
new URL('main.js', document.baseURI).href;
})();
;
// The require scope
var __webpack_require__ = {};
/************************************************************************/
// webpack/runtime/compat_get_default_export
(() => {
// getDefaultExport function for compatibility with non-ESM modules
__webpack_require__.n = (module) => {
var getter = module && module.__esModule ?
() => (module['default']) :
() => (module);
__webpack_require__.d(getter, { a: getter });
return getter;
};
})();
// webpack/runtime/define_property_getters
(() => {
__webpack_require__.d = (exports, definition) => {
for(var key in definition) {
if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
}
}
};
})();
// webpack/runtime/has_own_property
(() => {
__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
})();
// webpack/runtime/make_namespace_object
(() => {
// define __esModule on exports
__webpack_require__.r = (exports) => {
if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
}
Object.defineProperty(exports, '__esModule', { value: true });
};
})();
/************************************************************************/
var __webpack_exports__ = {};
// ESM COMPAT FLAG
__webpack_require__.r(__webpack_exports__);
// EXPORTS
__webpack_require__.d(__webpack_exports__, {
ContainerManager: () => (/* binding */ ContainerManager)
});
;// CONCATENATED MODULE: external "path"
const external_path_namespaceObject = require("path");
var external_path_default = /*#__PURE__*/__webpack_require__.n(external_path_namespaceObject);
;// CONCATENATED MODULE: external "@module-federation/sdk"
const sdk_namespaceObject = require("@module-federation/sdk");
;// CONCATENATED MODULE: external "./utils.js"
const external_utils_js_namespaceObject = require("./utils.js");
;// CONCATENATED MODULE: external "./BasicPluginOptionsManager.js"
const external_BasicPluginOptionsManager_js_namespaceObject = require("./BasicPluginOptionsManager.js");
;// CONCATENATED MODULE: ./src/ContainerManager.ts
function normalizeExposeModuleName(exposeKey) {
const relativePath = external_path_default().relative('.', exposeKey);
if (!relativePath) {
return 'ExposeEntry';
}
return relativePath;
}
class ContainerManager extends external_BasicPluginOptionsManager_js_namespaceObject.BasicPluginOptionsManager {
get enable() {
return Boolean(this.options.name && this.options.exposes && (Array.isArray(this.options.exposes) ? this.options.exposes.length > 0 : Object.keys(this.options.exposes).length > 0));
}
get globalEntryName() {
const { name, library } = this.options;
if (library) {
if (typeof library.name === 'string') {
return library.name;
}
return name;
}
return name;
}
get containerPluginExposesOptions() {
const { exposes } = this.options;
const parsedOptions = (0,external_utils_js_namespaceObject.parseOptions)(exposes, (item, key)=>({
import: Array.isArray(item) ? item : [
item
],
name: (0,sdk_namespaceObject.generateExposeFilename)(key, false)
}), (item, key)=>({
import: Array.isArray(item.import) ? item.import : [
item.import
],
name: item.name || (0,sdk_namespaceObject.generateExposeFilename)(key, false)
}));
return parsedOptions.reduce((sum, item)=>{
const [exposeKey, exposeObj] = item;
sum[exposeKey] = exposeObj;
return sum;
}, {});
}
// { '.' : './src/Button.jsx', './backup': './src/Button.jsx' } => { './src/Button' : ['.','./backup'] }
get fileExposeKeyMap() {
const parsedOptions = this._parseOptions();
return parsedOptions.reduce((sum, item)=>{
const [exposeKey, exposeObject] = item;
exposeObject.import.forEach((exposeFile)=>{
const exposeFileWithoutExt = exposeFile.replace(external_path_default().extname(exposeFile), '');
sum[exposeFileWithoutExt] ||= new Set();
sum[exposeFileWithoutExt].add(exposeKey);
});
return sum;
}, {});
}
// { '.' : './src/Button.jsx' } => { '__federation_expose_Component' : ['src/Buttton'] }
get exposeFileNameImportMap() {
const { exposes } = this.options;
const parsedOptions = (0,external_utils_js_namespaceObject.parseOptions)(exposes, (item, key)=>({
import: Array.isArray(item) ? item : [
item
],
name: (0,sdk_namespaceObject.generateExposeFilename)(key, false)
}), (item, key)=>({
import: Array.isArray(item.import) ? item.import : [
item.import
],
name: item.name || (0,sdk_namespaceObject.generateExposeFilename)(key, false)
}));
return parsedOptions.reduce((sum, item)=>{
const [_exposeKey, exposeObj] = item;
const { name, import: importPath } = exposeObj;
sum[name] = importPath;
return sum;
}, {});
}
// { '.' : './src/Button.jsx' } => { '.' : ['src/Button'] }
get exposeObject() {
const parsedOptions = this._parseOptions();
return parsedOptions.reduce((sum, item)=>{
const [exposeKey, exposeObject] = item;
sum[exposeKey] = [];
exposeObject.import.forEach((item)=>{
const relativePath = external_path_default().relative('.', item.replace(external_path_default().extname(item), ''));
sum[exposeKey].push(relativePath);
});
return sum;
}, {});
}
// { '.' : './src/Button.jsx' } => ['./src/Button.jsx']
get exposeFiles() {
const parsedOptions = this._parseOptions();
return parsedOptions.reduce((sum, item)=>{
const [_exposeKey, exposeObject] = item;
sum.push(...exposeObject.import);
return sum;
}, []);
}
get manifestModuleInfos() {
if (this._manifestModuleInfos) {
return this._manifestModuleInfos;
}
// { '.' : './src/Button.jsx' } => { '.' : { name: 'ExposeEntry', file: './src/Button.jsx', requires: {} } }
const parsedOptions = this._parseOptions();
this._manifestModuleInfos = parsedOptions.reduce((sum, item)=>{
const [exposeKey, exposeObject] = item;
sum[exposeKey] = {
name: exposeObject.name || normalizeExposeModuleName(exposeKey),
file: exposeObject.import
};
return sum;
}, {});
return this._manifestModuleInfos;
}
// { '.' : './src/Button.jsx' } => { index: ['./src/Button.jsx'] }
get webpackEntry() {
return Object.values(this.manifestModuleInfos).reduce((sum, cur)=>{
const entry = cur.name === 'ExposeEntry' ? 'index' : cur.name.slice(0, 1).toLowerCase() + cur.name.slice(1);
sum[entry] = cur.file;
return sum;
}, {});
}
_parseOptions() {
if (this._parsedOptions) {
return this._parsedOptions;
}
this._parsedOptions = (0,external_utils_js_namespaceObject.parseOptions)(this.options.exposes, (item)=>({
import: Array.isArray(item) ? item : [
item
],
name: undefined
}), (item)=>({
import: Array.isArray(item.import) ? item.import : [
item.import
],
name: undefined
}));
return this._parsedOptions;
}
init(options) {
this.setOptions(options);
this.validate(options.name);
}
validate(name) {
if (!name) {
throw new Error(`container name can not be empty!`);
}
}
}
exports.ContainerManager = __webpack_exports__.ContainerManager;
for(var __webpack_i__ in __webpack_exports__) {
if(["ContainerManager"].indexOf(__webpack_i__) === -1) {
exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
}
}
Object.defineProperty(exports, '__esModule', { value: true });

View File

@@ -0,0 +1,168 @@
import path from "path";
import { generateExposeFilename } from "@module-federation/sdk";
import { parseOptions } from "./utils.mjs";
import { BasicPluginOptionsManager } from "./BasicPluginOptionsManager.mjs";
;// CONCATENATED MODULE: external "path"
;// CONCATENATED MODULE: external "@module-federation/sdk"
;// CONCATENATED MODULE: external "./utils.mjs"
;// CONCATENATED MODULE: external "./BasicPluginOptionsManager.mjs"
;// CONCATENATED MODULE: ./src/ContainerManager.ts
function normalizeExposeModuleName(exposeKey) {
const relativePath = path.relative('.', exposeKey);
if (!relativePath) {
return 'ExposeEntry';
}
return relativePath;
}
class ContainerManager extends BasicPluginOptionsManager {
get enable() {
return Boolean(this.options.name && this.options.exposes && (Array.isArray(this.options.exposes) ? this.options.exposes.length > 0 : Object.keys(this.options.exposes).length > 0));
}
get globalEntryName() {
const { name, library } = this.options;
if (library) {
if (typeof library.name === 'string') {
return library.name;
}
return name;
}
return name;
}
get containerPluginExposesOptions() {
const { exposes } = this.options;
const parsedOptions = parseOptions(exposes, (item, key)=>({
import: Array.isArray(item) ? item : [
item
],
name: generateExposeFilename(key, false)
}), (item, key)=>({
import: Array.isArray(item.import) ? item.import : [
item.import
],
name: item.name || generateExposeFilename(key, false)
}));
return parsedOptions.reduce((sum, item)=>{
const [exposeKey, exposeObj] = item;
sum[exposeKey] = exposeObj;
return sum;
}, {});
}
// { '.' : './src/Button.jsx', './backup': './src/Button.jsx' } => { './src/Button' : ['.','./backup'] }
get fileExposeKeyMap() {
const parsedOptions = this._parseOptions();
return parsedOptions.reduce((sum, item)=>{
const [exposeKey, exposeObject] = item;
exposeObject.import.forEach((exposeFile)=>{
const exposeFileWithoutExt = exposeFile.replace(path.extname(exposeFile), '');
sum[exposeFileWithoutExt] ||= new Set();
sum[exposeFileWithoutExt].add(exposeKey);
});
return sum;
}, {});
}
// { '.' : './src/Button.jsx' } => { '__federation_expose_Component' : ['src/Buttton'] }
get exposeFileNameImportMap() {
const { exposes } = this.options;
const parsedOptions = parseOptions(exposes, (item, key)=>({
import: Array.isArray(item) ? item : [
item
],
name: generateExposeFilename(key, false)
}), (item, key)=>({
import: Array.isArray(item.import) ? item.import : [
item.import
],
name: item.name || generateExposeFilename(key, false)
}));
return parsedOptions.reduce((sum, item)=>{
const [_exposeKey, exposeObj] = item;
const { name, import: importPath } = exposeObj;
sum[name] = importPath;
return sum;
}, {});
}
// { '.' : './src/Button.jsx' } => { '.' : ['src/Button'] }
get exposeObject() {
const parsedOptions = this._parseOptions();
return parsedOptions.reduce((sum, item)=>{
const [exposeKey, exposeObject] = item;
sum[exposeKey] = [];
exposeObject.import.forEach((item)=>{
const relativePath = path.relative('.', item.replace(path.extname(item), ''));
sum[exposeKey].push(relativePath);
});
return sum;
}, {});
}
// { '.' : './src/Button.jsx' } => ['./src/Button.jsx']
get exposeFiles() {
const parsedOptions = this._parseOptions();
return parsedOptions.reduce((sum, item)=>{
const [_exposeKey, exposeObject] = item;
sum.push(...exposeObject.import);
return sum;
}, []);
}
get manifestModuleInfos() {
if (this._manifestModuleInfos) {
return this._manifestModuleInfos;
}
// { '.' : './src/Button.jsx' } => { '.' : { name: 'ExposeEntry', file: './src/Button.jsx', requires: {} } }
const parsedOptions = this._parseOptions();
this._manifestModuleInfos = parsedOptions.reduce((sum, item)=>{
const [exposeKey, exposeObject] = item;
sum[exposeKey] = {
name: exposeObject.name || normalizeExposeModuleName(exposeKey),
file: exposeObject.import
};
return sum;
}, {});
return this._manifestModuleInfos;
}
// { '.' : './src/Button.jsx' } => { index: ['./src/Button.jsx'] }
get webpackEntry() {
return Object.values(this.manifestModuleInfos).reduce((sum, cur)=>{
const entry = cur.name === 'ExposeEntry' ? 'index' : cur.name.slice(0, 1).toLowerCase() + cur.name.slice(1);
sum[entry] = cur.file;
return sum;
}, {});
}
_parseOptions() {
if (this._parsedOptions) {
return this._parsedOptions;
}
this._parsedOptions = parseOptions(this.options.exposes, (item)=>({
import: Array.isArray(item) ? item : [
item
],
name: undefined
}), (item)=>({
import: Array.isArray(item.import) ? item.import : [
item.import
],
name: undefined
}));
return this._parsedOptions;
}
init(options) {
this.setOptions(options);
this.validate(options.name);
}
validate(name) {
if (!name) {
throw new Error(`container name can not be empty!`);
}
}
}
export { ContainerManager };

21
node_modules/@module-federation/managers/dist/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2024-present hanric(2heal1)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -0,0 +1,6 @@
export declare class PKGJsonManager {
private _pkg?;
setPKGJson(pkg: Record<string, any>): void;
readPKGJson(root?: string): Record<string, any>;
getExposeGarfishModuleType(root?: string): string;
}

View File

@@ -0,0 +1,6 @@
export declare class PKGJsonManager {
private _pkg?;
setPKGJson(pkg: Record<string, any>): void;
readPKGJson(root?: string): Record<string, any>;
getExposeGarfishModuleType(root?: string): string;
}

View File

@@ -0,0 +1,113 @@
"use strict";
const __rslib_import_meta_url__ = /*#__PURE__*/ (function () {
return typeof document === 'undefined'
? new (require('url'.replace('', '')).URL)('file:' + __filename).href
: (document.currentScript && document.currentScript.src) ||
new URL('main.js', document.baseURI).href;
})();
;
// The require scope
var __webpack_require__ = {};
/************************************************************************/
// webpack/runtime/compat_get_default_export
(() => {
// getDefaultExport function for compatibility with non-ESM modules
__webpack_require__.n = (module) => {
var getter = module && module.__esModule ?
() => (module['default']) :
() => (module);
__webpack_require__.d(getter, { a: getter });
return getter;
};
})();
// webpack/runtime/define_property_getters
(() => {
__webpack_require__.d = (exports, definition) => {
for(var key in definition) {
if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
}
}
};
})();
// webpack/runtime/has_own_property
(() => {
__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
})();
// webpack/runtime/make_namespace_object
(() => {
// define __esModule on exports
__webpack_require__.r = (exports) => {
if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
}
Object.defineProperty(exports, '__esModule', { value: true });
};
})();
/************************************************************************/
var __webpack_exports__ = {};
// ESM COMPAT FLAG
__webpack_require__.r(__webpack_exports__);
// EXPORTS
__webpack_require__.d(__webpack_exports__, {
PKGJsonManager: () => (/* binding */ PKGJsonManager)
});
;// CONCATENATED MODULE: external "path"
const external_path_namespaceObject = require("path");
var external_path_default = /*#__PURE__*/__webpack_require__.n(external_path_namespaceObject);
;// CONCATENATED MODULE: external "find-pkg"
const external_find_pkg_namespaceObject = require("find-pkg");
var external_find_pkg_default = /*#__PURE__*/__webpack_require__.n(external_find_pkg_namespaceObject);
;// CONCATENATED MODULE: external "fs"
const external_fs_namespaceObject = require("fs");
var external_fs_default = /*#__PURE__*/__webpack_require__.n(external_fs_namespaceObject);
;// CONCATENATED MODULE: external "@module-federation/sdk"
const sdk_namespaceObject = require("@module-federation/sdk");
;// CONCATENATED MODULE: ./src/PKGJsonManager.ts
// @ts-ignore this pkg miss types
class PKGJsonManager {
setPKGJson(pkg) {
this._pkg = pkg;
}
readPKGJson(root = process.cwd()) {
if (this._pkg) {
return this._pkg;
}
try {
// eslint-disable-next-line no-restricted-globals
const pkg = JSON.parse(external_fs_default().readFileSync(external_path_default().resolve(root, 'package.json'), 'utf8'));
this._pkg = pkg;
return pkg;
} catch (_err) {
try {
const pkg = external_find_pkg_default().sync(root);
this._pkg = pkg;
return pkg;
} catch (err) {
sdk_namespaceObject.logger.error(err);
return {};
}
}
}
getExposeGarfishModuleType(root = process.cwd()) {
var _pkg_mf;
const pkg = this.readPKGJson(root);
return (pkg === null || pkg === void 0 ? void 0 : (_pkg_mf = pkg['mf']) === null || _pkg_mf === void 0 ? void 0 : _pkg_mf.type) === sdk_namespaceObject.MFModuleType.NPM ? sdk_namespaceObject.MFModuleType.NPM : sdk_namespaceObject.MFModuleType.APP;
}
}
exports.PKGJsonManager = __webpack_exports__.PKGJsonManager;
for(var __webpack_i__ in __webpack_exports__) {
if(["PKGJsonManager"].indexOf(__webpack_i__) === -1) {
exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
}
}
Object.defineProperty(exports, '__esModule', { value: true });

View File

@@ -0,0 +1,51 @@
import path from "path";
import find_pkg from "find-pkg";
import fs from "fs";
import { MFModuleType, logger } from "@module-federation/sdk";
;// CONCATENATED MODULE: external "path"
;// CONCATENATED MODULE: external "find-pkg"
;// CONCATENATED MODULE: external "fs"
;// CONCATENATED MODULE: external "@module-federation/sdk"
;// CONCATENATED MODULE: ./src/PKGJsonManager.ts
// @ts-ignore this pkg miss types
class PKGJsonManager {
setPKGJson(pkg) {
this._pkg = pkg;
}
readPKGJson(root = process.cwd()) {
if (this._pkg) {
return this._pkg;
}
try {
// eslint-disable-next-line no-restricted-globals
const pkg = JSON.parse(fs.readFileSync(path.resolve(root, 'package.json'), 'utf8'));
this._pkg = pkg;
return pkg;
} catch (_err) {
try {
const pkg = find_pkg.sync(root);
this._pkg = pkg;
return pkg;
} catch (err) {
logger.error(err);
return {};
}
}
}
getExposeGarfishModuleType(root = process.cwd()) {
var _pkg_mf;
const pkg = this.readPKGJson(root);
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;
}
}
export { PKGJsonManager };

View File

@@ -0,0 +1,18 @@
import { RemoteEntryInfo, StatsRemote, containerReferencePlugin, moduleFederationPlugin } from '@module-federation/sdk';
import { BasicPluginOptionsManager } from './BasicPluginOptionsManager';
interface NormalizedRemote {
[remoteName: string]: RemoteEntryInfo & {
alias: string;
shareScope: string | string[];
};
}
declare class RemoteManager extends BasicPluginOptionsManager<moduleFederationPlugin.ModuleFederationPluginOptions> {
normalizedOptions: NormalizedRemote;
get enable(): boolean;
get statsRemoteWithEmptyUsedIn(): StatsRemote[];
get dtsRemotes(): Record<string, string>;
get remotes(): moduleFederationPlugin.ModuleFederationPluginOptions['remotes'];
normalizeOptions(options?: containerReferencePlugin.ContainerReferencePluginOptions['remotes']): void;
init(options: moduleFederationPlugin.ModuleFederationPluginOptions): void;
}
export { RemoteManager };

View File

@@ -0,0 +1,18 @@
import { RemoteEntryInfo, StatsRemote, containerReferencePlugin, moduleFederationPlugin } from '@module-federation/sdk';
import { BasicPluginOptionsManager } from './BasicPluginOptionsManager';
interface NormalizedRemote {
[remoteName: string]: RemoteEntryInfo & {
alias: string;
shareScope: string | string[];
};
}
declare class RemoteManager extends BasicPluginOptionsManager<moduleFederationPlugin.ModuleFederationPluginOptions> {
normalizedOptions: NormalizedRemote;
get enable(): boolean;
get statsRemoteWithEmptyUsedIn(): StatsRemote[];
get dtsRemotes(): Record<string, string>;
get remotes(): moduleFederationPlugin.ModuleFederationPluginOptions['remotes'];
normalizeOptions(options?: containerReferencePlugin.ContainerReferencePluginOptions['remotes']): void;
init(options: moduleFederationPlugin.ModuleFederationPluginOptions): void;
}
export { RemoteManager };

View File

@@ -0,0 +1,160 @@
"use strict";
const __rslib_import_meta_url__ = /*#__PURE__*/ (function () {
return typeof document === 'undefined'
? new (require('url'.replace('', '')).URL)('file:' + __filename).href
: (document.currentScript && document.currentScript.src) ||
new URL('main.js', document.baseURI).href;
})();
;
// The require scope
var __webpack_require__ = {};
/************************************************************************/
// webpack/runtime/define_property_getters
(() => {
__webpack_require__.d = (exports, definition) => {
for(var key in definition) {
if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
}
}
};
})();
// webpack/runtime/has_own_property
(() => {
__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
})();
// webpack/runtime/make_namespace_object
(() => {
// define __esModule on exports
__webpack_require__.r = (exports) => {
if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
}
Object.defineProperty(exports, '__esModule', { value: true });
};
})();
/************************************************************************/
var __webpack_exports__ = {};
// ESM COMPAT FLAG
__webpack_require__.r(__webpack_exports__);
// EXPORTS
__webpack_require__.d(__webpack_exports__, {
RemoteManager: () => (/* binding */ RemoteManager)
});
;// CONCATENATED MODULE: external "@module-federation/sdk"
const sdk_namespaceObject = require("@module-federation/sdk");
;// CONCATENATED MODULE: external "./BasicPluginOptionsManager.js"
const external_BasicPluginOptionsManager_js_namespaceObject = require("./BasicPluginOptionsManager.js");
;// CONCATENATED MODULE: external "./constant.js"
const external_constant_js_namespaceObject = require("./constant.js");
;// CONCATENATED MODULE: ./src/RemoteManager.ts
function getEntry(remoteObj) {
if (typeof remoteObj === 'string') {
return remoteObj;
}
if (typeof remoteObj.external === 'string') {
return remoteObj.external;
}
throw new Error('Not support "array" remote value yet!');
}
class RemoteManager extends external_BasicPluginOptionsManager_js_namespaceObject.BasicPluginOptionsManager {
get enable() {
return Boolean(this.remotes && (Array.isArray(this.remotes) ? this.remotes.length > 0 : Object.keys(this.remotes).length > 0));
}
get statsRemoteWithEmptyUsedIn() {
const { name } = this.options;
return Object.keys(this.normalizedOptions).reduce((sum, cur)=>{
const normalizedOption = this.normalizedOptions[cur];
let curObj;
if ('entry' in normalizedOption) {
curObj = {
entry: normalizedOption.entry,
alias: normalizedOption.alias,
moduleName: external_constant_js_namespaceObject.UNKNOWN_MODULE_NAME,
federationContainerName: normalizedOption.name,
consumingFederationContainerName: name,
usedIn: [
external_constant_js_namespaceObject.UNKNOWN_MODULE_NAME
]
};
} else {
curObj = {
alias: normalizedOption.alias,
moduleName: external_constant_js_namespaceObject.UNKNOWN_MODULE_NAME,
version: normalizedOption.version,
federationContainerName: normalizedOption.name,
consumingFederationContainerName: name,
usedIn: [
external_constant_js_namespaceObject.UNKNOWN_MODULE_NAME
]
};
}
sum.push(curObj);
return sum;
}, []);
}
// 'micro-app-sub3': 'app:@garfish/micro-app-sub3:0.0.4',
// ↓↓↓
// {
// 'micro-app-sub3': @garfish/micro-app-sub3:0.0.4
// }
get dtsRemotes() {
return Object.keys(this.normalizedOptions).reduce((sum, remoteAlias)=>{
const remoteInfo = this.normalizedOptions[remoteAlias];
sum[remoteAlias] = (0,sdk_namespaceObject.composeKeyWithSeparator)(remoteInfo.name, 'entry' in remoteInfo ? remoteInfo.entry : remoteInfo.version);
return sum;
}, {});
}
get remotes() {
return this.options.remotes;
}
// INFO: only support remoteType: script now
normalizeOptions(options = {}) {
this.normalizedOptions = Object.keys(options).reduce((sum, remoteAlias)=>{
if (Array.isArray(options)) {
return sum;
}
const remoteInfo = options[remoteAlias];
if (Array.isArray(remoteInfo)) {
return sum;
}
let parsedOptions;
try {
parsedOptions = (0,sdk_namespaceObject.parseEntry)(typeof remoteInfo === 'string' ? remoteInfo : getEntry(remoteInfo), '', '@');
} catch (e) {
// noop
}
if (!parsedOptions) {
return sum;
}
sum[remoteAlias] = {
...parsedOptions,
alias: remoteAlias,
shareScope: typeof remoteInfo === 'object' ? remoteInfo.shareScope || 'default' : 'default'
};
return sum;
}, {});
}
init(options) {
this.setOptions(options);
this.normalizeOptions(options.remotes);
}
constructor(...args){
super(...args), this.normalizedOptions = {};
}
}
exports.RemoteManager = __webpack_exports__.RemoteManager;
for(var __webpack_i__ in __webpack_exports__) {
if(["RemoteManager"].indexOf(__webpack_i__) === -1) {
exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
}
}
Object.defineProperty(exports, '__esModule', { value: true });

View File

@@ -0,0 +1,112 @@
import { composeKeyWithSeparator, parseEntry } from "@module-federation/sdk";
import { BasicPluginOptionsManager } from "./BasicPluginOptionsManager.mjs";
import { UNKNOWN_MODULE_NAME } from "./constant.mjs";
;// CONCATENATED MODULE: external "@module-federation/sdk"
;// CONCATENATED MODULE: external "./BasicPluginOptionsManager.mjs"
;// CONCATENATED MODULE: external "./constant.mjs"
;// CONCATENATED MODULE: ./src/RemoteManager.ts
function getEntry(remoteObj) {
if (typeof remoteObj === 'string') {
return remoteObj;
}
if (typeof remoteObj.external === 'string') {
return remoteObj.external;
}
throw new Error('Not support "array" remote value yet!');
}
class RemoteManager extends BasicPluginOptionsManager {
get enable() {
return Boolean(this.remotes && (Array.isArray(this.remotes) ? this.remotes.length > 0 : Object.keys(this.remotes).length > 0));
}
get statsRemoteWithEmptyUsedIn() {
const { name } = this.options;
return Object.keys(this.normalizedOptions).reduce((sum, cur)=>{
const normalizedOption = this.normalizedOptions[cur];
let curObj;
if ('entry' in normalizedOption) {
curObj = {
entry: normalizedOption.entry,
alias: normalizedOption.alias,
moduleName: UNKNOWN_MODULE_NAME,
federationContainerName: normalizedOption.name,
consumingFederationContainerName: name,
usedIn: [
UNKNOWN_MODULE_NAME
]
};
} else {
curObj = {
alias: normalizedOption.alias,
moduleName: UNKNOWN_MODULE_NAME,
version: normalizedOption.version,
federationContainerName: normalizedOption.name,
consumingFederationContainerName: name,
usedIn: [
UNKNOWN_MODULE_NAME
]
};
}
sum.push(curObj);
return sum;
}, []);
}
// 'micro-app-sub3': 'app:@garfish/micro-app-sub3:0.0.4',
// ↓↓↓
// {
// 'micro-app-sub3': @garfish/micro-app-sub3:0.0.4
// }
get dtsRemotes() {
return Object.keys(this.normalizedOptions).reduce((sum, remoteAlias)=>{
const remoteInfo = this.normalizedOptions[remoteAlias];
sum[remoteAlias] = composeKeyWithSeparator(remoteInfo.name, 'entry' in remoteInfo ? remoteInfo.entry : remoteInfo.version);
return sum;
}, {});
}
get remotes() {
return this.options.remotes;
}
// INFO: only support remoteType: script now
normalizeOptions(options = {}) {
this.normalizedOptions = Object.keys(options).reduce((sum, remoteAlias)=>{
if (Array.isArray(options)) {
return sum;
}
const remoteInfo = options[remoteAlias];
if (Array.isArray(remoteInfo)) {
return sum;
}
let parsedOptions;
try {
parsedOptions = parseEntry(typeof remoteInfo === 'string' ? remoteInfo : getEntry(remoteInfo), '', '@');
} catch (e) {
// noop
}
if (!parsedOptions) {
return sum;
}
sum[remoteAlias] = {
...parsedOptions,
alias: remoteAlias,
shareScope: typeof remoteInfo === 'object' ? remoteInfo.shareScope || 'default' : 'default'
};
return sum;
}, {});
}
init(options) {
this.setOptions(options);
this.normalizeOptions(options.remotes);
}
constructor(...args){
super(...args), this.normalizedOptions = {};
}
}
export { RemoteManager };

View File

@@ -0,0 +1,18 @@
import { moduleFederationPlugin, sharePlugin } from '@module-federation/sdk';
import { NormalizedSharedOptions } from './types';
import { BasicPluginOptionsManager } from './BasicPluginOptionsManager';
declare class SharedManager extends BasicPluginOptionsManager<moduleFederationPlugin.ModuleFederationPluginOptions> {
normalizedOptions: NormalizedSharedOptions;
get enable(): boolean;
get sharedPluginOptions(): sharePlugin.SharePluginOptions;
findPkg(name: string, shareConfig: moduleFederationPlugin.SharedConfig): {
pkg: Record<string, any>;
path: string;
pkgPath: string;
};
get enableTreeShaking(): boolean;
transformSharedConfig(sharedConfig: moduleFederationPlugin.SharedConfig): moduleFederationPlugin.SharedConfig;
normalizeOptions(options: moduleFederationPlugin.ModuleFederationPluginOptions['shared']): void;
init(options: moduleFederationPlugin.ModuleFederationPluginOptions): void;
}
export { SharedManager };

View File

@@ -0,0 +1,18 @@
import { moduleFederationPlugin, sharePlugin } from '@module-federation/sdk';
import { NormalizedSharedOptions } from './types';
import { BasicPluginOptionsManager } from './BasicPluginOptionsManager';
declare class SharedManager extends BasicPluginOptionsManager<moduleFederationPlugin.ModuleFederationPluginOptions> {
normalizedOptions: NormalizedSharedOptions;
get enable(): boolean;
get sharedPluginOptions(): sharePlugin.SharePluginOptions;
findPkg(name: string, shareConfig: moduleFederationPlugin.SharedConfig): {
pkg: Record<string, any>;
path: string;
pkgPath: string;
};
get enableTreeShaking(): boolean;
transformSharedConfig(sharedConfig: moduleFederationPlugin.SharedConfig): moduleFederationPlugin.SharedConfig;
normalizeOptions(options: moduleFederationPlugin.ModuleFederationPluginOptions['shared']): void;
init(options: moduleFederationPlugin.ModuleFederationPluginOptions): void;
}
export { SharedManager };

View File

@@ -0,0 +1,196 @@
"use strict";
const __rslib_import_meta_url__ = /*#__PURE__*/ (function () {
return typeof document === 'undefined'
? new (require('url'.replace('', '')).URL)('file:' + __filename).href
: (document.currentScript && document.currentScript.src) ||
new URL('main.js', document.baseURI).href;
})();
;
// The require scope
var __webpack_require__ = {};
/************************************************************************/
// webpack/runtime/compat_get_default_export
(() => {
// getDefaultExport function for compatibility with non-ESM modules
__webpack_require__.n = (module) => {
var getter = module && module.__esModule ?
() => (module['default']) :
() => (module);
__webpack_require__.d(getter, { a: getter });
return getter;
};
})();
// webpack/runtime/define_property_getters
(() => {
__webpack_require__.d = (exports, definition) => {
for(var key in definition) {
if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
}
}
};
})();
// webpack/runtime/has_own_property
(() => {
__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
})();
// webpack/runtime/make_namespace_object
(() => {
// define __esModule on exports
__webpack_require__.r = (exports) => {
if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
}
Object.defineProperty(exports, '__esModule', { value: true });
};
})();
/************************************************************************/
var __webpack_exports__ = {};
// ESM COMPAT FLAG
__webpack_require__.r(__webpack_exports__);
// EXPORTS
__webpack_require__.d(__webpack_exports__, {
SharedManager: () => (/* binding */ SharedManager)
});
;// CONCATENATED MODULE: external "find-pkg"
const external_find_pkg_namespaceObject = require("find-pkg");
var external_find_pkg_default = /*#__PURE__*/__webpack_require__.n(external_find_pkg_namespaceObject);
;// CONCATENATED MODULE: external "path"
const external_path_namespaceObject = require("path");
var external_path_default = /*#__PURE__*/__webpack_require__.n(external_path_namespaceObject);
;// CONCATENATED MODULE: external "fs"
const external_fs_namespaceObject = require("fs");
var external_fs_default = /*#__PURE__*/__webpack_require__.n(external_fs_namespaceObject);
;// CONCATENATED MODULE: external "@module-federation/sdk"
const sdk_namespaceObject = require("@module-federation/sdk");
;// CONCATENATED MODULE: external "./BasicPluginOptionsManager.js"
const external_BasicPluginOptionsManager_js_namespaceObject = require("./BasicPluginOptionsManager.js");
;// CONCATENATED MODULE: external "./utils.js"
const external_utils_js_namespaceObject = require("./utils.js");
;// CONCATENATED MODULE: ./src/SharedManager.ts
// @ts-ignore this pkg miss types
class SharedManager extends external_BasicPluginOptionsManager_js_namespaceObject.BasicPluginOptionsManager {
get enable() {
return Boolean(Object.keys(this.sharedPluginOptions.shared).length);
}
get sharedPluginOptions() {
const normalizedShared = this.normalizedOptions;
const shared = Object.keys(normalizedShared).reduce((sum, cur)=>{
const { singleton, requiredVersion, version, eager, shareScope, import: sharedImport, treeShaking } = normalizedShared[cur];
sum[cur] = {
singleton,
requiredVersion,
version,
eager,
shareScope,
import: sharedImport,
treeShaking
};
return sum;
}, {});
return {
shared,
shareScope: this.options.shareScope || 'default'
};
}
findPkg(name, shareConfig) {
try {
let pkgPath = '';
let depName = name;
if (shareConfig.import) {
if (external_path_default().isAbsolute(shareConfig.import)) {
pkgPath = shareConfig.import;
} else if (shareConfig.import.startsWith('.')) {
pkgPath = external_path_default().resolve(this.root, shareConfig.import);
}
} else {
if (shareConfig.packageName) {
depName = shareConfig.packageName;
}
}
pkgPath = pkgPath || require.resolve(depName, {
paths: [
this.root
]
});
const pkgJsonPath = external_find_pkg_default().sync(pkgPath);
return {
pkg: JSON.parse(external_fs_default().readFileSync(pkgJsonPath, 'utf-8')),
path: '',
pkgPath: ''
};
} catch (err) {
return {
pkg: {},
path: '',
pkgPath: ''
};
}
}
get enableTreeShaking() {
return Object.values(this.normalizedOptions).some((item)=>item.treeShaking);
}
transformSharedConfig(sharedConfig) {
const defaultSharedConfig = {
singleton: true,
requiredVersion: undefined,
shareScope: 'default'
};
return {
...defaultSharedConfig,
...sharedConfig
};
}
normalizeOptions(options) {
const normalizedShared = {};
const sharedOptions = (0,external_utils_js_namespaceObject.parseOptions)(options, (item, key)=>{
if (typeof item !== 'string') throw new Error('Unexpected array in shared');
const config = item === key || !(0,sdk_namespaceObject.isRequiredVersion)(item) ? {
import: item
} : {
import: key,
requiredVersion: item
};
return config;
}, (item)=>item);
sharedOptions.forEach((item)=>{
const [sharedName, sharedOptions] = item;
const pkgInfo = this.findPkg(sharedName, sharedOptions);
const sharedConfig = this.transformSharedConfig(sharedOptions);
normalizedShared[sharedName] = {
...sharedConfig,
requiredVersion: typeof sharedConfig.requiredVersion !== 'undefined' ? sharedConfig.requiredVersion : `^${pkgInfo.pkg['version']}`,
name: sharedName,
version: pkgInfo.pkg['version'],
eager: Boolean(sharedConfig.eager)
};
});
this.normalizedOptions = normalizedShared;
}
init(options) {
this.setOptions(options);
this.normalizeOptions(options.shared);
}
constructor(...args){
super(...args), this.normalizedOptions = {};
}
}
exports.SharedManager = __webpack_exports__.SharedManager;
for(var __webpack_i__ in __webpack_exports__) {
if(["SharedManager"].indexOf(__webpack_i__) === -1) {
exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
}
}
Object.defineProperty(exports, '__esModule', { value: true });

View File

@@ -0,0 +1,136 @@
import find_pkg from "find-pkg";
import path from "path";
import fs from "fs";
import { isRequiredVersion } from "@module-federation/sdk";
import { BasicPluginOptionsManager } from "./BasicPluginOptionsManager.mjs";
import { parseOptions } from "./utils.mjs";
;// CONCATENATED MODULE: external "find-pkg"
;// CONCATENATED MODULE: external "path"
;// CONCATENATED MODULE: external "fs"
;// CONCATENATED MODULE: external "@module-federation/sdk"
;// CONCATENATED MODULE: external "./BasicPluginOptionsManager.mjs"
;// CONCATENATED MODULE: external "./utils.mjs"
;// CONCATENATED MODULE: ./src/SharedManager.ts
// @ts-ignore this pkg miss types
class SharedManager extends BasicPluginOptionsManager {
get enable() {
return Boolean(Object.keys(this.sharedPluginOptions.shared).length);
}
get sharedPluginOptions() {
const normalizedShared = this.normalizedOptions;
const shared = Object.keys(normalizedShared).reduce((sum, cur)=>{
const { singleton, requiredVersion, version, eager, shareScope, import: sharedImport, treeShaking } = normalizedShared[cur];
sum[cur] = {
singleton,
requiredVersion,
version,
eager,
shareScope,
import: sharedImport,
treeShaking
};
return sum;
}, {});
return {
shared,
shareScope: this.options.shareScope || 'default'
};
}
findPkg(name, shareConfig) {
try {
let pkgPath = '';
let depName = name;
if (shareConfig.import) {
if (path.isAbsolute(shareConfig.import)) {
pkgPath = shareConfig.import;
} else if (shareConfig.import.startsWith('.')) {
pkgPath = path.resolve(this.root, shareConfig.import);
}
} else {
if (shareConfig.packageName) {
depName = shareConfig.packageName;
}
}
pkgPath = pkgPath || require.resolve(depName, {
paths: [
this.root
]
});
const pkgJsonPath = find_pkg.sync(pkgPath);
return {
pkg: JSON.parse(fs.readFileSync(pkgJsonPath, 'utf-8')),
path: '',
pkgPath: ''
};
} catch (err) {
return {
pkg: {},
path: '',
pkgPath: ''
};
}
}
get enableTreeShaking() {
return Object.values(this.normalizedOptions).some((item)=>item.treeShaking);
}
transformSharedConfig(sharedConfig) {
const defaultSharedConfig = {
singleton: true,
requiredVersion: undefined,
shareScope: 'default'
};
return {
...defaultSharedConfig,
...sharedConfig
};
}
normalizeOptions(options) {
const normalizedShared = {};
const sharedOptions = parseOptions(options, (item, key)=>{
if (typeof item !== 'string') throw new Error('Unexpected array in shared');
const config = item === key || !isRequiredVersion(item) ? {
import: item
} : {
import: key,
requiredVersion: item
};
return config;
}, (item)=>item);
sharedOptions.forEach((item)=>{
const [sharedName, sharedOptions] = item;
const pkgInfo = this.findPkg(sharedName, sharedOptions);
const sharedConfig = this.transformSharedConfig(sharedOptions);
normalizedShared[sharedName] = {
...sharedConfig,
requiredVersion: typeof sharedConfig.requiredVersion !== 'undefined' ? sharedConfig.requiredVersion : `^${pkgInfo.pkg['version']}`,
name: sharedName,
version: pkgInfo.pkg['version'],
eager: Boolean(sharedConfig.eager)
};
});
this.normalizedOptions = normalizedShared;
}
init(options) {
this.setOptions(options);
this.normalizeOptions(options.shared);
}
constructor(...args){
super(...args), this.normalizedOptions = {};
}
}
export { SharedManager };

View File

@@ -0,0 +1,2 @@
export declare const LOCAL_BUILD_VERSION = "local";
export declare const UNKNOWN_MODULE_NAME = "UNKNOWN";

View File

@@ -0,0 +1,2 @@
export declare const LOCAL_BUILD_VERSION = "local";
export declare const UNKNOWN_MODULE_NAME = "UNKNOWN";

View File

@@ -0,0 +1,54 @@
"use strict";
const __rslib_import_meta_url__ = /*#__PURE__*/ (function () {
return typeof document === 'undefined'
? new (require('url'.replace('', '')).URL)('file:' + __filename).href
: (document.currentScript && document.currentScript.src) ||
new URL('main.js', document.baseURI).href;
})();
;
// The require scope
var __webpack_require__ = {};
/************************************************************************/
// webpack/runtime/define_property_getters
(() => {
__webpack_require__.d = (exports, definition) => {
for(var key in definition) {
if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
}
}
};
})();
// webpack/runtime/has_own_property
(() => {
__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
})();
// webpack/runtime/make_namespace_object
(() => {
// define __esModule on exports
__webpack_require__.r = (exports) => {
if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
}
Object.defineProperty(exports, '__esModule', { value: true });
};
})();
/************************************************************************/
var __webpack_exports__ = {};
__webpack_require__.r(__webpack_exports__);
__webpack_require__.d(__webpack_exports__, {
LOCAL_BUILD_VERSION: () => (LOCAL_BUILD_VERSION),
UNKNOWN_MODULE_NAME: () => (UNKNOWN_MODULE_NAME)
});
const LOCAL_BUILD_VERSION = 'local';
const UNKNOWN_MODULE_NAME = 'UNKNOWN';
exports.LOCAL_BUILD_VERSION = __webpack_exports__.LOCAL_BUILD_VERSION;
exports.UNKNOWN_MODULE_NAME = __webpack_exports__.UNKNOWN_MODULE_NAME;
for(var __webpack_i__ in __webpack_exports__) {
if(["LOCAL_BUILD_VERSION","UNKNOWN_MODULE_NAME"].indexOf(__webpack_i__) === -1) {
exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
}
}
Object.defineProperty(exports, '__esModule', { value: true });

View File

@@ -0,0 +1,6 @@
;// CONCATENATED MODULE: ./src/constant.ts
const LOCAL_BUILD_VERSION = 'local';
const UNKNOWN_MODULE_NAME = 'UNKNOWN';
export { LOCAL_BUILD_VERSION, UNKNOWN_MODULE_NAME };

View File

@@ -0,0 +1,8 @@
export { BasicPluginOptionsManager } from './BasicPluginOptionsManager';
export { ContainerManager } from './ContainerManager';
export { PKGJsonManager } from './PKGJsonManager';
export { RemoteManager } from './RemoteManager';
export { SharedManager } from './SharedManager';
export { UNKNOWN_MODULE_NAME } from './constant';
export * as utils from './utils';
export * as types from './types';

View File

@@ -0,0 +1,8 @@
export { BasicPluginOptionsManager } from './BasicPluginOptionsManager';
export { ContainerManager } from './ContainerManager';
export { PKGJsonManager } from './PKGJsonManager';
export { RemoteManager } from './RemoteManager';
export { SharedManager } from './SharedManager';
export { UNKNOWN_MODULE_NAME } from './constant';
export * as utils from './utils';
export * as types from './types';

93
node_modules/@module-federation/managers/dist/index.js generated vendored Normal file
View File

@@ -0,0 +1,93 @@
"use strict";
const __rslib_import_meta_url__ = /*#__PURE__*/ (function () {
return typeof document === 'undefined'
? new (require('url'.replace('', '')).URL)('file:' + __filename).href
: (document.currentScript && document.currentScript.src) ||
new URL('main.js', document.baseURI).href;
})();
;
// The require scope
var __webpack_require__ = {};
/************************************************************************/
// webpack/runtime/define_property_getters
(() => {
__webpack_require__.d = (exports, definition) => {
for(var key in definition) {
if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
}
}
};
})();
// webpack/runtime/has_own_property
(() => {
__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
})();
// webpack/runtime/make_namespace_object
(() => {
// define __esModule on exports
__webpack_require__.r = (exports) => {
if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
}
Object.defineProperty(exports, '__esModule', { value: true });
};
})();
/************************************************************************/
var __webpack_exports__ = {};
// ESM COMPAT FLAG
__webpack_require__.r(__webpack_exports__);
// EXPORTS
__webpack_require__.d(__webpack_exports__, {
UNKNOWN_MODULE_NAME: () => (/* reexport */ external_constant_js_namespaceObject.UNKNOWN_MODULE_NAME),
PKGJsonManager: () => (/* reexport */ external_PKGJsonManager_js_namespaceObject.PKGJsonManager),
types: () => (/* reexport */ external_types_js_namespaceObject),
SharedManager: () => (/* reexport */ external_SharedManager_js_namespaceObject.SharedManager),
ContainerManager: () => (/* reexport */ external_ContainerManager_js_namespaceObject.ContainerManager),
BasicPluginOptionsManager: () => (/* reexport */ external_BasicPluginOptionsManager_js_namespaceObject.BasicPluginOptionsManager),
utils: () => (/* reexport */ external_utils_js_namespaceObject),
RemoteManager: () => (/* reexport */ external_RemoteManager_js_namespaceObject.RemoteManager)
});
;// CONCATENATED MODULE: external "./BasicPluginOptionsManager.js"
const external_BasicPluginOptionsManager_js_namespaceObject = require("./BasicPluginOptionsManager.js");
;// CONCATENATED MODULE: external "./ContainerManager.js"
const external_ContainerManager_js_namespaceObject = require("./ContainerManager.js");
;// CONCATENATED MODULE: external "./PKGJsonManager.js"
const external_PKGJsonManager_js_namespaceObject = require("./PKGJsonManager.js");
;// CONCATENATED MODULE: external "./RemoteManager.js"
const external_RemoteManager_js_namespaceObject = require("./RemoteManager.js");
;// CONCATENATED MODULE: external "./SharedManager.js"
const external_SharedManager_js_namespaceObject = require("./SharedManager.js");
;// CONCATENATED MODULE: external "./constant.js"
const external_constant_js_namespaceObject = require("./constant.js");
;// CONCATENATED MODULE: external "./utils.js"
const external_utils_js_namespaceObject = require("./utils.js");
;// CONCATENATED MODULE: external "./types.js"
const external_types_js_namespaceObject = require("./types.js");
;// CONCATENATED MODULE: ./src/index.ts
exports.BasicPluginOptionsManager = __webpack_exports__.BasicPluginOptionsManager;
exports.ContainerManager = __webpack_exports__.ContainerManager;
exports.PKGJsonManager = __webpack_exports__.PKGJsonManager;
exports.RemoteManager = __webpack_exports__.RemoteManager;
exports.SharedManager = __webpack_exports__.SharedManager;
exports.UNKNOWN_MODULE_NAME = __webpack_exports__.UNKNOWN_MODULE_NAME;
exports.types = __webpack_exports__.types;
exports.utils = __webpack_exports__.utils;
for(var __webpack_i__ in __webpack_exports__) {
if(["BasicPluginOptionsManager","ContainerManager","PKGJsonManager","RemoteManager","SharedManager","UNKNOWN_MODULE_NAME","types","utils"].indexOf(__webpack_i__) === -1) {
exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
}
}
Object.defineProperty(exports, '__esModule', { value: true });

View File

@@ -0,0 +1,36 @@
import { BasicPluginOptionsManager } from "./BasicPluginOptionsManager.mjs";
import { ContainerManager } from "./ContainerManager.mjs";
import { PKGJsonManager } from "./PKGJsonManager.mjs";
import { RemoteManager } from "./RemoteManager.mjs";
import { SharedManager } from "./SharedManager.mjs";
import { UNKNOWN_MODULE_NAME } from "./constant.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__utils_mjs_25ece7d1__ from "./utils.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__types_mjs_4ad50757__ from "./types.mjs";
;// CONCATENATED MODULE: external "./BasicPluginOptionsManager.mjs"
;// CONCATENATED MODULE: external "./ContainerManager.mjs"
;// CONCATENATED MODULE: external "./PKGJsonManager.mjs"
;// CONCATENATED MODULE: external "./RemoteManager.mjs"
;// CONCATENATED MODULE: external "./SharedManager.mjs"
;// CONCATENATED MODULE: external "./constant.mjs"
;// CONCATENATED MODULE: external "./utils.mjs"
;// CONCATENATED MODULE: external "./types.mjs"
;// CONCATENATED MODULE: ./src/index.ts
export { BasicPluginOptionsManager, ContainerManager, PKGJsonManager, RemoteManager, SharedManager, UNKNOWN_MODULE_NAME, __WEBPACK_EXTERNAL_MODULE__types_mjs_4ad50757__ as types, __WEBPACK_EXTERNAL_MODULE__utils_mjs_25ece7d1__ as utils };

View File

@@ -0,0 +1,16 @@
import { WebpackOptionsNormalized } from 'webpack';
import { moduleFederationPlugin } from '@module-federation/sdk';
export type EntryStaticNormalized = Awaited<ReturnType<Extract<WebpackOptionsNormalized['entry'], () => any>>>;
export type EntryDescriptionNormalized = EntryStaticNormalized[keyof EntryStaticNormalized];
export type ContainerOptionsFormat<T> = (string | Record<string, string | string[] | T>)[] | Record<string, string | string[] | T>;
export type NormalizeSimple<R> = (value: string | string[], key: string) => R;
export type NormalizeOptions<T, R> = (value: T, key: string) => R;
export type ProcessFN<R> = (key: string, normalizedOptions: R) => void;
export type ParsedContainerOptions<T> = [string, T][];
export type NormalizedSharedOption = {
name: string;
version: string;
} & moduleFederationPlugin.SharedConfig;
export interface NormalizedSharedOptions {
[depName: string]: NormalizedSharedOption;
}

View File

@@ -0,0 +1,16 @@
import { WebpackOptionsNormalized } from 'webpack';
import { moduleFederationPlugin } from '@module-federation/sdk';
export type EntryStaticNormalized = Awaited<ReturnType<Extract<WebpackOptionsNormalized['entry'], () => any>>>;
export type EntryDescriptionNormalized = EntryStaticNormalized[keyof EntryStaticNormalized];
export type ContainerOptionsFormat<T> = (string | Record<string, string | string[] | T>)[] | Record<string, string | string[] | T>;
export type NormalizeSimple<R> = (value: string | string[], key: string) => R;
export type NormalizeOptions<T, R> = (value: T, key: string) => R;
export type ProcessFN<R> = (key: string, normalizedOptions: R) => void;
export type ParsedContainerOptions<T> = [string, T][];
export type NormalizedSharedOption = {
name: string;
version: string;
} & moduleFederationPlugin.SharedConfig;
export interface NormalizedSharedOptions {
[depName: string]: NormalizedSharedOption;
}

31
node_modules/@module-federation/managers/dist/types.js generated vendored Normal file
View File

@@ -0,0 +1,31 @@
"use strict";
const __rslib_import_meta_url__ = /*#__PURE__*/ (function () {
return typeof document === 'undefined'
? new (require('url'.replace('', '')).URL)('file:' + __filename).href
: (document.currentScript && document.currentScript.src) ||
new URL('main.js', document.baseURI).href;
})();
;
// The require scope
var __webpack_require__ = {};
/************************************************************************/
// webpack/runtime/make_namespace_object
(() => {
// define __esModule on exports
__webpack_require__.r = (exports) => {
if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
}
Object.defineProperty(exports, '__esModule', { value: true });
};
})();
/************************************************************************/
var __webpack_exports__ = {};
__webpack_require__.r(__webpack_exports__);
for(var __webpack_i__ in __webpack_exports__) {
exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
}
Object.defineProperty(exports, '__esModule', { value: true });

View File

@@ -0,0 +1,4 @@
;// CONCATENATED MODULE: ./src/types.ts

View File

@@ -0,0 +1,4 @@
import { ContainerOptionsFormat, NormalizeSimple, NormalizeOptions, ParsedContainerOptions } from './types';
export declare function parseOptions<T, R>(options: ContainerOptionsFormat<T>, normalizeSimple: NormalizeSimple<R>, normalizeOptions: NormalizeOptions<T, R>): ParsedContainerOptions<R>;
export declare function getBuildVersion(root?: string): string;
export declare function getBuildName(): string | undefined;

View File

@@ -0,0 +1,4 @@
import { ContainerOptionsFormat, NormalizeSimple, NormalizeOptions, ParsedContainerOptions } from './types';
export declare function parseOptions<T, R>(options: ContainerOptionsFormat<T>, normalizeSimple: NormalizeSimple<R>, normalizeOptions: NormalizeOptions<T, R>): ParsedContainerOptions<R>;
export declare function getBuildVersion(root?: string): string;
export declare function getBuildName(): string | undefined;

119
node_modules/@module-federation/managers/dist/utils.js generated vendored Normal file
View File

@@ -0,0 +1,119 @@
"use strict";
const __rslib_import_meta_url__ = /*#__PURE__*/ (function () {
return typeof document === 'undefined'
? new (require('url'.replace('', '')).URL)('file:' + __filename).href
: (document.currentScript && document.currentScript.src) ||
new URL('main.js', document.baseURI).href;
})();
;
// The require scope
var __webpack_require__ = {};
/************************************************************************/
// webpack/runtime/define_property_getters
(() => {
__webpack_require__.d = (exports, definition) => {
for(var key in definition) {
if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
}
}
};
})();
// webpack/runtime/has_own_property
(() => {
__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
})();
// webpack/runtime/make_namespace_object
(() => {
// define __esModule on exports
__webpack_require__.r = (exports) => {
if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
}
Object.defineProperty(exports, '__esModule', { value: true });
};
})();
/************************************************************************/
var __webpack_exports__ = {};
// ESM COMPAT FLAG
__webpack_require__.r(__webpack_exports__);
// EXPORTS
__webpack_require__.d(__webpack_exports__, {
getBuildVersion: () => (/* binding */ getBuildVersion),
getBuildName: () => (/* binding */ getBuildName),
parseOptions: () => (/* binding */ parseOptions)
});
;// CONCATENATED MODULE: external "./PKGJsonManager.js"
const external_PKGJsonManager_js_namespaceObject = require("./PKGJsonManager.js");
;// CONCATENATED MODULE: external "./constant.js"
const external_constant_js_namespaceObject = require("./constant.js");
;// CONCATENATED MODULE: ./src/utils.ts
function processFn(options, normalizeSimple, normalizeOptions, fn) {
const object = (obj)=>{
for (const [key, value] of Object.entries(obj)){
if (typeof value === 'string') {
fn(key, normalizeSimple(value, key));
} else {
fn(key, normalizeOptions(value, key));
}
}
};
const array = (items)=>{
for (const item of items){
if (typeof item === 'string') {
fn(item, normalizeSimple(item, item));
} else if (item && typeof item === 'object') {
object(item);
} else {
throw new Error('Unexpected options format');
}
}
};
if (!options) {
return;
} else if (Array.isArray(options)) {
array(options);
} else if (typeof options === 'object') {
object(options);
} else {
throw new Error('Unexpected options format');
}
}
function parseOptions(options, normalizeSimple, normalizeOptions) {
const items = [];
processFn(options, normalizeSimple, normalizeOptions, (key, value)=>{
items.push([
key,
value
]);
});
return items;
}
function getBuildVersion(root) {
if (process.env['MF_BUILD_VERSION']) {
return process.env['MF_BUILD_VERSION'];
}
const pkg = new external_PKGJsonManager_js_namespaceObject.PKGJsonManager().readPKGJson(root);
if ((pkg === null || pkg === void 0 ? void 0 : pkg['version']) && typeof pkg['version'] === 'string') {
return pkg['version'];
}
return external_constant_js_namespaceObject.LOCAL_BUILD_VERSION;
}
function getBuildName() {
return process.env['MF_BUILD_NAME'];
}
exports.getBuildName = __webpack_exports__.getBuildName;
exports.getBuildVersion = __webpack_exports__.getBuildVersion;
exports.parseOptions = __webpack_exports__.parseOptions;
for(var __webpack_i__ in __webpack_exports__) {
if(["getBuildName","getBuildVersion","parseOptions"].indexOf(__webpack_i__) === -1) {
exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
}
}
Object.defineProperty(exports, '__esModule', { value: true });

View File

@@ -0,0 +1,66 @@
import { PKGJsonManager } from "./PKGJsonManager.mjs";
import { LOCAL_BUILD_VERSION } from "./constant.mjs";
;// CONCATENATED MODULE: external "./PKGJsonManager.mjs"
;// CONCATENATED MODULE: external "./constant.mjs"
;// CONCATENATED MODULE: ./src/utils.ts
function processFn(options, normalizeSimple, normalizeOptions, fn) {
const object = (obj)=>{
for (const [key, value] of Object.entries(obj)){
if (typeof value === 'string') {
fn(key, normalizeSimple(value, key));
} else {
fn(key, normalizeOptions(value, key));
}
}
};
const array = (items)=>{
for (const item of items){
if (typeof item === 'string') {
fn(item, normalizeSimple(item, item));
} else if (item && typeof item === 'object') {
object(item);
} else {
throw new Error('Unexpected options format');
}
}
};
if (!options) {
return;
} else if (Array.isArray(options)) {
array(options);
} else if (typeof options === 'object') {
object(options);
} else {
throw new Error('Unexpected options format');
}
}
function parseOptions(options, normalizeSimple, normalizeOptions) {
const items = [];
processFn(options, normalizeSimple, normalizeOptions, (key, value)=>{
items.push([
key,
value
]);
});
return items;
}
function getBuildVersion(root) {
if (process.env['MF_BUILD_VERSION']) {
return process.env['MF_BUILD_VERSION'];
}
const pkg = new PKGJsonManager().readPKGJson(root);
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'];
}
export { getBuildName, getBuildVersion, parseOptions };

60
node_modules/@module-federation/managers/package.json generated vendored Normal file
View File

@@ -0,0 +1,60 @@
{
"name": "@module-federation/managers",
"version": "2.5.0",
"license": "MIT",
"description": "Provide managers for helping handle mf data .",
"keywords": [
"Module Federation"
],
"type": "commonjs",
"files": [
"dist/",
"README.md"
],
"publishConfig": {
"access": "public"
},
"author": "hanric <hanric.zhang@gmail.com>",
"repository": {
"type": "git",
"url": "git+https://github.com/module-federation/core.git",
"directory": "packages/managers"
},
"sideEffects": false,
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"dependencies": {
"find-pkg": "2.0.0",
"@module-federation/sdk": "2.5.0"
},
"devDependencies": {
"webpack": "5.104.1"
},
"exports": {
".": {
"import": {
"types": "./dist/index.d.mts",
"default": "./dist/index.mjs"
},
"require": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
}
}
},
"typesVersions": {
"*": {
".": [
"./dist/index.d.ts"
]
}
},
"scripts": {
"build": "rslib build",
"lint": "ESLINT_USE_FLAT_CONFIG=false pnpm exec eslint --ignore-pattern node_modules \"**/*.ts\" \"package.json\"",
"test": "pnpm exec jest --config jest.config.js --passWithNoTests",
"test:ci": "pnpm exec jest --config jest.config.js --passWithNoTests --ci --coverage",
"pre-release": "pnpm run test && pnpm run build"
}
}