mirror of
https://github.com/Tria-plc/emaui.git
synced 2026-08-27 01:22:49 +00:00
297 lines
10 KiB
JavaScript
297 lines
10 KiB
JavaScript
"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__, {
|
|
findChunk: () => (/* binding */ findChunk),
|
|
getSharedModules: () => (/* binding */ getSharedModules),
|
|
getTypesMetaInfo: () => (/* binding */ getTypesMetaInfo),
|
|
isDev: () => (/* binding */ isDev),
|
|
getFileNameWithOutExt: () => (/* binding */ getFileNameWithOutExt),
|
|
getAssetsByChunk: () => (/* binding */ getAssetsByChunk),
|
|
error: () => (/* binding */ error),
|
|
getAssetsByChunkIDs: () => (/* binding */ getAssetsByChunkIDs),
|
|
assert: () => (/* binding */ assert)
|
|
});
|
|
|
|
;// 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 "@module-federation/dts-plugin/core"
|
|
const core_namespaceObject = require("@module-federation/dts-plugin/core");
|
|
;// CONCATENATED MODULE: external "./constants.js"
|
|
const external_constants_js_namespaceObject = require("./constants.js");
|
|
;// CONCATENATED MODULE: external "./logger.js"
|
|
const external_logger_js_namespaceObject = require("./logger.js");
|
|
var external_logger_js_default = /*#__PURE__*/__webpack_require__.n(external_logger_js_namespaceObject);
|
|
;// CONCATENATED MODULE: ./src/utils.ts
|
|
|
|
|
|
|
|
|
|
|
|
function isHotFile(file) {
|
|
return file.includes(external_constants_js_namespaceObject.HOT_UPDATE_SUFFIX);
|
|
}
|
|
const collectAssets = (assets, jsTargetSet, cssTargetSet)=>{
|
|
assets.forEach((file)=>{
|
|
if (file.endsWith('.css')) {
|
|
cssTargetSet.add(file);
|
|
} else {
|
|
if (isDev()) {
|
|
if (!isHotFile(file)) {
|
|
jsTargetSet.add(file);
|
|
}
|
|
} else {
|
|
jsTargetSet.add(file);
|
|
}
|
|
}
|
|
});
|
|
};
|
|
function getSharedModuleName(name) {
|
|
const [_type, _shared, _module, _shareScope, sharedInfo] = name.split(' ');
|
|
return sharedInfo.split('@').slice(0, -1).join('@');
|
|
}
|
|
function getAssetsByChunkIDs(compilation, chunkIDMap) {
|
|
const arrayChunks = Array.from(compilation.chunks);
|
|
const assetMap = {};
|
|
Object.keys(chunkIDMap).forEach((key)=>{
|
|
const chunkIDs = Array.from(chunkIDMap[key]);
|
|
if (!assetMap[key]) {
|
|
assetMap[key] = {
|
|
css: new Set(),
|
|
js: new Set()
|
|
};
|
|
}
|
|
chunkIDs.forEach((chunkID)=>{
|
|
const chunk = arrayChunks.find((item)=>item.id === chunkID);
|
|
if (chunk) {
|
|
collectAssets([
|
|
...chunk.files
|
|
], assetMap[key].js, assetMap[key].css);
|
|
}
|
|
});
|
|
});
|
|
const assets = {};
|
|
Object.keys(assetMap).map((key)=>{
|
|
assets[key] = {
|
|
js: Array.from(assetMap[key].js),
|
|
css: Array.from(assetMap[key].css)
|
|
};
|
|
});
|
|
return assets;
|
|
}
|
|
function findChunk(id, chunks) {
|
|
for (const chunk of chunks){
|
|
if (id === chunk.id) {
|
|
return chunk;
|
|
}
|
|
}
|
|
}
|
|
function getSharedModules(stats, sharedModules) {
|
|
var _stats_modules;
|
|
// 获取入口文件就是实际内容的 module
|
|
const entryContentModuleNames = [];
|
|
let effectiveSharedModules = ((_stats_modules = stats.modules) === null || _stats_modules === void 0 ? void 0 : _stats_modules.reduce((sum, module)=>{
|
|
for (const sharedModule of sharedModules){
|
|
if (sharedModule.name === module.issuerName) {
|
|
entryContentModuleNames.push(sharedModule.name);
|
|
sum.push([
|
|
getSharedModuleName(module.issuerName),
|
|
module
|
|
]);
|
|
return sum;
|
|
}
|
|
}
|
|
return sum;
|
|
}, [])) || [];
|
|
// 获取入口文件仅作为 Re Export 的 module
|
|
const entryReExportModules = sharedModules.filter((sharedModule)=>!entryContentModuleNames.includes(sharedModule.name));
|
|
if (entryReExportModules.length) {
|
|
effectiveSharedModules = effectiveSharedModules.concat(stats.modules.reduce((sum, module)=>{
|
|
let flag = false;
|
|
for (const entryReExportModule of entryReExportModules){
|
|
if (flag) {
|
|
break;
|
|
}
|
|
if (module.reasons) {
|
|
for (const issueModule of module.reasons){
|
|
if (issueModule.moduleName === entryReExportModule.name) {
|
|
sum.push([
|
|
getSharedModuleName(entryReExportModule.name),
|
|
module
|
|
]);
|
|
flag = true;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return sum;
|
|
}, []));
|
|
}
|
|
return effectiveSharedModules;
|
|
}
|
|
function getAssetsByChunk(chunk, entryPointNames) {
|
|
const assesSet = {
|
|
js: {
|
|
sync: new Set(),
|
|
async: new Set()
|
|
},
|
|
css: {
|
|
sync: new Set(),
|
|
async: new Set()
|
|
}
|
|
};
|
|
const collectChunkFiles = (targetChunk, type)=>{
|
|
[
|
|
...targetChunk.groupsIterable
|
|
].forEach((chunkGroup)=>{
|
|
if (chunkGroup.name && !entryPointNames.includes(chunkGroup.name)) {
|
|
collectAssets(chunkGroup.getFiles(), assesSet.js[type], assesSet.css[type]);
|
|
}
|
|
});
|
|
};
|
|
collectChunkFiles(chunk, 'sync');
|
|
[
|
|
...chunk.getAllAsyncChunks()
|
|
].forEach((asyncChunk)=>{
|
|
collectAssets([
|
|
...asyncChunk.files
|
|
], assesSet.js['async'], assesSet.css['async']);
|
|
collectChunkFiles(asyncChunk, 'async');
|
|
});
|
|
const assets = {
|
|
js: {
|
|
sync: Array.from(assesSet.js.sync),
|
|
async: Array.from(assesSet.js.async)
|
|
},
|
|
css: {
|
|
sync: Array.from(assesSet.css.sync),
|
|
async: Array.from(assesSet.css.async)
|
|
}
|
|
};
|
|
return assets;
|
|
}
|
|
function assert(condition, msg) {
|
|
if (!condition) {
|
|
error(msg);
|
|
}
|
|
}
|
|
function error(msg) {
|
|
throw new Error(`[ ${external_constants_js_namespaceObject.PLUGIN_IDENTIFIER} ]: ${msg}`);
|
|
}
|
|
function isDev() {
|
|
return process.env['NODE_ENV'] === 'development';
|
|
}
|
|
function getFileNameWithOutExt(str) {
|
|
return str.replace(external_path_default().extname(str), '');
|
|
}
|
|
function getTypesMetaInfo(pluginOptions, context) {
|
|
const defaultRemoteOptions = {
|
|
generateAPITypes: true,
|
|
compileInChildProcess: true
|
|
};
|
|
const defaultTypesMetaInfo = {
|
|
path: '',
|
|
name: '',
|
|
zip: '',
|
|
api: ''
|
|
};
|
|
try {
|
|
const normalizedDtsOptions = (0,sdk_namespaceObject.normalizeOptions)((0,core_namespaceObject.isTSProject)(pluginOptions.dts, context), {
|
|
generateTypes: defaultRemoteOptions,
|
|
consumeTypes: {}
|
|
}, 'mfOptions.dts')(pluginOptions.dts);
|
|
if (normalizedDtsOptions === false) {
|
|
return defaultTypesMetaInfo;
|
|
}
|
|
const normalizedRemote = (0,sdk_namespaceObject.normalizeOptions)(true, defaultRemoteOptions, 'mfOptions.dts.generateTypes')(normalizedDtsOptions.generateTypes);
|
|
if (normalizedRemote === false) {
|
|
return defaultTypesMetaInfo;
|
|
}
|
|
const { apiFileName, zipName } = (0,core_namespaceObject.retrieveTypesAssetsInfo)({
|
|
...normalizedRemote,
|
|
context,
|
|
moduleFederationConfig: pluginOptions
|
|
});
|
|
return {
|
|
path: '',
|
|
name: '',
|
|
zip: zipName,
|
|
api: apiFileName
|
|
};
|
|
} catch (err) {
|
|
external_logger_js_default().warn(`getTypesMetaInfo failed, it will use the default types meta info, and the errors as belows: ${err}`);
|
|
return defaultTypesMetaInfo;
|
|
}
|
|
}
|
|
|
|
exports.assert = __webpack_exports__.assert;
|
|
exports.error = __webpack_exports__.error;
|
|
exports.findChunk = __webpack_exports__.findChunk;
|
|
exports.getAssetsByChunk = __webpack_exports__.getAssetsByChunk;
|
|
exports.getAssetsByChunkIDs = __webpack_exports__.getAssetsByChunkIDs;
|
|
exports.getFileNameWithOutExt = __webpack_exports__.getFileNameWithOutExt;
|
|
exports.getSharedModules = __webpack_exports__.getSharedModules;
|
|
exports.getTypesMetaInfo = __webpack_exports__.getTypesMetaInfo;
|
|
exports.isDev = __webpack_exports__.isDev;
|
|
for(var __webpack_i__ in __webpack_exports__) {
|
|
if(["assert","error","findChunk","getAssetsByChunk","getAssetsByChunkIDs","getFileNameWithOutExt","getSharedModules","getTypesMetaInfo","isDev"].indexOf(__webpack_i__) === -1) {
|
|
exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
}
|
|
}
|
|
Object.defineProperty(exports, '__esModule', { value: true });
|