@module-federation/enhanced 2.6.0 → 2.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/CHANGELOG.md +44 -0
- package/dist/rstestmigrate.md +2 -2
- package/dist/src/lib/Constants.d.ts +29 -25
- package/dist/src/lib/container/ContainerEntryDependency.d.ts +2 -2
- package/dist/src/lib/container/ContainerEntryModule.d.ts +40 -21
- package/dist/src/lib/container/ContainerExposedDependency.d.ts +6 -8
- package/dist/src/lib/container/FallbackDependency.d.ts +2 -2
- package/dist/src/lib/container/FallbackItemDependency.d.ts +2 -2
- package/dist/src/lib/container/FallbackModule.d.ts +2 -2
- package/dist/src/lib/container/ModuleFederationPlugin.js +13 -2
- package/dist/src/lib/container/ModuleFederationPlugin.js.map +1 -1
- package/dist/src/lib/container/RemoteModule.d.ts +2 -2
- package/dist/src/lib/container/RemoteRuntimeModule.d.ts +2 -2
- package/dist/src/lib/container/RemoteToExternalDependency.d.ts +2 -2
- package/dist/src/lib/container/options.d.ts +12 -7
- package/dist/src/lib/container/runtime/EmbedFederationRuntimeModule.d.ts +2 -2
- package/dist/src/lib/container/runtime/FederationRuntimeModule.d.ts +2 -2
- package/dist/src/lib/container/runtime/FederationRuntimePlugin.js +3 -2
- package/dist/src/lib/container/runtime/FederationRuntimePlugin.js.map +1 -1
- package/dist/src/lib/container/runtime/getFederationGlobal.d.ts +2 -2
- package/dist/src/lib/container/runtime/normalizeToPosixPath.d.ts +5 -0
- package/dist/src/lib/container/runtime/normalizeToPosixPath.js +20 -0
- package/dist/src/lib/container/runtime/normalizeToPosixPath.js.map +1 -0
- package/dist/src/lib/container/runtime/utils.d.ts +23 -19
- package/dist/src/lib/container/runtime/utils.js +2 -6
- package/dist/src/lib/container/runtime/utils.js.map +1 -1
- package/dist/src/lib/sharing/ConsumeSharedFallbackDependency.d.ts +2 -2
- package/dist/src/lib/sharing/ConsumeSharedModule.d.ts +5 -5
- package/dist/src/lib/sharing/ConsumeSharedRuntimeModule.d.ts +2 -2
- package/dist/src/lib/sharing/ProvideForSharedDependency.d.ts +2 -2
- package/dist/src/lib/sharing/ProvideSharedDependency.d.ts +2 -2
- package/dist/src/lib/sharing/ProvideSharedModule.d.ts +2 -2
- package/dist/src/lib/sharing/ShareRuntimeModule.d.ts +2 -2
- package/dist/src/lib/sharing/tree-shaking/IndependentSharedRuntimeModule.d.ts +2 -2
- package/dist/src/lib/sharing/tree-shaking/SharedContainerPlugin/SharedDependency.d.ts +2 -2
- package/dist/src/lib/sharing/tree-shaking/SharedContainerPlugin/SharedEntryDependency.d.ts +2 -2
- package/dist/src/lib/sharing/tree-shaking/SharedContainerPlugin/SharedEntryModule.d.ts +2 -2
- package/dist/src/lib/sharing/tree-shaking/SharedUsedExportsOptimizerRuntimeModule.d.ts +2 -2
- package/dist/src/schemas/container/ModuleFederationPlugin.check.js +25 -13
- package/dist/src/schemas/container/ModuleFederationPlugin.check.js.map +1 -1
- package/dist/src/schemas/container/ModuleFederationPlugin.d.ts +9 -1
- package/dist/src/schemas/container/ModuleFederationPlugin.js +9 -5
- package/dist/src/schemas/container/ModuleFederationPlugin.js.map +1 -1
- package/dist/src/wrapper/FederationModulesPlugin.d.ts +4 -4
- package/package.json +17 -17
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FederationRuntimePlugin.js","names":["getFederationGlobalScope","normalizeToPosixPath","createHash","TEMP_DIR","FederationRuntimeDependency","FederationModulesPlugin","normalizeRuntimeInitOptionsWithOutShared","FederationRuntimeModule","EmbedFederationRuntimePlugin","HoistContainerReferences"],"sources":["../../../../../src/lib/container/runtime/FederationRuntimePlugin.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\nimport type {\n Compiler,\n WebpackPluginInstance,\n Compilation,\n Chunk,\n} from 'webpack';\nimport { normalizeWebpackPath } from '@module-federation/sdk/normalize-webpack-path';\nimport { moduleFederationPlugin } from '@module-federation/sdk';\nimport FederationRuntimeModule from './FederationRuntimeModule';\nimport {\n getFederationGlobalScope,\n normalizeRuntimeInitOptionsWithOutShared,\n createHash,\n normalizeToPosixPath,\n} from './utils';\nimport { TEMP_DIR } from '../constant';\nimport EmbedFederationRuntimePlugin from './EmbedFederationRuntimePlugin';\nimport FederationModulesPlugin from './FederationModulesPlugin';\nimport HoistContainerReferences from '../HoistContainerReferencesPlugin';\nimport FederationRuntimeDependency from './FederationRuntimeDependency';\n\nconst ModuleDependency = require(\n normalizeWebpackPath('webpack/lib/dependencies/ModuleDependency'),\n) as typeof import('webpack/lib/dependencies/ModuleDependency');\n\nconst { RuntimeGlobals, Template } = require(\n normalizeWebpackPath('webpack'),\n) as typeof import('webpack');\nconst { mkdirpSync } = require(\n normalizeWebpackPath('webpack/lib/util/fs'),\n) as typeof import('webpack/lib/util/fs');\n\ntype ResolveFn = typeof require.resolve;\ntype RuntimeEntrySpec = {\n bundler: string;\n esm: string;\n cjs: string;\n};\n\nfunction resolveRuntimeEntry(\n spec: RuntimeEntrySpec,\n implementation: string | undefined,\n resolve: ResolveFn = require.resolve,\n) {\n const candidates = [spec.bundler, spec.esm, spec.cjs];\n const modulePaths = implementation ? [implementation] : undefined;\n let lastError: unknown;\n\n for (const candidate of candidates) {\n try {\n return modulePaths\n ? resolve(candidate, { paths: modulePaths })\n : resolve(candidate);\n } catch (error) {\n lastError = error;\n }\n }\n\n throw lastError;\n}\n\nfunction resolveRuntimeEntryWithFallback(\n spec: RuntimeEntrySpec,\n implementation: string | undefined,\n resolve: ResolveFn = require.resolve,\n) {\n if (implementation) {\n try {\n return resolveRuntimeEntry(spec, implementation, resolve);\n } catch {\n // Fall back to the workspace runtime packages when a custom\n // implementation hasn't published the newer subpath yet.\n }\n }\n\n return resolveRuntimeEntry(spec, undefined, resolve);\n}\nexport function resolveRuntimePaths(\n implementation?: string,\n resolve: ResolveFn = require.resolve,\n) {\n // Prefer the dedicated bundler subpath so webpack can tree-shake across the\n // runtime package boundary. Fall back to the legacy dist contract for older\n // custom implementations that have not published /bundler yet.\n const runtimeToolsPath = resolveRuntimeEntryWithFallback(\n {\n bundler: '@module-federation/runtime-tools/bundler',\n esm: '@module-federation/runtime-tools/dist/index.js',\n cjs: '@module-federation/runtime-tools/dist/index.cjs',\n },\n implementation,\n resolve,\n );\n const moduleBase = implementation || runtimeToolsPath;\n\n return {\n runtimeToolsPath,\n bundlerRuntimePath: resolveRuntimeEntry(\n {\n bundler: '@module-federation/webpack-bundler-runtime/bundler',\n esm: '@module-federation/webpack-bundler-runtime/dist/index.js',\n cjs: '@module-federation/webpack-bundler-runtime/dist/index.cjs',\n },\n moduleBase,\n resolve,\n ),\n runtimePath: resolveRuntimeEntry(\n {\n bundler: '@module-federation/runtime/bundler',\n esm: '@module-federation/runtime/dist/index.js',\n cjs: '@module-federation/runtime/dist/index.cjs',\n },\n moduleBase,\n resolve,\n ),\n };\n}\n\nconst {\n runtimeToolsPath: RuntimeToolsPath,\n bundlerRuntimePath: BundlerRuntimePath,\n runtimePath: RuntimePath,\n} = resolveRuntimePaths();\nconst federationGlobal = getFederationGlobalScope(RuntimeGlobals);\n\nconst onceForCompiler = new WeakSet<Compiler>();\nconst onceForCompilerEntryMap = new WeakMap<Compiler, string>();\n\nclass FederationRuntimePlugin {\n options?: moduleFederationPlugin.ModuleFederationPluginOptions;\n entryFilePath: string;\n bundlerRuntimePath: string;\n runtimePath: string;\n runtimeToolsPath: string;\n federationRuntimeDependency?: FederationRuntimeDependency; // Add this line\n\n constructor(options?: moduleFederationPlugin.ModuleFederationPluginOptions) {\n this.options = options ? { ...options } : undefined;\n this.entryFilePath = '';\n this.bundlerRuntimePath = BundlerRuntimePath;\n this.runtimePath = RuntimePath;\n this.runtimeToolsPath = RuntimeToolsPath;\n this.federationRuntimeDependency = undefined; // Initialize as undefined\n }\n\n static getTemplate(\n compiler: Compiler,\n options: moduleFederationPlugin.ModuleFederationPluginOptions,\n bundlerRuntimePath?: string,\n ) {\n // internal runtime plugin\n const runtimePlugins = options.runtimePlugins;\n const normalizedBundlerRuntimePath = normalizeToPosixPath(\n bundlerRuntimePath || BundlerRuntimePath,\n );\n\n let runtimePluginTemplates = '';\n const runtimePluginCalls: string[] = [];\n\n if (Array.isArray(runtimePlugins)) {\n runtimePlugins.forEach((runtimePlugin, index) => {\n if (!runtimePlugin) {\n return;\n }\n const runtimePluginName = `plugin_${index}`;\n const runtimePluginEntry = Array.isArray(runtimePlugin)\n ? runtimePlugin[0]\n : runtimePlugin;\n const runtimePluginPath = normalizeToPosixPath(\n path.isAbsolute(runtimePluginEntry)\n ? runtimePluginEntry\n : path.join(process.cwd(), runtimePluginEntry),\n );\n const paramsStr =\n Array.isArray(runtimePlugin) && runtimePlugin.length > 1\n ? JSON.stringify(runtimePlugin[1])\n : 'undefined';\n runtimePluginTemplates += `import ${runtimePluginName} from '${runtimePluginPath}';\\n`;\n runtimePluginCalls.push(\n `${runtimePluginName} ? (${runtimePluginName}.default || ${runtimePluginName})(${paramsStr}) : false`,\n );\n });\n }\n const embedRuntimeLines = Template.asString([\n `if(!${federationGlobal}.runtime || !${federationGlobal}.bundlerRuntime){`,\n Template.indent([\n `var prevFederation = ${federationGlobal};`,\n `${federationGlobal} = {}`,\n `for(var key in federation){`,\n Template.indent([`${federationGlobal}[key] = federation[key];`]),\n '}',\n `for(var key in prevFederation){`,\n Template.indent([`${federationGlobal}[key] = prevFederation[key];`]),\n '}',\n ]),\n '}',\n ]);\n\n return Template.asString([\n `import federation from '${normalizedBundlerRuntimePath}';`,\n runtimePluginTemplates,\n embedRuntimeLines,\n `if(!${federationGlobal}.instance){`,\n Template.indent([\n runtimePluginCalls.length\n ? Template.asString([\n `var pluginsToAdd = [`,\n Template.indent(\n Template.indent(runtimePluginCalls.map((call) => `${call},`)),\n ),\n `].filter(Boolean);`,\n `${federationGlobal}.initOptions.plugins = ${federationGlobal}.initOptions.plugins ? `,\n `${federationGlobal}.initOptions.plugins.concat(pluginsToAdd) : pluginsToAdd;`,\n ])\n : '',\n // `${federationGlobal}.instance = ${federationGlobal}.runtime.init(${federationGlobal}.initOptions);`,\n `${federationGlobal}.instance = ${federationGlobal}.bundlerRuntime.init({webpackRequire:${RuntimeGlobals.require}});`,\n `if(${federationGlobal}.attachShareScopeMap){`,\n Template.indent([\n `${federationGlobal}.attachShareScopeMap(${RuntimeGlobals.require})`,\n ]),\n '}',\n `if(${federationGlobal}.installInitialConsumes){`,\n Template.indent([`${federationGlobal}.installInitialConsumes()`]),\n '}',\n ]),\n '}',\n ]);\n }\n\n getFilePath(compiler: Compiler) {\n if (!this.options) {\n return '';\n }\n\n const existedFilePath = onceForCompilerEntryMap.get(compiler);\n\n if (existedFilePath) {\n return existedFilePath;\n }\n\n let entryFilePath = '';\n if (!this.options?.virtualRuntimeEntry) {\n const containerName = this.options.name;\n const hash = createHash(\n `${containerName} ${FederationRuntimePlugin.getTemplate(\n compiler,\n this.options,\n this.bundlerRuntimePath,\n )}`,\n );\n entryFilePath = path.join(TEMP_DIR, `entry.${hash}.js`);\n } else {\n entryFilePath = `data:text/javascript;charset=utf-8;base64,${Buffer.from(\n FederationRuntimePlugin.getTemplate(\n compiler,\n this.options,\n this.bundlerRuntimePath,\n ),\n 'utf8',\n ).toString('base64')}`;\n }\n\n onceForCompilerEntryMap.set(compiler, entryFilePath);\n\n return entryFilePath;\n }\n\n ensureFile(compiler: Compiler) {\n if (!this.options) {\n return;\n }\n // skip virtual entry\n if (this.options?.virtualRuntimeEntry) {\n return;\n }\n const filePath = this.entryFilePath;\n const outputFs = (compiler as unknown as { outputFileSystem?: unknown })\n .outputFileSystem;\n const fsLike =\n outputFs &&\n typeof (outputFs as typeof fs).readFileSync === 'function' &&\n typeof (outputFs as typeof fs).writeFileSync === 'function'\n ? (outputFs as typeof fs)\n : fs;\n try {\n fsLike.readFileSync(filePath);\n } catch {\n mkdirpSync(fsLike as any, TEMP_DIR);\n fsLike.writeFileSync(\n filePath,\n FederationRuntimePlugin.getTemplate(\n compiler,\n this.options,\n this.bundlerRuntimePath,\n ),\n );\n }\n }\n\n getDependency(compiler: Compiler) {\n if (this.federationRuntimeDependency)\n return this.federationRuntimeDependency;\n\n this.ensureFile(compiler);\n\n this.federationRuntimeDependency = new FederationRuntimeDependency(\n this.entryFilePath,\n );\n return this.federationRuntimeDependency;\n }\n\n prependEntry(compiler: Compiler) {\n if (!this.options?.virtualRuntimeEntry) {\n this.ensureFile(compiler);\n }\n\n compiler.hooks.thisCompilation.tap(\n this.constructor.name,\n (compilation: Compilation, { normalModuleFactory }) => {\n compilation.dependencyFactories.set(\n FederationRuntimeDependency,\n normalModuleFactory,\n );\n compilation.dependencyTemplates.set(\n FederationRuntimeDependency,\n new ModuleDependency.Template(),\n );\n },\n );\n compiler.hooks.make.tapAsync(\n this.constructor.name,\n (compilation: Compilation, callback) => {\n const federationRuntimeDependency = this.getDependency(compiler);\n const hooks = FederationModulesPlugin.getCompilationHooks(compilation);\n compilation.addInclude(\n compiler.context,\n federationRuntimeDependency,\n { name: undefined },\n (err) => {\n if (err) {\n return callback(err);\n }\n hooks.addFederationRuntimeDependency.call(\n federationRuntimeDependency,\n );\n callback();\n },\n );\n },\n );\n }\n\n injectRuntime(compiler: Compiler) {\n if (!this.options || !this.options.name) {\n return;\n }\n const name = this.options.name;\n const initOptionsWithoutShared = normalizeRuntimeInitOptionsWithOutShared(\n this.options,\n );\n const federationGlobal = getFederationGlobalScope(\n RuntimeGlobals || ({} as typeof RuntimeGlobals),\n );\n\n compiler.hooks.thisCompilation.tap(\n this.constructor.name,\n (compilation: Compilation) => {\n const handler = (chunk: Chunk, runtimeRequirements: Set<string>) => {\n if (runtimeRequirements.has(federationGlobal)) return;\n runtimeRequirements.add(federationGlobal);\n runtimeRequirements.add(RuntimeGlobals.interceptModuleExecution);\n runtimeRequirements.add(RuntimeGlobals.moduleCache);\n runtimeRequirements.add(RuntimeGlobals.compatGetDefaultExport);\n\n compilation.addRuntimeModule(\n chunk,\n new FederationRuntimeModule(\n runtimeRequirements,\n name,\n initOptionsWithoutShared,\n ),\n );\n };\n\n compilation.hooks.additionalTreeRuntimeRequirements.tap(\n this.constructor.name,\n (chunk: Chunk, runtimeRequirements: Set<string>) => {\n if (!chunk.hasRuntime()) return;\n if (runtimeRequirements.has(RuntimeGlobals.initializeSharing))\n return;\n if (runtimeRequirements.has(RuntimeGlobals.currentRemoteGetScope))\n return;\n if (runtimeRequirements.has(RuntimeGlobals.shareScopeMap)) return;\n if (runtimeRequirements.has(federationGlobal)) return;\n handler(chunk, runtimeRequirements);\n },\n );\n\n // if federation runtime requirements exist\n // attach runtime module to the chunk\n compilation.hooks.runtimeRequirementInTree\n .for(RuntimeGlobals.initializeSharing)\n .tap(this.constructor.name, handler);\n compilation.hooks.runtimeRequirementInTree\n .for(RuntimeGlobals.currentRemoteGetScope)\n .tap(this.constructor.name, handler);\n compilation.hooks.runtimeRequirementInTree\n .for(RuntimeGlobals.shareScopeMap)\n .tap(this.constructor.name, handler);\n compilation.hooks.runtimeRequirementInTree\n .for(federationGlobal)\n .tap(this.constructor.name, handler);\n },\n );\n }\n\n getRuntimeAlias(compiler: Compiler) {\n const { implementation } = this.options || {};\n const alias: any = compiler.options.resolve.alias || {};\n\n const resolvedPaths = resolveRuntimePaths(implementation);\n\n this.runtimeToolsPath = resolvedPaths.runtimeToolsPath;\n this.bundlerRuntimePath = resolvedPaths.bundlerRuntimePath;\n\n if (alias['@module-federation/runtime$']) {\n this.runtimePath = alias['@module-federation/runtime$'];\n return this.runtimePath;\n }\n\n this.runtimePath = resolvedPaths.runtimePath;\n\n return this.runtimePath;\n }\n\n setRuntimeAlias(compiler: Compiler) {\n const { implementation } = this.options || {};\n const alias: any = compiler.options.resolve.alias || {};\n const runtimePath = this.getRuntimeAlias(compiler);\n alias['@module-federation/runtime$'] =\n alias['@module-federation/runtime$'] || runtimePath;\n alias['@module-federation/runtime-tools$'] =\n alias['@module-federation/runtime-tools$'] ||\n implementation ||\n this.runtimeToolsPath;\n\n // Set up aliases for the federation runtime and tools\n // This ensures that the correct versions are used throughout the project\n compiler.options.resolve.alias = alias;\n }\n\n apply(compiler: Compiler) {\n const useSharedContainerPlugin = compiler.options.plugins.find(\n (p): p is WebpackPluginInstance & { _options?: any } => {\n if (typeof p !== 'object' || !p) {\n return false;\n }\n return p['name'] === 'SharedContainerPlugin';\n },\n );\n // share container plugin should not inject mf runtime\n if (useSharedContainerPlugin) {\n return;\n }\n const useModuleFederationPlugin = compiler.options.plugins.find(\n (p): p is WebpackPluginInstance & { _options?: any } => {\n if (typeof p !== 'object' || !p) {\n return false;\n }\n return p['name'] === 'ModuleFederationPlugin';\n },\n );\n\n if (useModuleFederationPlugin && !this.options) {\n this.options = useModuleFederationPlugin._options;\n }\n\n const useContainerPlugin = compiler.options.plugins.find(\n (p): p is WebpackPluginInstance & { _options?: any } => {\n if (typeof p !== 'object' || !p) {\n return false;\n }\n\n return p['name'] === 'ContainerPlugin';\n },\n );\n\n if (useContainerPlugin && !this.options) {\n this.options = useContainerPlugin._options;\n }\n\n if (!useContainerPlugin && !useModuleFederationPlugin) {\n this.options = {\n remotes: {},\n ...this.options,\n };\n }\n if (this.options && !this.options?.name) {\n //! the instance may get the same one if the name is the same https://github.com/module-federation/core/blob/main/packages/runtime/src/index.ts#L18\n this.options.name =\n compiler.options.output.uniqueName || `container_${Date.now()}`;\n }\n\n const resolvedPaths = resolveRuntimePaths(this.options?.implementation);\n this.bundlerRuntimePath = resolvedPaths.bundlerRuntimePath;\n this.runtimePath = resolvedPaths.runtimePath;\n this.runtimeToolsPath = resolvedPaths.runtimeToolsPath;\n\n this.entryFilePath = this.getFilePath(compiler);\n\n new EmbedFederationRuntimePlugin().apply(compiler);\n\n new HoistContainerReferences().apply(compiler);\n\n // dont run multiple times on every apply()\n if (!onceForCompiler.has(compiler)) {\n this.prependEntry(compiler);\n this.injectRuntime(compiler);\n this.setRuntimeAlias(compiler);\n onceForCompiler.add(compiler);\n }\n }\n}\n\nexport default FederationRuntimePlugin;\n"],"mappings":";;;;;;;;;;;;;;;;AAuBA,MAAM,mBAAmB,gF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uD;AACtD,OAAI,OAAO,MAAM,YAAY,CAAC,EAC5B,QAAO;AAET,UAAO,EAAE,YAAY;IAExB,CAGC;EAEF,MAAM,4BAA4B,SAAS,QAAQ,QAAQ,MACxD,MAAuD;AACtD,OAAI,OAAO,MAAM,YAAY,CAAC,EAC5B,QAAO;AAET,UAAO,EAAE,YAAY;IAExB;AAED,MAAI,6BAA6B,CAAC,KAAK,QACrC,MAAK,UAAU,0BAA0B;EAG3C,MAAM,qBAAqB,SAAS,QAAQ,QAAQ,MACjD,MAAuD;AACtD,OAAI,OAAO,MAAM,YAAY,CAAC,EAC5B,QAAO;AAGT,UAAO,EAAE,YAAY;IAExB;AAED,MAAI,sBAAsB,CAAC,KAAK,QAC9B,MAAK,UAAU,mBAAmB;AAGpC,MAAI,CAAC,sBAAsB,CAAC,0BAC1B,MAAK,UAAU;GACb,SAAS,EAAE;GACX,GAAG,KAAK;GACT;AAEH,MAAI,KAAK,WAAW,CAAC,KAAK,SAAS;;AAEjC,OAAK,QAAQ,OACX,SAAS,QAAQ,OAAO,cAAc,aAAa,KAAK,KAAK;EAGjE,MAAM,gBAAgB,oBAAoB,KAAK,SAAS,eAAe;AACvE,OAAK,qBAAqB,cAAc;AACxC,OAAK,cAAc,cAAc;AACjC,OAAK,mBAAmB,cAAc;AAEtC,OAAK,gBAAgB,KAAK,YAAY,SAAS;AAE/C,MAAIC,oEAA8B,CAAC,MAAM,SAAS;AAElD,MAAIC,8DAA0B,CAAC,MAAM,SAAS;AAG9C,MAAI,CAAC,gBAAgB,IAAI,SAAS,EAAE;AAClC,QAAK,aAAa,SAAS;AAC3B,QAAK,cAAc,SAAS;AAC5B,QAAK,gBAAgB,SAAS;AAC9B,mBAAgB,IAAI,SAAS"}
|
|
1
|
+
{"version":3,"file":"FederationRuntimePlugin.js","names":["getFederationGlobalScope","normalizeToPosixPath","createHash","TEMP_DIR","FederationRuntimeDependency","FederationModulesPlugin","normalizeRuntimeInitOptionsWithOutShared","FederationRuntimeModule","EmbedFederationRuntimePlugin","HoistContainerReferences"],"sources":["../../../../../src/lib/container/runtime/FederationRuntimePlugin.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\nimport type {\n Compiler,\n WebpackPluginInstance,\n Compilation,\n Chunk,\n} from 'webpack';\nimport { normalizeWebpackPath } from '@module-federation/sdk/normalize-webpack-path';\nimport { moduleFederationPlugin } from '@module-federation/sdk';\nimport FederationRuntimeModule from './FederationRuntimeModule';\nimport {\n getFederationGlobalScope,\n normalizeRuntimeInitOptionsWithOutShared,\n createHash,\n normalizeToPosixPath,\n} from './utils';\nimport { TEMP_DIR } from '../constant';\nimport EmbedFederationRuntimePlugin from './EmbedFederationRuntimePlugin';\nimport FederationModulesPlugin from './FederationModulesPlugin';\nimport HoistContainerReferences from '../HoistContainerReferencesPlugin';\nimport FederationRuntimeDependency from './FederationRuntimeDependency';\n\nconst ModuleDependency = require(\n normalizeWebpackPath('webpack/lib/dependencies/ModuleDependency'),\n) as typeof import('webpack/lib/dependencies/ModuleDependency');\n\nconst { RuntimeGlobals, Template } = require(\n normalizeWebpackPath('webpack'),\n) as typeof import('webpack');\nconst { mkdirpSync } = require(\n normalizeWebpackPath('webpack/lib/util/fs'),\n) as typeof import('webpack/lib/util/fs');\n\ntype ResolveFn = typeof require.resolve;\ntype RuntimeEntrySpec = {\n bundler: string;\n esm: string;\n cjs: string;\n};\n\nfunction resolveRuntimeEntry(\n spec: RuntimeEntrySpec,\n implementation: string | undefined,\n resolve: ResolveFn = require.resolve,\n) {\n const candidates = [spec.bundler, spec.esm, spec.cjs];\n const modulePaths = implementation ? [implementation] : undefined;\n let lastError: unknown;\n\n for (const candidate of candidates) {\n try {\n return modulePaths\n ? resolve(candidate, { paths: modulePaths })\n : resolve(candidate);\n } catch (error) {\n lastError = error;\n }\n }\n\n throw lastError;\n}\n\nfunction resolveRuntimeEntryWithFallback(\n spec: RuntimeEntrySpec,\n implementation: string | undefined,\n resolve: ResolveFn = require.resolve,\n) {\n if (implementation) {\n try {\n return resolveRuntimeEntry(spec, implementation, resolve);\n } catch {\n // Fall back to the workspace runtime packages when a custom\n // implementation hasn't published the newer subpath yet.\n }\n }\n\n return resolveRuntimeEntry(spec, undefined, resolve);\n}\nexport function resolveRuntimePaths(\n implementation?: string,\n resolve: ResolveFn = require.resolve,\n) {\n // Prefer the dedicated bundler subpath so webpack can tree-shake across the\n // runtime package boundary. Fall back to the legacy dist contract for older\n // custom implementations that have not published /bundler yet.\n const runtimeToolsPath = resolveRuntimeEntryWithFallback(\n {\n bundler: '@module-federation/runtime-tools/bundler',\n esm: '@module-federation/runtime-tools/dist/index.js',\n cjs: '@module-federation/runtime-tools/dist/index.cjs',\n },\n implementation,\n resolve,\n );\n const moduleBase = implementation || runtimeToolsPath;\n\n return {\n runtimeToolsPath,\n bundlerRuntimePath: resolveRuntimeEntry(\n {\n bundler: '@module-federation/webpack-bundler-runtime/bundler',\n esm: '@module-federation/webpack-bundler-runtime/dist/index.js',\n cjs: '@module-federation/webpack-bundler-runtime/dist/index.cjs',\n },\n moduleBase,\n resolve,\n ),\n runtimePath: resolveRuntimeEntry(\n {\n bundler: '@module-federation/runtime/bundler',\n esm: '@module-federation/runtime/dist/index.js',\n cjs: '@module-federation/runtime/dist/index.cjs',\n },\n moduleBase,\n resolve,\n ),\n };\n}\n\nconst {\n runtimeToolsPath: RuntimeToolsPath,\n bundlerRuntimePath: BundlerRuntimePath,\n runtimePath: RuntimePath,\n} = resolveRuntimePaths();\nconst federationGlobal = getFederationGlobalScope(RuntimeGlobals);\n\nconst onceForCompiler = new WeakSet<Compiler>();\nconst onceForCompilerEntryMap = new WeakMap<Compiler, string>();\n\nclass FederationRuntimePlugin {\n options?: moduleFederationPlugin.ModuleFederationPluginOptions;\n entryFilePath: string;\n bundlerRuntimePath: string;\n runtimePath: string;\n runtimeToolsPath: string;\n federationRuntimeDependency?: FederationRuntimeDependency; // Add this line\n\n constructor(options?: moduleFederationPlugin.ModuleFederationPluginOptions) {\n this.options = options ? { ...options } : undefined;\n this.entryFilePath = '';\n this.bundlerRuntimePath = BundlerRuntimePath;\n this.runtimePath = RuntimePath;\n this.runtimeToolsPath = RuntimeToolsPath;\n this.federationRuntimeDependency = undefined; // Initialize as undefined\n }\n\n static getTemplate(\n compiler: Compiler,\n options: moduleFederationPlugin.ModuleFederationPluginOptions,\n bundlerRuntimePath?: string,\n ) {\n // internal runtime plugin\n const runtimePlugins = options.runtimePlugins;\n const normalizedBundlerRuntimePath = normalizeToPosixPath(\n bundlerRuntimePath || BundlerRuntimePath,\n );\n\n let runtimePluginTemplates = '';\n const runtimePluginCalls: string[] = [];\n\n if (Array.isArray(runtimePlugins)) {\n runtimePlugins.forEach((runtimePlugin, index) => {\n if (!runtimePlugin) {\n return;\n }\n const runtimePluginName = `plugin_${index}`;\n const runtimePluginEntry = Array.isArray(runtimePlugin)\n ? runtimePlugin[0]\n : runtimePlugin;\n const runtimePluginPath = normalizeToPosixPath(\n path.isAbsolute(runtimePluginEntry)\n ? runtimePluginEntry\n : path.join(process.cwd(), runtimePluginEntry),\n );\n const paramsStr =\n Array.isArray(runtimePlugin) && runtimePlugin.length > 1\n ? JSON.stringify(runtimePlugin[1])\n : 'undefined';\n runtimePluginTemplates += `import ${runtimePluginName} from '${runtimePluginPath}';\\n`;\n runtimePluginCalls.push(\n `${runtimePluginName} ? (${runtimePluginName}.default || ${runtimePluginName})(${paramsStr}) : false`,\n );\n });\n }\n const embedRuntimeLines = Template.asString([\n `if(!${federationGlobal}.runtime || !${federationGlobal}.bundlerRuntime){`,\n Template.indent([\n `var prevFederation = ${federationGlobal};`,\n `${federationGlobal} = {}`,\n `for(var key in federation){`,\n Template.indent([`${federationGlobal}[key] = federation[key];`]),\n '}',\n `for(var key in prevFederation){`,\n Template.indent([`${federationGlobal}[key] = prevFederation[key];`]),\n '}',\n ]),\n '}',\n ]);\n\n return Template.asString([\n `import federation from '${normalizedBundlerRuntimePath}';`,\n runtimePluginTemplates,\n embedRuntimeLines,\n `if(!${federationGlobal}.instance){`,\n Template.indent([\n runtimePluginCalls.length\n ? Template.asString([\n `var pluginsToAdd = [`,\n Template.indent(\n Template.indent(runtimePluginCalls.map((call) => `${call},`)),\n ),\n `].filter(Boolean);`,\n `${federationGlobal}.initOptions.plugins = ${federationGlobal}.initOptions.plugins ? `,\n `${federationGlobal}.initOptions.plugins.concat(pluginsToAdd) : pluginsToAdd;`,\n ])\n : '',\n // `${federationGlobal}.instance = ${federationGlobal}.runtime.init(${federationGlobal}.initOptions);`,\n `${federationGlobal}.instance = ${federationGlobal}.bundlerRuntime.init({webpackRequire:${RuntimeGlobals.require}});`,\n `if(${federationGlobal}.attachShareScopeMap){`,\n Template.indent([\n `${federationGlobal}.attachShareScopeMap(${RuntimeGlobals.require})`,\n ]),\n '}',\n `if(${federationGlobal}.installInitialConsumes){`,\n Template.indent([`${federationGlobal}.installInitialConsumes()`]),\n '}',\n ]),\n '}',\n ]);\n }\n\n getFilePath(compiler: Compiler) {\n if (!this.options) {\n return '';\n }\n\n const existedFilePath = onceForCompilerEntryMap.get(compiler);\n\n if (existedFilePath) {\n return existedFilePath;\n }\n\n let entryFilePath = '';\n if (!this.options?.virtualRuntimeEntry) {\n const containerName = this.options.name;\n const hash = createHash(\n `${containerName} ${FederationRuntimePlugin.getTemplate(\n compiler,\n this.options,\n this.bundlerRuntimePath,\n )}`,\n );\n entryFilePath = path.join(TEMP_DIR, `entry.${hash}.js`);\n } else {\n entryFilePath = `data:text/javascript;charset=utf-8;base64,${Buffer.from(\n FederationRuntimePlugin.getTemplate(\n compiler,\n this.options,\n this.bundlerRuntimePath,\n ),\n 'utf8',\n ).toString('base64')}`;\n }\n\n onceForCompilerEntryMap.set(compiler, entryFilePath);\n\n return entryFilePath;\n }\n\n ensureFile(compiler: Compiler) {\n if (!this.options) {\n return;\n }\n // skip virtual entry\n if (this.options?.virtualRuntimeEntry) {\n return;\n }\n const filePath = this.entryFilePath;\n const outputFs = (compiler as unknown as { outputFileSystem?: unknown })\n .outputFileSystem;\n const fsLike =\n outputFs &&\n typeof (outputFs as typeof fs).readFileSync === 'function' &&\n typeof (outputFs as typeof fs).writeFileSync === 'function'\n ? (outputFs as typeof fs)\n : fs;\n try {\n fsLike.readFileSync(filePath);\n } catch {\n mkdirpSync(fsLike as any, TEMP_DIR);\n fsLike.writeFileSync(\n filePath,\n FederationRuntimePlugin.getTemplate(\n compiler,\n this.options,\n this.bundlerRuntimePath,\n ),\n );\n }\n }\n\n getDependency(compiler: Compiler) {\n if (this.federationRuntimeDependency)\n return this.federationRuntimeDependency;\n\n this.ensureFile(compiler);\n\n this.federationRuntimeDependency = new FederationRuntimeDependency(\n this.entryFilePath,\n );\n return this.federationRuntimeDependency;\n }\n\n prependEntry(compiler: Compiler) {\n if (!this.options?.virtualRuntimeEntry) {\n this.ensureFile(compiler);\n }\n\n compiler.hooks.thisCompilation.tap(\n this.constructor.name,\n (compilation: Compilation, { normalModuleFactory }) => {\n compilation.dependencyFactories.set(\n FederationRuntimeDependency,\n normalModuleFactory,\n );\n compilation.dependencyTemplates.set(\n FederationRuntimeDependency,\n new ModuleDependency.Template(),\n );\n },\n );\n compiler.hooks.make.tapAsync(\n this.constructor.name,\n (compilation: Compilation, callback) => {\n const federationRuntimeDependency = this.getDependency(compiler);\n const hooks = FederationModulesPlugin.getCompilationHooks(compilation);\n compilation.addInclude(\n compiler.context,\n federationRuntimeDependency,\n { name: undefined },\n (err) => {\n if (err) {\n return callback(err);\n }\n hooks.addFederationRuntimeDependency.call(\n federationRuntimeDependency,\n );\n callback();\n },\n );\n },\n );\n }\n\n injectRuntime(compiler: Compiler) {\n if (!this.options || !this.options.name) {\n return;\n }\n const name = this.options.name;\n const initOptionsWithoutShared = normalizeRuntimeInitOptionsWithOutShared(\n this.options,\n );\n const federationGlobal = getFederationGlobalScope(\n RuntimeGlobals || ({} as typeof RuntimeGlobals),\n );\n\n compiler.hooks.thisCompilation.tap(\n this.constructor.name,\n (compilation: Compilation) => {\n const handler = (chunk: Chunk, runtimeRequirements: Set<string>) => {\n if (runtimeRequirements.has(federationGlobal)) return;\n runtimeRequirements.add(federationGlobal);\n runtimeRequirements.add(RuntimeGlobals.interceptModuleExecution);\n runtimeRequirements.add(RuntimeGlobals.moduleCache);\n runtimeRequirements.add(RuntimeGlobals.compatGetDefaultExport);\n\n compilation.addRuntimeModule(\n chunk,\n new FederationRuntimeModule(\n runtimeRequirements,\n name,\n initOptionsWithoutShared,\n ),\n );\n };\n\n compilation.hooks.additionalTreeRuntimeRequirements.tap(\n this.constructor.name,\n (chunk: Chunk, runtimeRequirements: Set<string>) => {\n if (!chunk.hasRuntime()) return;\n if (runtimeRequirements.has(RuntimeGlobals.initializeSharing))\n return;\n if (runtimeRequirements.has(RuntimeGlobals.currentRemoteGetScope))\n return;\n if (runtimeRequirements.has(RuntimeGlobals.shareScopeMap)) return;\n if (runtimeRequirements.has(federationGlobal)) return;\n handler(chunk, runtimeRequirements);\n },\n );\n\n // if federation runtime requirements exist\n // attach runtime module to the chunk\n compilation.hooks.runtimeRequirementInTree\n .for(RuntimeGlobals.initializeSharing)\n .tap(this.constructor.name, handler);\n compilation.hooks.runtimeRequirementInTree\n .for(RuntimeGlobals.currentRemoteGetScope)\n .tap(this.constructor.name, handler);\n compilation.hooks.runtimeRequirementInTree\n .for(RuntimeGlobals.shareScopeMap)\n .tap(this.constructor.name, handler);\n compilation.hooks.runtimeRequirementInTree\n .for(federationGlobal)\n .tap(this.constructor.name, handler);\n },\n );\n }\n\n getRuntimeAlias(compiler: Compiler) {\n const { implementation } = this.options || {};\n const alias: any = compiler.options.resolve.alias || {};\n\n const resolvedPaths = resolveRuntimePaths(implementation);\n\n this.runtimeToolsPath = resolvedPaths.runtimeToolsPath;\n this.bundlerRuntimePath = resolvedPaths.bundlerRuntimePath;\n\n if (alias['@module-federation/runtime$']) {\n this.runtimePath = alias['@module-federation/runtime$'];\n return this.runtimePath;\n }\n\n this.runtimePath = resolvedPaths.runtimePath;\n\n return this.runtimePath;\n }\n\n setRuntimeAlias(compiler: Compiler) {\n const { implementation } = this.options || {};\n const alias: any = compiler.options.resolve.alias || {};\n const runtimePath = this.getRuntimeAlias(compiler);\n alias['@module-federation/runtime$'] =\n alias['@module-federation/runtime$'] || runtimePath;\n alias['@module-federation/runtime-tools$'] =\n alias['@module-federation/runtime-tools$'] ||\n implementation ||\n this.runtimeToolsPath;\n\n // Set up aliases for the federation runtime and tools\n // This ensures that the correct versions are used throughout the project\n compiler.options.resolve.alias = alias;\n }\n\n apply(compiler: Compiler) {\n const useSharedContainerPlugin = compiler.options.plugins.find(\n (p): p is WebpackPluginInstance & { _options?: any } => {\n if (typeof p !== 'object' || !p) {\n return false;\n }\n return p['name'] === 'SharedContainerPlugin';\n },\n );\n // share container plugin should not inject mf runtime\n if (useSharedContainerPlugin) {\n return;\n }\n const useModuleFederationPlugin = compiler.options.plugins.find(\n (p): p is WebpackPluginInstance & { _options?: any } => {\n if (typeof p !== 'object' || !p) {\n return false;\n }\n return p['name'] === 'ModuleFederationPlugin';\n },\n );\n\n if (useModuleFederationPlugin && !this.options) {\n this.options = useModuleFederationPlugin._options;\n }\n\n const useContainerPlugin = compiler.options.plugins.find(\n (p): p is WebpackPluginInstance & { _options?: any } => {\n if (typeof p !== 'object' || !p) {\n return false;\n }\n\n return p['name'] === 'ContainerPlugin';\n },\n );\n\n if (useContainerPlugin && !this.options) {\n this.options = useContainerPlugin._options;\n }\n\n if (!useContainerPlugin && !useModuleFederationPlugin) {\n this.options = {\n remotes: {},\n ...this.options,\n };\n }\n if (this.options && !this.options?.name) {\n //! the instance may get the same one if the name is the same https://github.com/module-federation/core/blob/main/packages/runtime/src/index.ts#L18\n this.options.name =\n compiler.options.output.uniqueName || `container_${Date.now()}`;\n }\n\n const resolvedPaths = resolveRuntimePaths(this.options?.implementation);\n this.bundlerRuntimePath = resolvedPaths.bundlerRuntimePath;\n this.runtimePath = resolvedPaths.runtimePath;\n this.runtimeToolsPath = resolvedPaths.runtimeToolsPath;\n\n this.entryFilePath = this.getFilePath(compiler);\n\n new EmbedFederationRuntimePlugin().apply(compiler);\n\n new HoistContainerReferences().apply(compiler);\n\n // dont run multiple times on every apply()\n if (!onceForCompiler.has(compiler)) {\n this.prependEntry(compiler);\n this.injectRuntime(compiler);\n this.setRuntimeAlias(compiler);\n onceForCompiler.add(compiler);\n }\n }\n}\n\nexport default FederationRuntimePlugin;\n"],"mappings":";;;;;;;;;;;;;;;;;AAuBA,MAAM,mBAAmB,gFACF,4CAA4C,CAClE;AAED,MAAM,EAAE,gBAAgB,aAAa,gFACd,UAAU,CAChC;AACD,MAAM,EAAE,eAAe,gFACA,sBAAsB,CAC5C;AASD,SAAS,oBACP,MACA,gBACA,UAAqB,QAAQ,SAC7B;CACA,MAAM,aAAa;EAAC,KAAK;EAAS,KAAK;EAAK,KAAK;EAAI;CACrD,MAAM,cAAc,iBAAiB,CAAC,eAAe,GAAG;CACxD,IAAI;AAEJ,MAAK,MAAM,aAAa,WACtB,KAAI;AACF,SAAO,cACH,QAAQ,WAAW,EAAE,OAAO,aAAa,CAAC,GAC1C,QAAQ,UAAU;UACf,OAAO;AACd,cAAY;;AAIhB,OAAM;;AAGR,SAAS,gCACP,MACA,gBACA,UAAqB,QAAQ,SAC7B;AACA,KAAI,eACF,KAAI;AACF,SAAO,oBAAoB,MAAM,gBAAgB,QAAQ;SACnD;AAMV,QAAO,oBAAoB,MAAM,QAAW,QAAQ;;AAEtD,SAAgB,oBACd,gBACA,UAAqB,QAAQ,SAC7B;CAIA,MAAM,mBAAmB,gCACvB;EACE,SAAS;EACT,KAAK;EACL,KAAK;EACN,EACD,gBACA,QACD;CACD,MAAM,aAAa,kBAAkB;AAErC,QAAO;EACL;EACA,oBAAoB,oBAClB;GACE,SAAS;GACT,KAAK;GACL,KAAK;GACN,EACD,YACA,QACD;EACD,aAAa,oBACX;GACE,SAAS;GACT,KAAK;GACL,KAAK;GACN,EACD,YACA,QACD;EACF;;AAGH,MAAM,EACJ,kBAAkB,kBAClB,oBAAoB,oBACpB,aAAa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AAS,EAAE;AAClC,QAAK,aAAa,SAAS;AAC3B,QAAK,cAAc,SAAS;AAC5B,QAAK,gBAAgB,SAAS;AAC9B,mBAAgB,IAAI,SAAS"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { NormalizedRuntimeInitOptionsWithOutShared } from "./utils.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as node_modules_webpack_types0 from "node_modules/webpack/types";
|
|
3
3
|
import RuntimeGlobals from "webpack/lib/RuntimeGlobals";
|
|
4
4
|
|
|
5
5
|
//#region src/lib/container/runtime/getFederationGlobal.d.ts
|
|
6
|
-
declare const Template: typeof
|
|
6
|
+
declare const Template: typeof node_modules_webpack_types0.Template;
|
|
7
7
|
declare function getFederationGlobal(template: typeof Template, runtimeGlobals: typeof RuntimeGlobals, matcher: string | boolean, rootOutputDir: string | undefined, initOptionsWithoutShared: NormalizedRuntimeInitOptionsWithOutShared): string;
|
|
8
8
|
//#endregion
|
|
9
9
|
export { getFederationGlobal as default };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_runtime = require('../../../_virtual/_rolldown/runtime.js');
|
|
3
|
+
let path = require("path");
|
|
4
|
+
path = require_runtime.__toESM(path);
|
|
5
|
+
|
|
6
|
+
//#region src/lib/container/runtime/normalizeToPosixPath.ts
|
|
7
|
+
function toPosixSeparators(value) {
|
|
8
|
+
return value.replace(/\\/g, "/").replace(/(?<!^)\/+/g, "/");
|
|
9
|
+
}
|
|
10
|
+
function normalizeToPosixPath(value) {
|
|
11
|
+
const input = toPosixSeparators(path.default.normalize(value || ""));
|
|
12
|
+
let result = toPosixSeparators(path.default.normalize(input));
|
|
13
|
+
if (input.startsWith("./") && !result.startsWith("./") && !result.startsWith("..")) result = `./${result}`;
|
|
14
|
+
else if (input.startsWith("//") && !result.startsWith("//")) result = input.startsWith("//./") ? `//.${result}` : `/${result}`;
|
|
15
|
+
return result;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
//#endregion
|
|
19
|
+
exports.normalizeToPosixPath = normalizeToPosixPath;
|
|
20
|
+
//# sourceMappingURL=normalizeToPosixPath.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalizeToPosixPath.js","names":[],"sources":["../../../../../src/lib/container/runtime/normalizeToPosixPath.ts"],"sourcesContent":["import path from 'path';\n\nfunction toPosixSeparators(value: string): string {\n return value.replace(/\\\\/g, '/').replace(/(?<!^)\\/+/g, '/');\n}\n\nexport function normalizeToPosixPath(value: string): string {\n const input = toPosixSeparators(path.normalize(value || ''));\n let result = toPosixSeparators(path.normalize(input));\n\n if (\n input.startsWith('./') &&\n !result.startsWith('./') &&\n !result.startsWith('..')\n ) {\n result = `./${result}`;\n } else if (input.startsWith('//') && !result.startsWith('//')) {\n result = input.startsWith('//./') ? `//.${result}` : `/${result}`;\n }\n\n return result;\n}\n"],"mappings":";;;;;;AAEA,SAAS,kBAAkB,OAAuB;AAChD,QAAO,MAAM,QAAQ,OAAO,IAAI,CAAC,QAAQ,cAAc,IAAI;;AAG7D,SAAgB,qBAAqB,OAAuB;CAC1D,MAAM,QAAQ,kBAAkB,aAAK,UAAU,SAAS,GAAG,CAAC;CAC5D,IAAI,SAAS,kBAAkB,aAAK,UAAU,MAAM,CAAC;AAErD,KACE,MAAM,WAAW,KAAK,IACtB,CAAC,OAAO,WAAW,KAAK,IACxB,CAAC,OAAO,WAAW,KAAK,CAExB,UAAS,KAAK;UACL,MAAM,WAAW,KAAK,IAAI,CAAC,OAAO,WAAW,KAAK,CAC3D,UAAS,MAAM,WAAW,OAAO,GAAG,MAAM,WAAW,IAAI;AAG3D,QAAO"}
|
|
@@ -1,27 +1,31 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import { init } from
|
|
5
|
-
|
|
6
|
-
//#region src/lib/container/runtime/utils.d.ts
|
|
1
|
+
import type webpack from 'webpack';
|
|
2
|
+
import type RuntimeGlobals from 'webpack/lib/RuntimeGlobals';
|
|
3
|
+
import type { moduleFederationPlugin } from '@module-federation/sdk';
|
|
4
|
+
import type { init } from '@module-federation/runtime-tools';
|
|
7
5
|
type Remotes = Parameters<typeof init>[0]['remotes'];
|
|
8
|
-
interface NormalizedRuntimeInitOptionsWithOutShared {
|
|
6
|
+
export interface NormalizedRuntimeInitOptionsWithOutShared {
|
|
9
7
|
name: string;
|
|
10
|
-
remotes: Array<
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
remotes: Array<
|
|
9
|
+
Remotes[0] & {
|
|
10
|
+
externalType: moduleFederationPlugin.ExternalsType;
|
|
11
|
+
}
|
|
12
|
+
>;
|
|
13
13
|
}
|
|
14
|
-
type EntryStaticNormalized = Awaited<
|
|
14
|
+
type EntryStaticNormalized = Awaited<
|
|
15
|
+
ReturnType<Extract<webpack.WebpackOptionsNormalized['entry'], () => any>>
|
|
16
|
+
>;
|
|
15
17
|
interface ModifyEntryOptions {
|
|
16
18
|
compiler: webpack.Compiler;
|
|
17
19
|
prependEntry?: (entry: EntryStaticNormalized) => void;
|
|
18
20
|
staticEntry?: EntryStaticNormalized;
|
|
19
21
|
}
|
|
20
|
-
declare function getFederationGlobalScope(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
declare function
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
export
|
|
27
|
-
|
|
22
|
+
export declare function getFederationGlobalScope(
|
|
23
|
+
runtimeGlobals: typeof RuntimeGlobals,
|
|
24
|
+
): string;
|
|
25
|
+
export declare function normalizeRuntimeInitOptionsWithOutShared(
|
|
26
|
+
options: moduleFederationPlugin.ModuleFederationPluginOptions,
|
|
27
|
+
): NormalizedRuntimeInitOptionsWithOutShared;
|
|
28
|
+
export declare function modifyEntry(options: ModifyEntryOptions): void;
|
|
29
|
+
export declare function createHash(contents: string): string;
|
|
30
|
+
export declare const normalizeToPosixPath: (p: string) => string;
|
|
31
|
+
export {};
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
const require_runtime = require('../../../_virtual/_rolldown/runtime.js');
|
|
3
3
|
const require_lib_container_options = require('../options.js');
|
|
4
|
+
const require_lib_container_runtime_normalizeToPosixPath = require('./normalizeToPosixPath.js');
|
|
4
5
|
let _module_federation_sdk_normalize_webpack_path = require("@module-federation/sdk/normalize-webpack-path");
|
|
5
|
-
let upath = require("upath");
|
|
6
|
-
upath = require_runtime.__toESM(upath);
|
|
7
|
-
let path = require("path");
|
|
8
|
-
path = require_runtime.__toESM(path);
|
|
9
6
|
let crypto = require("crypto");
|
|
10
7
|
crypto = require_runtime.__toESM(crypto);
|
|
11
8
|
|
|
@@ -82,12 +79,11 @@ function modifyEntry(options) {
|
|
|
82
79
|
function createHash(contents) {
|
|
83
80
|
return crypto.default.createHash("md5").update(contents).digest("hex");
|
|
84
81
|
}
|
|
85
|
-
const normalizeToPosixPath = (p) => upath.default.normalizeSafe(path.default.normalize(p || ""));
|
|
86
82
|
|
|
87
83
|
//#endregion
|
|
88
84
|
exports.createHash = createHash;
|
|
89
85
|
exports.getFederationGlobalScope = getFederationGlobalScope;
|
|
90
86
|
exports.modifyEntry = modifyEntry;
|
|
91
87
|
exports.normalizeRuntimeInitOptionsWithOutShared = normalizeRuntimeInitOptionsWithOutShared;
|
|
92
|
-
exports.normalizeToPosixPath = normalizeToPosixPath;
|
|
88
|
+
exports.normalizeToPosixPath = require_lib_container_runtime_normalizeToPosixPath.normalizeToPosixPath;
|
|
93
89
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":["parseOptions"],"sources":["../../../../../src/lib/container/runtime/utils.ts"],"sourcesContent":["/*\n\tMIT License http://www.opensource.org/licenses/mit-license.php\n\tAuthor Zackary Jackson @ScriptedAlchemy\n*/\nimport { normalizeWebpackPath } from '@module-federation/sdk/normalize-webpack-path';\nimport
|
|
1
|
+
{"version":3,"file":"utils.js","names":["parseOptions"],"sources":["../../../../../src/lib/container/runtime/utils.ts"],"sourcesContent":["/*\n\tMIT License http://www.opensource.org/licenses/mit-license.php\n\tAuthor Zackary Jackson @ScriptedAlchemy\n*/\nimport { normalizeWebpackPath } from '@module-federation/sdk/normalize-webpack-path';\nimport crypto from 'crypto';\nimport { parseOptions } from '../options';\nimport type webpack from 'webpack';\nimport type RuntimeGlobals from 'webpack/lib/RuntimeGlobals';\nimport type { moduleFederationPlugin } from '@module-federation/sdk';\nimport type { init } from '@module-federation/runtime-tools';\n\ntype Remotes = Parameters<typeof init>[0]['remotes'];\n\nexport interface NormalizedRuntimeInitOptionsWithOutShared {\n name: string;\n remotes: Array<\n Remotes[0] & { externalType: moduleFederationPlugin.ExternalsType }\n >;\n}\n\nconst extractUrlAndGlobal = require(\n normalizeWebpackPath('webpack/lib/util/extractUrlAndGlobal'),\n) as typeof import('webpack/lib/util/extractUrlAndGlobal');\n\ntype EntryStaticNormalized = Awaited<\n ReturnType<Extract<webpack.WebpackOptionsNormalized['entry'], () => any>>\n>;\n\ninterface ModifyEntryOptions {\n compiler: webpack.Compiler;\n prependEntry?: (entry: EntryStaticNormalized) => void;\n staticEntry?: EntryStaticNormalized;\n}\n\nexport function getFederationGlobalScope(\n runtimeGlobals: typeof RuntimeGlobals,\n): string {\n return `${runtimeGlobals.require || '__webpack_require__'}.federation`;\n}\n\nexport function normalizeRuntimeInitOptionsWithOutShared(\n options: moduleFederationPlugin.ModuleFederationPluginOptions,\n): NormalizedRuntimeInitOptionsWithOutShared {\n const parsedOptions = parseOptions(\n options.remotes || [],\n (item) => ({\n external: Array.isArray(item) ? item : [item],\n shareScope: options.shareScope || 'default',\n }),\n (item) => ({\n external: Array.isArray(item.external) ? item.external : [item.external],\n shareScope: item.shareScope || options.shareScope || 'default',\n }),\n );\n const remoteOptions: NormalizedRuntimeInitOptionsWithOutShared['remotes'] =\n [];\n parsedOptions.forEach((parsedOption) => {\n const [alias, remoteInfos] = parsedOption;\n const { external, shareScope } = remoteInfos;\n external.forEach((externalItem) => {\n try {\n const entry = externalItem;\n if (/\\s/.test(entry)) {\n return;\n }\n const [url, globalName] = extractUrlAndGlobal(externalItem);\n remoteOptions.push({\n alias,\n name: globalName,\n entry: url,\n shareScope: shareScope,\n externalType: 'script',\n });\n } catch (err) {\n const getExternalTypeFromExternal = (external: string) => {\n if (/^[a-z0-9-]+ /.test(external)) {\n const idx = external.indexOf(' ');\n return [\n external.slice(0, idx) as moduleFederationPlugin.ExternalsType,\n external.slice(idx + 1),\n ] as const;\n }\n return null;\n };\n remoteOptions.push({\n alias,\n name: '',\n entry: '',\n shareScope: shareScope,\n // @ts-ignore\n externalType: getExternalTypeFromExternal(externalItem) || 'unknown',\n });\n return;\n }\n });\n });\n\n const initOptionsWithoutShared = {\n name: options.name!,\n remotes: remoteOptions,\n shareStrategy: options.shareStrategy || 'version-first',\n };\n\n return initOptionsWithoutShared;\n}\n\nexport function modifyEntry(options: ModifyEntryOptions): void {\n const { compiler, staticEntry, prependEntry } = options;\n const operator = (\n oriEntry: EntryStaticNormalized,\n newEntry: EntryStaticNormalized,\n ): EntryStaticNormalized => Object.assign(oriEntry, newEntry);\n\n if (typeof compiler.options.entry === 'function') {\n const prevEntryFn = compiler.options.entry;\n compiler.options.entry = async () => {\n let res = await prevEntryFn();\n if (staticEntry) {\n res = operator(res, staticEntry);\n }\n if (prependEntry) {\n prependEntry(res);\n }\n return res;\n };\n } else {\n if (staticEntry) {\n compiler.options.entry = operator(compiler.options.entry, staticEntry);\n }\n if (prependEntry) {\n prependEntry(compiler.options.entry);\n }\n }\n}\n\nexport function createHash(contents: string): string {\n return crypto.createHash('md5').update(contents).digest('hex');\n}\n\nexport { normalizeToPosixPath } from './normalizeToPosixPath';\n"],"mappings":";;;;;;;;;AAqBA,MAAM,sBAAsB,gFACL,uCAAuC,CAC7D;AAYD,SAAgB,yBACd,gBACQ;AACR,QAAO,GAAG,eAAe,WAAW,sBAAs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AAS,QAAQ,QAAQ,YAAY;GACnC,IAAI,MAAM,MAAM,aAAa;AAC7B,OAAI,YACF,OAAM,SAAS,KAAK,YAAY;AAElC,OAAI,aACF,cAAa,IAAI;AAEnB,UAAO;;QAEJ;AACL,MAAI,YACF,UAAS,QAAQ,QAAQ,SAAS,SAAS,QAAQ,OAAO,YAAY;AAExE,MAAI,aACF,cAAa,SAAS,QAAQ,MAAM;;;AAK1C,SAAgB,WAAW,UAA0B;AACnD,QAAO,eAAO,WAAW,MAAM,CAAC,OAAO,SAAS,CAAC,OAAO,MAAM"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as node_modules_webpack_types0 from "node_modules/webpack/types";
|
|
2
2
|
|
|
3
3
|
//#region src/lib/sharing/ConsumeSharedFallbackDependency.d.ts
|
|
4
|
-
declare const dependencies: typeof
|
|
4
|
+
declare const dependencies: typeof node_modules_webpack_types0.dependencies;
|
|
5
5
|
declare class ConsumeSharedFallbackDependency extends dependencies.ModuleDependency {
|
|
6
6
|
layer?: string | null;
|
|
7
7
|
/**
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ConsumeOptions } from "@module-federation/sdk";
|
|
2
|
-
import * as
|
|
3
|
-
import { CodeGenerationContext, CodeGenerationResult, Compilation
|
|
2
|
+
import * as node_modules_webpack_types0 from "node_modules/webpack/types";
|
|
3
|
+
import { CodeGenerationContext, CodeGenerationResult, Compilation, Hash, InputFileSystem, LibIdentOptions, NeedBuildContext, ObjectDeserializerContext, ObjectSerializerContext, RequestShortener, ResolverWithOptions, UpdateHashContext, WebpackError, WebpackOptions } from "webpack/lib/Module";
|
|
4
4
|
|
|
5
5
|
//#region src/lib/sharing/ConsumeSharedModule.d.ts
|
|
6
|
-
declare const Module
|
|
7
|
-
declare class ConsumeSharedModule extends Module
|
|
6
|
+
declare const Module: typeof node_modules_webpack_types0.Module;
|
|
7
|
+
declare class ConsumeSharedModule extends Module {
|
|
8
8
|
options: ConsumeOptions;
|
|
9
9
|
/**
|
|
10
10
|
* @param {string} context context
|
|
@@ -39,7 +39,7 @@ declare class ConsumeSharedModule extends Module$1 {
|
|
|
39
39
|
* @param {function(WebpackError=): void} callback callback function
|
|
40
40
|
* @returns {void}
|
|
41
41
|
*/
|
|
42
|
-
build(options: WebpackOptions, compilation: Compilation
|
|
42
|
+
build(options: WebpackOptions, compilation: Compilation, resolver: ResolverWithOptions, fs: InputFileSystem, callback: (error?: WebpackError) => void): void;
|
|
43
43
|
/**
|
|
44
44
|
* @returns {Set<string>} types available (do not mutate)
|
|
45
45
|
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as node_modules_webpack_types0 from "node_modules/webpack/types";
|
|
2
2
|
|
|
3
3
|
//#region src/lib/sharing/ConsumeSharedRuntimeModule.d.ts
|
|
4
|
-
declare const RuntimeModule: typeof
|
|
4
|
+
declare const RuntimeModule: typeof node_modules_webpack_types0.RuntimeModule;
|
|
5
5
|
declare class ConsumeSharedRuntimeModule extends RuntimeModule {
|
|
6
6
|
private _runtimeRequirements;
|
|
7
7
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as node_modules_webpack_types0 from "node_modules/webpack/types";
|
|
2
2
|
|
|
3
3
|
//#region src/lib/sharing/ProvideForSharedDependency.d.ts
|
|
4
|
-
declare const dependencies: typeof
|
|
4
|
+
declare const dependencies: typeof node_modules_webpack_types0.dependencies;
|
|
5
5
|
declare class ProvideForSharedDependency extends dependencies.ModuleDependency {
|
|
6
6
|
/**
|
|
7
7
|
*
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as node_modules_webpack_types0 from "node_modules/webpack/types";
|
|
2
2
|
import { ObjectDeserializerContext, ObjectSerializerContext } from "webpack/lib/Dependency";
|
|
3
3
|
|
|
4
4
|
//#region src/lib/sharing/ProvideSharedDependency.d.ts
|
|
5
|
-
declare const Dependency: typeof
|
|
5
|
+
declare const Dependency: typeof node_modules_webpack_types0.Dependency;
|
|
6
6
|
declare class ProvideSharedDependency extends Dependency {
|
|
7
7
|
shareScope: string | string[];
|
|
8
8
|
name: string;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import * as webpack$1 from "webpack";
|
|
2
1
|
import { Compilation } from "webpack";
|
|
2
|
+
import * as node_modules_webpack_types0 from "node_modules/webpack/types";
|
|
3
3
|
import { CodeGenerationContext, CodeGenerationResult, LibIdentOptions, NeedBuildContext, ObjectDeserializerContext, ObjectSerializerContext, RequestShortener, ResolverWithOptions } from "webpack/lib/Module";
|
|
4
4
|
import WebpackError$1 from "webpack/lib/WebpackError";
|
|
5
5
|
import { InputFileSystem as InputFileSystem$1 } from "webpack/lib/util/fs";
|
|
6
6
|
import { WebpackOptionsNormalized as WebpackOptionsNormalized$1 } from "webpack/declarations/WebpackOptions";
|
|
7
7
|
|
|
8
8
|
//#region src/lib/sharing/ProvideSharedModule.d.ts
|
|
9
|
-
declare const Module$1: typeof
|
|
9
|
+
declare const Module$1: typeof node_modules_webpack_types0.Module;
|
|
10
10
|
/**
|
|
11
11
|
* @class
|
|
12
12
|
* @extends {Module}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as node_modules_webpack_types0 from "node_modules/webpack/types";
|
|
2
2
|
|
|
3
3
|
//#region src/lib/sharing/ShareRuntimeModule.d.ts
|
|
4
|
-
declare const RuntimeModule: typeof
|
|
4
|
+
declare const RuntimeModule: typeof node_modules_webpack_types0.RuntimeModule;
|
|
5
5
|
declare class ShareRuntimeModule extends RuntimeModule {
|
|
6
6
|
constructor();
|
|
7
7
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ShareFallback } from "./IndependentSharedPlugin.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as node_modules_webpack_types0 from "node_modules/webpack/types";
|
|
3
3
|
|
|
4
4
|
//#region src/lib/sharing/tree-shaking/IndependentSharedRuntimeModule.d.ts
|
|
5
5
|
/**
|
|
@@ -11,7 +11,7 @@ import * as webpack$1 from "webpack";
|
|
|
11
11
|
* }
|
|
12
12
|
*/
|
|
13
13
|
type ReferencedExports = Map<string, Map<string, Set<string>>>;
|
|
14
|
-
declare const RuntimeModule: typeof
|
|
14
|
+
declare const RuntimeModule: typeof node_modules_webpack_types0.RuntimeModule;
|
|
15
15
|
declare class IndependentSharedRuntimeModule extends RuntimeModule {
|
|
16
16
|
buildAssets: ShareFallback;
|
|
17
17
|
libraryType: string;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as node_modules_webpack_types0 from "node_modules/webpack/types";
|
|
2
2
|
import { ObjectDeserializerContext, ObjectSerializerContext } from "webpack/lib/dependencies/ModuleDependency";
|
|
3
3
|
|
|
4
4
|
//#region src/lib/sharing/tree-shaking/SharedContainerPlugin/SharedDependency.d.ts
|
|
5
|
-
declare const dependencies: typeof
|
|
5
|
+
declare const dependencies: typeof node_modules_webpack_types0.dependencies;
|
|
6
6
|
declare class SharedDependency extends dependencies.ModuleDependency {
|
|
7
7
|
sharedName: string;
|
|
8
8
|
request: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as node_modules_webpack_types0 from "node_modules/webpack/types";
|
|
2
2
|
|
|
3
3
|
//#region src/lib/sharing/tree-shaking/SharedContainerPlugin/SharedEntryDependency.d.ts
|
|
4
|
-
declare const Dependency: typeof
|
|
4
|
+
declare const Dependency: typeof node_modules_webpack_types0.Dependency;
|
|
5
5
|
declare class SharedEntryDependency extends Dependency {
|
|
6
6
|
name: string;
|
|
7
7
|
request: string;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import * as webpack$1 from "webpack";
|
|
2
1
|
import { Compilation } from "webpack";
|
|
2
|
+
import * as node_modules_webpack_types0 from "node_modules/webpack/types";
|
|
3
3
|
import { CodeGenerationResult, InputFileSystem, LibIdentOptions, NeedBuildContext, ObjectDeserializerContext, ObjectSerializerContext, RequestShortener, ResolverWithOptions, WebpackOptions } from "webpack/lib/Module";
|
|
4
4
|
import WebpackError$1 from "webpack/lib/WebpackError";
|
|
5
5
|
|
|
6
6
|
//#region src/lib/sharing/tree-shaking/SharedContainerPlugin/SharedEntryModule.d.ts
|
|
7
|
-
declare const Module$1: typeof
|
|
7
|
+
declare const Module$1: typeof node_modules_webpack_types0.Module;
|
|
8
8
|
type ExposeOptions = {
|
|
9
9
|
/**
|
|
10
10
|
* requests to exposed modules (last one is exported)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as node_modules_webpack_types0 from "node_modules/webpack/types";
|
|
2
2
|
|
|
3
3
|
//#region src/lib/sharing/tree-shaking/SharedUsedExportsOptimizerRuntimeModule.d.ts
|
|
4
4
|
/**
|
|
@@ -8,7 +8,7 @@ import * as webpack$1 from "webpack";
|
|
|
8
8
|
* }
|
|
9
9
|
*/
|
|
10
10
|
type ReferencedExports = Map<string, Set<string>>;
|
|
11
|
-
declare const RuntimeModule: typeof
|
|
11
|
+
declare const RuntimeModule: typeof node_modules_webpack_types0.RuntimeModule;
|
|
12
12
|
declare class SharedUsedExportsOptimizerRuntimeModule extends RuntimeModule {
|
|
13
13
|
private sharedUsedExports;
|
|
14
14
|
constructor(sharedUsedExports: ReferencedExports);
|
|
@@ -1967,7 +1967,7 @@ function D(o, { instancePath: i = "", parentData: a, parentDataProperty: p, root
|
|
|
1967
1967
|
if (void 0 !== r.family) {
|
|
1968
1968
|
let e = r.family;
|
|
1969
1969
|
const n = c;
|
|
1970
|
-
if (
|
|
1970
|
+
if (4 !== e && 6 !== e) {
|
|
1971
1971
|
const e = { params: { allowedValues: t.properties.dts.anyOf[1].properties.consumeTypes.anyOf[1].properties.family.enum } };
|
|
1972
1972
|
null === u ? u = [e] : u.push(e), c++;
|
|
1973
1973
|
}
|
|
@@ -2095,19 +2095,33 @@ function D(o, { instancePath: i = "", parentData: a, parentDataProperty: p, root
|
|
|
2095
2095
|
if (!r || "object" != typeof r || Array.isArray(r)) return D.errors = [{ params: { type: "object" } }], !1;
|
|
2096
2096
|
{
|
|
2097
2097
|
const e = c;
|
|
2098
|
-
for (const e in r) if ("disableSnapshot" !== e && "target" !== e) return D.errors = [{ params: { additionalProperty: e } }], !1;
|
|
2098
|
+
for (const e in r) if ("disableSnapshot" !== e && "disableRemote" !== e && "disableShared" !== e && "target" !== e) return D.errors = [{ params: { additionalProperty: e } }], !1;
|
|
2099
2099
|
if (e === c) {
|
|
2100
2100
|
if (void 0 !== r.disableSnapshot) {
|
|
2101
2101
|
const e = c;
|
|
2102
2102
|
if ("boolean" != typeof r.disableSnapshot) return D.errors = [{ params: { type: "boolean" } }], !1;
|
|
2103
2103
|
var I = e === c;
|
|
2104
2104
|
} else I = !0;
|
|
2105
|
-
if (I)
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2105
|
+
if (I) {
|
|
2106
|
+
if (void 0 !== r.disableRemote) {
|
|
2107
|
+
const e = c;
|
|
2108
|
+
if ("boolean" != typeof r.disableRemote) return D.errors = [{ params: { type: "boolean" } }], !1;
|
|
2109
|
+
I = e === c;
|
|
2110
|
+
} else I = !0;
|
|
2111
|
+
if (I) {
|
|
2112
|
+
if (void 0 !== r.disableShared) {
|
|
2113
|
+
const e = c;
|
|
2114
|
+
if ("boolean" != typeof r.disableShared) return D.errors = [{ params: { type: "boolean" } }], !1;
|
|
2115
|
+
I = e === c;
|
|
2116
|
+
} else I = !0;
|
|
2117
|
+
if (I) if (void 0 !== r.target) {
|
|
2118
|
+
let e = r.target;
|
|
2119
|
+
const n = c;
|
|
2120
|
+
if ("web" !== e && "node" !== e) return D.errors = [{ params: { allowedValues: t.properties.experiments.properties.optimization.properties.target.enum } }], !1;
|
|
2121
|
+
I = n === c;
|
|
2122
|
+
} else I = !0;
|
|
2123
|
+
}
|
|
2124
|
+
}
|
|
2111
2125
|
}
|
|
2112
2126
|
}
|
|
2113
2127
|
}
|
|
@@ -2799,11 +2813,7 @@ var init_ModuleFederationPlugin_check = require_runtime.__esmMin((() => {
|
|
|
2799
2813
|
}
|
|
2800
2814
|
}] },
|
|
2801
2815
|
timeout: { type: "number" },
|
|
2802
|
-
family: { enum: [
|
|
2803
|
-
0,
|
|
2804
|
-
4,
|
|
2805
|
-
6
|
|
2806
|
-
] },
|
|
2816
|
+
family: { enum: [4, 6] },
|
|
2807
2817
|
typesOnBuild: { type: "boolean" }
|
|
2808
2818
|
}
|
|
2809
2819
|
}] },
|
|
@@ -2824,6 +2834,8 @@ var init_ModuleFederationPlugin_check = require_runtime.__esmMin((() => {
|
|
|
2824
2834
|
type: "object",
|
|
2825
2835
|
properties: {
|
|
2826
2836
|
disableSnapshot: { type: "boolean" },
|
|
2837
|
+
disableRemote: { type: "boolean" },
|
|
2838
|
+
disableShared: { type: "boolean" },
|
|
2827
2839
|
target: { enum: ["web", "node"] }
|
|
2828
2840
|
},
|
|
2829
2841
|
additionalProperties: !1
|