UNPKG

zephyr-xpack-internal

Version:

Xpack internals for Zephyr

78 lines (77 loc) • 2.06 kB
import "node:module"; import { ze_log } from "zephyr-agent"; import { extractFederatedConfig } from "./extract-federation-config.mjs"; function isLegacyMFPlugin(plugin) { const options = extractFederatedConfig(plugin); if (!options) { ze_log.mf('Not a Module Federation plugin'); return false; } if ('ModuleFederationPlugin' !== plugin.constructor.name) { ze_log.mf('Non-legacy Module Federation plugin identified. Current plugin name: ', plugin.constructor.name); return false; } if ('name' in plugin) { ze_log.mf('Non-legacy Module Federation plugin identified. Plugin has "name" property: ', plugin.name); return false; } const enhancedFeaturesChecks = [ [ plugin, 'getRemoteEntryUrls', 'function' ], [ plugin, 'getContainerEntryModule', 'function' ], [ plugin, 'invalidateRemote', 'function' ], [ plugin, 'statsResourceInfo' ], [ plugin, 'getStats', 'function' ], [ options, 'experiments' ], [ options, 'runtimePlugins' ], [ options, 'enhanced' ], [ plugin, '_experiments' ], [ plugin, '_enhanced' ] ]; for (const check of enhancedFeaturesChecks)if (hasProperty(...check)) { ze_log.mf('Non-legacy Module Federation plugin identified. Plugin contains property: ', check[1]); return false; } return true; } const hasProperty = (target, property, type)=>{ const hasProp = property in target; if (!(property in target)) return false; if (type) return typeof target[property] === type; return hasProp; }; export { isLegacyMFPlugin }; //# sourceMappingURL=is-legacy-mf-plugin.mjs.map