@module-federation/enhanced 2.9.1 → 2.9.3

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.
Files changed (52) hide show
  1. package/dist/CHANGELOG.md +63 -0
  2. package/dist/src/lib/container/ContainerEntryDependency.js +2 -2
  3. package/dist/src/lib/container/ContainerEntryDependency.js.map +1 -1
  4. package/dist/src/lib/container/ContainerEntryModule.js +14 -8
  5. package/dist/src/lib/container/ContainerEntryModule.js.map +1 -1
  6. package/dist/src/lib/container/ContainerExposedDependency.js +2 -2
  7. package/dist/src/lib/container/ContainerExposedDependency.js.map +1 -1
  8. package/dist/src/lib/container/FallbackDependency.js +2 -2
  9. package/dist/src/lib/container/FallbackDependency.js.map +1 -1
  10. package/dist/src/lib/container/FallbackItemDependency.js +2 -2
  11. package/dist/src/lib/container/FallbackItemDependency.js.map +1 -1
  12. package/dist/src/lib/container/FallbackModule.js +2 -2
  13. package/dist/src/lib/container/FallbackModule.js.map +1 -1
  14. package/dist/src/lib/container/HoistContainerReferencesPlugin.js +1 -0
  15. package/dist/src/lib/container/HoistContainerReferencesPlugin.js.map +1 -1
  16. package/dist/src/lib/container/RemoteModule.js +2 -2
  17. package/dist/src/lib/container/RemoteModule.js.map +1 -1
  18. package/dist/src/lib/container/RemoteRuntimeModule.js +2 -1
  19. package/dist/src/lib/container/RemoteRuntimeModule.js.map +1 -1
  20. package/dist/src/lib/container/RemoteToExternalDependency.js +2 -2
  21. package/dist/src/lib/container/RemoteToExternalDependency.js.map +1 -1
  22. package/dist/src/lib/container/runtime/FederationRuntimePlugin.js +29 -5
  23. package/dist/src/lib/container/runtime/FederationRuntimePlugin.js.map +1 -1
  24. package/dist/src/lib/makeSerializable.d.ts +15 -0
  25. package/dist/src/lib/makeSerializable.js +20 -0
  26. package/dist/src/lib/makeSerializable.js.map +1 -0
  27. package/dist/src/lib/sharing/ConsumeSharedFallbackDependency.js +2 -2
  28. package/dist/src/lib/sharing/ConsumeSharedFallbackDependency.js.map +1 -1
  29. package/dist/src/lib/sharing/ConsumeSharedModule.js +6 -6
  30. package/dist/src/lib/sharing/ConsumeSharedModule.js.map +1 -1
  31. package/dist/src/lib/sharing/ConsumeSharedPlugin.d.ts +1 -1
  32. package/dist/src/lib/sharing/ConsumeSharedPlugin.js +27 -38
  33. package/dist/src/lib/sharing/ConsumeSharedPlugin.js.map +1 -1
  34. package/dist/src/lib/sharing/ProvideForSharedDependency.js +2 -2
  35. package/dist/src/lib/sharing/ProvideForSharedDependency.js.map +1 -1
  36. package/dist/src/lib/sharing/ProvideSharedDependency.js +2 -2
  37. package/dist/src/lib/sharing/ProvideSharedDependency.js.map +1 -1
  38. package/dist/src/lib/sharing/ProvideSharedModule.js +2 -2
  39. package/dist/src/lib/sharing/ProvideSharedModule.js.map +1 -1
  40. package/dist/src/lib/sharing/ProvideSharedPlugin.js +14 -65
  41. package/dist/src/lib/sharing/ProvideSharedPlugin.js.map +1 -1
  42. package/dist/src/lib/sharing/tree-shaking/IndependentSharedPlugin.js +46 -36
  43. package/dist/src/lib/sharing/tree-shaking/IndependentSharedPlugin.js.map +1 -1
  44. package/dist/src/lib/sharing/tree-shaking/SharedContainerPlugin/SharedContainerPlugin.js +2 -5
  45. package/dist/src/lib/sharing/tree-shaking/SharedContainerPlugin/SharedContainerPlugin.js.map +1 -1
  46. package/dist/src/lib/sharing/tree-shaking/SharedContainerPlugin/SharedDependency.js +2 -2
  47. package/dist/src/lib/sharing/tree-shaking/SharedContainerPlugin/SharedDependency.js.map +1 -1
  48. package/dist/src/lib/sharing/tree-shaking/SharedContainerPlugin/SharedEntryDependency.js +2 -2
  49. package/dist/src/lib/sharing/tree-shaking/SharedContainerPlugin/SharedEntryDependency.js.map +1 -1
  50. package/dist/src/lib/sharing/tree-shaking/SharedContainerPlugin/SharedEntryModule.js +2 -2
  51. package/dist/src/lib/sharing/tree-shaking/SharedContainerPlugin/SharedEntryModule.js.map +1 -1
  52. package/package.json +13 -13
@@ -1 +1 @@
1
- {"version":3,"file":"ConsumeSharedPlugin.js","names":["createSchemaValidation","parseOptions","getRequiredVersionFromDescriptionFile","ConsumeSharedModule","FederationRuntimePlugin","ConsumeSharedFallbackDependency","resolveMatchedConfigs","ProvideForSharedDependency","createLookupKeyForSharing","extractPathAfterNodeModules","testRequestFilters","ConsumeSharedRuntimeModule","ShareRuntimeModule"],"sources":["../../../../src/lib/sharing/ConsumeSharedPlugin.ts"],"sourcesContent":["/*\n MIT License http://www.opensource.org/licenses/mit-license.php\n Author Tobias Koppers @sokra, Zackary Jackson @ScriptedAlchemy\n*/\n\n'use strict';\n\n// Hoisted regex constants\nconst DIRECT_FALLBACK_REGEX = /^(\\.\\.?(\\/|$)|\\/|[A-Za-z]:|\\\\\\\\)/;\nconst ABSOLUTE_PATH_REGEX = /^(\\/|[A-Za-z]:|\\\\\\\\)/;\nconst RELATIVE_OR_ABSOLUTE_PATH_REGEX = /^(?:\\.{1,2}[\\\\/]|\\/|[A-Za-z]:|\\\\\\\\)/;\nconst PACKAGE_NAME_REGEX = /^((?:@[^\\\\/]+[\\\\/])?[^\\\\/]+)/;\n\nimport {\n getWebpackPath,\n normalizeWebpackPath,\n} from '@module-federation/sdk/normalize-webpack-path';\nimport { isRequiredVersion } from '@module-federation/sdk';\nimport type { Compiler, Compilation, Module } from 'webpack';\nimport { parseOptions } from '../container/options';\nimport type { consumeSharedPlugin } from '@module-federation/sdk';\ntype ConsumeSharedPluginOptions =\n consumeSharedPlugin.ConsumeSharedPluginOptions;\nimport { resolveMatchedConfigs } from './resolveMatchedConfigs';\nimport {\n getDescriptionFile,\n getRequiredVersionFromDescriptionFile,\n} from './utils';\nimport type {\n ResolveOptionsWithDependencyType,\n ResolverWithOptions,\n} from 'webpack/lib/ResolverFactory';\nimport ConsumeSharedFallbackDependency from './ConsumeSharedFallbackDependency';\nimport ConsumeSharedModule from './ConsumeSharedModule';\nimport ConsumeSharedRuntimeModule from './ConsumeSharedRuntimeModule';\nimport ProvideForSharedDependency from './ProvideForSharedDependency';\nimport FederationRuntimePlugin from '../container/runtime/FederationRuntimePlugin';\nimport ShareRuntimeModule from './ShareRuntimeModule';\nimport type { SemVerRange } from 'webpack/lib/util/semver';\nimport type { ResolveData } from 'webpack/lib/NormalModuleFactory';\nimport type { ModuleFactoryCreateDataContextInfo } from 'webpack/lib/ModuleFactory';\nimport type { ConsumeOptions } from '@module-federation/sdk';\nimport { createSchemaValidation } from '../../utils';\nimport path from 'path';\nconst { satisfy, parseRange } = require(\n normalizeWebpackPath('webpack/lib/util/semver'),\n) as typeof import('webpack/lib/util/semver');\nimport {\n addSingletonFilterWarning,\n testRequestFilters,\n createLookupKeyForSharing,\n extractPathAfterNodeModules,\n} from './utils';\n\nconst ModuleNotFoundError = require(\n normalizeWebpackPath('webpack/lib/ModuleNotFoundError'),\n) as typeof import('webpack/lib/ModuleNotFoundError');\nconst { RuntimeGlobals } = require(\n normalizeWebpackPath('webpack'),\n) as typeof import('webpack');\nconst LazySet = require(\n normalizeWebpackPath('webpack/lib/util/LazySet'),\n) as typeof import('webpack/lib/util/LazySet');\nconst WebpackError = require(\n normalizeWebpackPath('webpack/lib/WebpackError'),\n) as typeof import('webpack/lib/WebpackError');\n\nconst validate = createSchemaValidation(\n // eslint-disable-next-line\n require('../../schemas/sharing/ConsumeSharedPlugin.check.js').validate,\n () => require('../../schemas/sharing/ConsumeSharedPlugin').default,\n {\n name: 'Consume Shared Plugin',\n baseDataPath: 'options',\n },\n);\n\nconst RESOLVE_OPTIONS: ResolveOptionsWithDependencyType = {\n dependencyType: 'esm',\n};\nconst PLUGIN_NAME = 'ConsumeSharedPlugin';\n\nclass ConsumeSharedPlugin {\n private _consumes: [string, ConsumeOptions][];\n\n constructor(options: ConsumeSharedPluginOptions) {\n if (typeof options !== 'string') {\n validate(options);\n }\n\n this._consumes = parseOptions(\n options.consumes,\n (item, key) => {\n if (Array.isArray(item)) throw new Error('Unexpected array in options');\n //@ts-ignore\n const result: ConsumeOptions =\n item === key || !isRequiredVersion(item)\n ? // item is a request/key\n {\n import: key,\n shareScope: options.shareScope || 'default',\n shareKey: key,\n requiredVersion: undefined,\n packageName: undefined,\n strictVersion: false,\n singleton: false,\n eager: false,\n issuerLayer: undefined,\n layer: undefined,\n request: key,\n include: undefined,\n exclude: undefined,\n allowNodeModulesSuffixMatch: undefined,\n treeShakingMode: undefined,\n }\n : // key is a request/key\n // item is a version\n {\n import: key,\n shareScope: options.shareScope || 'default',\n shareKey: key,\n // webpack internal semver has some issue, use runtime semver , related issue: https://github.com/webpack/webpack/issues/17756\n requiredVersion: item,\n strictVersion: true,\n packageName: undefined,\n singleton: false,\n eager: false,\n issuerLayer: undefined,\n layer: undefined,\n request: key,\n include: undefined,\n exclude: undefined,\n allowNodeModulesSuffixMatch: undefined,\n treeShakingMode: undefined,\n };\n return result;\n },\n (item, key) => {\n const request = item.request || key;\n return {\n import: item.import === false ? undefined : item.import || request,\n shareScope: item.shareScope || options.shareScope || 'default',\n shareKey: item.shareKey || request,\n requiredVersion:\n item.requiredVersion === false\n ? false\n : // @ts-ignore webpack internal semver has some issue, use runtime semver , related issue: https://github.com/webpack/webpack/issues/17756\n (item.requiredVersion as SemVerRange),\n strictVersion:\n typeof item.strictVersion === 'boolean'\n ? item.strictVersion\n : item.import !== false && !item.singleton,\n packageName: item.packageName,\n singleton: !!item.singleton,\n eager: !!item.eager,\n exclude: item.exclude,\n include: item.include,\n issuerLayer: item.issuerLayer ? item.issuerLayer : undefined,\n layer: item.layer ? item.layer : undefined,\n request,\n allowNodeModulesSuffixMatch: item.allowNodeModulesSuffixMatch,\n treeShakingMode: item.treeShakingMode,\n } as ConsumeOptions;\n },\n );\n }\n\n createConsumeSharedModule(\n compilation: Compilation,\n context: string,\n request: string,\n config: ConsumeOptions,\n ): Promise<ConsumeSharedModule> {\n const requiredVersionWarning = (details: string) => {\n const error = new WebpackError(\n `No required version specified and unable to automatically determine one. ${details}`,\n );\n error.file = `shared module ${request}`;\n compilation.warnings.push(error);\n };\n const directFallback =\n config.import && DIRECT_FALLBACK_REGEX.test(config.import);\n\n const resolver: ResolverWithOptions = compilation.resolverFactory.get(\n 'normal',\n RESOLVE_OPTIONS as ResolveOptionsWithDependencyType,\n );\n\n return Promise.all([\n new Promise<string | undefined>((resolve) => {\n if (!config.import) return resolve(undefined);\n const resolveContext = {\n fileDependencies: new LazySet<string>(),\n contextDependencies: new LazySet<string>(),\n missingDependencies: new LazySet<string>(),\n };\n resolver.resolve(\n {},\n directFallback ? compilation.compiler.context : context,\n config.import,\n resolveContext,\n (err, result) => {\n compilation.contextDependencies.addAll(\n resolveContext.contextDependencies,\n );\n compilation.fileDependencies.addAll(\n resolveContext.fileDependencies,\n );\n compilation.missingDependencies.addAll(\n resolveContext.missingDependencies,\n );\n if (err) {\n compilation.errors.push(\n new ModuleNotFoundError(null, err, {\n name: `resolving fallback for shared module ${request}`,\n }),\n );\n return resolve(undefined);\n }\n //@ts-ignore\n resolve(result);\n },\n );\n }),\n new Promise<false | undefined | SemVerRange>((resolve) => {\n if (config.requiredVersion !== undefined) {\n return resolve(config.requiredVersion);\n }\n let packageName = config.packageName;\n if (packageName === undefined) {\n if (ABSOLUTE_PATH_REGEX.test(request)) {\n // For relative or absolute requests we don't automatically use a packageName.\n // If wished one can specify one with the packageName option.\n return resolve(undefined);\n }\n const match = PACKAGE_NAME_REGEX.exec(request);\n if (!match) {\n requiredVersionWarning(\n 'Unable to extract the package name from request.',\n );\n return resolve(undefined);\n }\n packageName = match[0];\n }\n\n getDescriptionFile(\n compilation.inputFileSystem,\n context,\n ['package.json'],\n (err, result, checkedDescriptionFilePaths) => {\n if (err) {\n requiredVersionWarning(`Unable to read description file: ${err}`);\n return resolve(undefined);\n }\n const { data } = /** @type {DescriptionFile} */ result || {};\n if (!data) {\n if (checkedDescriptionFilePaths?.length) {\n requiredVersionWarning(\n [\n `Unable to find required version for \"${packageName}\" in description file/s`,\n checkedDescriptionFilePaths.join('\\n'),\n 'It need to be in dependencies, devDependencies or peerDependencies.',\n ].join('\\n'),\n );\n } else {\n requiredVersionWarning(\n `Unable to find description file in ${context}.`,\n );\n }\n\n return resolve(undefined);\n }\n if (data['name'] === packageName) {\n // Package self-referencing\n return resolve(undefined);\n }\n const requiredVersion = getRequiredVersionFromDescriptionFile(\n data,\n packageName,\n );\n //TODO: align with webpck semver parser again\n // @ts-ignore webpack internal semver has some issue, use runtime semver , related issue: https://github.com/webpack/webpack/issues/17756\n resolve(requiredVersion);\n },\n (result) => {\n if (!result) return false;\n const { data } = result;\n const maybeRequiredVersion = getRequiredVersionFromDescriptionFile(\n data,\n packageName,\n );\n return (\n data['name'] === packageName ||\n typeof maybeRequiredVersion === 'string'\n );\n },\n );\n }),\n ]).then(([importResolved, requiredVersion]) => {\n const currentConfig = {\n ...config,\n importResolved,\n import: importResolved ? config.import : undefined,\n requiredVersion,\n };\n const consumedModule = new ConsumeSharedModule(\n directFallback ? compilation.compiler.context : context,\n currentConfig,\n );\n\n // Check for include version first\n if (config.include && typeof config.include.version === 'string') {\n if (!importResolved) {\n return consumedModule;\n }\n\n return new Promise((resolveFilter) => {\n getDescriptionFile(\n compilation.inputFileSystem,\n path.dirname(importResolved as string),\n ['package.json'],\n (err, result) => {\n if (err) {\n return resolveFilter(consumedModule);\n }\n const { data } = result || {};\n if (!data || !data['version'] || data['name'] !== request) {\n return resolveFilter(consumedModule);\n }\n\n // Only include if version satisfies the include constraint\n if (\n config.include &&\n satisfy(\n parseRange(config.include.version as string),\n data['version'],\n )\n ) {\n // Validate singleton usage with include.version\n if (\n config.include &&\n config.include.version &&\n config.singleton\n ) {\n addSingletonFilterWarning(\n compilation,\n config.shareKey || request,\n 'include',\n 'version',\n config.include.version,\n request, // moduleRequest\n importResolved, // moduleResource (might be undefined)\n );\n }\n\n return resolveFilter(consumedModule);\n }\n\n // Check fallback version\n if (\n config.include &&\n typeof config.include.fallbackVersion === 'string' &&\n config.include.fallbackVersion\n ) {\n if (\n satisfy(\n parseRange(config.include.version as string),\n config.include.fallbackVersion,\n )\n ) {\n return resolveFilter(consumedModule);\n }\n return resolveFilter(\n undefined as unknown as ConsumeSharedModule,\n );\n }\n\n return resolveFilter(undefined as unknown as ConsumeSharedModule);\n },\n );\n });\n }\n\n // Check for exclude version (existing logic)\n if (config.exclude && typeof config.exclude.version === 'string') {\n if (!importResolved) {\n return consumedModule;\n }\n\n if (\n config.exclude &&\n typeof config.exclude.fallbackVersion === 'string' &&\n config.exclude.fallbackVersion\n ) {\n if (\n satisfy(\n parseRange(config.exclude.version),\n config.exclude.fallbackVersion,\n )\n ) {\n return undefined as unknown as ConsumeSharedModule;\n }\n return consumedModule;\n }\n\n return new Promise((resolveFilter) => {\n getDescriptionFile(\n compilation.inputFileSystem,\n path.dirname(importResolved as string),\n ['package.json'],\n (err, result) => {\n if (err) {\n return resolveFilter(consumedModule);\n }\n const { data } = result || {};\n if (!data || !data['version'] || data['name'] !== request) {\n return resolveFilter(consumedModule);\n }\n\n if (\n config.exclude &&\n typeof config.exclude.version === 'string' &&\n satisfy(parseRange(config.exclude.version), data['version'])\n ) {\n return resolveFilter(\n undefined as unknown as ConsumeSharedModule,\n );\n }\n\n // Validate singleton usage with exclude.version\n if (\n config.exclude &&\n config.exclude.version &&\n config.singleton\n ) {\n addSingletonFilterWarning(\n compilation,\n config.shareKey || request,\n 'exclude',\n 'version',\n config.exclude.version,\n request, // moduleRequest\n importResolved, // moduleResource (might be undefined)\n );\n }\n\n return resolveFilter(consumedModule);\n },\n );\n });\n }\n\n return consumedModule;\n });\n }\n\n apply(compiler: Compiler): void {\n new FederationRuntimePlugin().apply(compiler);\n process.env['FEDERATION_WEBPACK_PATH'] =\n process.env['FEDERATION_WEBPACK_PATH'] || getWebpackPath(compiler);\n\n compiler.hooks.thisCompilation.tap(\n PLUGIN_NAME,\n (compilation: Compilation, { normalModuleFactory }) => {\n compilation.dependencyFactories.set(\n ConsumeSharedFallbackDependency,\n normalModuleFactory,\n );\n\n let unresolvedConsumes: Map<string, ConsumeOptions>,\n resolvedConsumes: Map<string, ConsumeOptions>,\n prefixedConsumes: Map<string, ConsumeOptions>;\n const promise = resolveMatchedConfigs(compilation, this._consumes).then(\n ({ resolved, unresolved, prefixed }) => {\n resolvedConsumes = resolved;\n unresolvedConsumes = unresolved;\n prefixedConsumes = prefixed;\n },\n );\n\n normalModuleFactory.hooks.factorize.tapPromise(\n PLUGIN_NAME,\n async (resolveData: ResolveData): Promise<Module | undefined> => {\n const { context, request, dependencies, contextInfo } = resolveData;\n // wait for resolving to be complete\n // BIND `this` for createConsumeSharedModule call\n const boundCreateConsumeSharedModule =\n this.createConsumeSharedModule.bind(this);\n\n return promise.then(() => {\n if (\n dependencies[0] instanceof ConsumeSharedFallbackDependency ||\n dependencies[0] instanceof ProvideForSharedDependency\n ) {\n return;\n }\n const { context, request, contextInfo } = resolveData;\n\n const match =\n unresolvedConsumes.get(\n createLookupKeyForSharing(request, contextInfo.issuerLayer),\n ) ||\n unresolvedConsumes.get(\n createLookupKeyForSharing(request, undefined),\n );\n\n // First check direct match with original request\n if (match !== undefined) {\n // Use the bound function\n return boundCreateConsumeSharedModule(\n compilation,\n context,\n request,\n match,\n );\n }\n\n // Then try relative path handling and node_modules paths\n let reconstructed: string | null = null;\n let modulePathAfterNodeModules: string | null = null;\n\n if (\n request &&\n !path.isAbsolute(request) &&\n RELATIVE_OR_ABSOLUTE_PATH_REGEX.test(request)\n ) {\n reconstructed = path.join(context, request);\n modulePathAfterNodeModules =\n extractPathAfterNodeModules(reconstructed);\n\n // Try to match with module path after node_modules\n if (modulePathAfterNodeModules) {\n const moduleMatch =\n unresolvedConsumes.get(\n createLookupKeyForSharing(\n modulePathAfterNodeModules,\n contextInfo.issuerLayer,\n ),\n ) ||\n unresolvedConsumes.get(\n createLookupKeyForSharing(\n modulePathAfterNodeModules,\n undefined,\n ),\n );\n\n if (\n moduleMatch !== undefined &&\n moduleMatch.allowNodeModulesSuffixMatch\n ) {\n return boundCreateConsumeSharedModule(\n compilation,\n context,\n modulePathAfterNodeModules,\n moduleMatch,\n );\n }\n }\n\n // Try to match with the full reconstructed path\n const reconstructedMatch =\n unresolvedConsumes.get(\n createLookupKeyForSharing(\n reconstructed,\n contextInfo.issuerLayer,\n ),\n ) ||\n unresolvedConsumes.get(\n createLookupKeyForSharing(reconstructed, undefined),\n );\n\n if (reconstructedMatch !== undefined) {\n return boundCreateConsumeSharedModule(\n compilation,\n context,\n reconstructed,\n reconstructedMatch,\n );\n }\n }\n // Check for prefixed consumes with original request\n for (const [prefix, options] of prefixedConsumes) {\n const lookup = options.request || prefix;\n // Refined issuerLayer matching logic\n if (options.issuerLayer) {\n if (!contextInfo.issuerLayer) {\n continue; // Option is layered, request is not: skip\n }\n if (contextInfo.issuerLayer !== options.issuerLayer) {\n continue; // Both are layered but do not match: skip\n }\n }\n // If contextInfo.issuerLayer exists but options.issuerLayer does not, allow (non-layered option matches layered request)\n if (request.startsWith(lookup)) {\n const remainder = request.slice(lookup.length);\n if (\n !testRequestFilters(\n remainder,\n options.include?.request,\n options.exclude?.request,\n )\n ) {\n continue;\n }\n\n // Use the bound function\n return boundCreateConsumeSharedModule(\n compilation,\n context,\n request,\n {\n ...options,\n import: options.import\n ? options.import + remainder\n : undefined,\n shareKey: options.shareKey + remainder,\n layer: options.layer,\n },\n );\n }\n }\n\n // Also check prefixed consumes with modulePathAfterNodeModules\n if (modulePathAfterNodeModules) {\n for (const [prefix, options] of prefixedConsumes) {\n if (!options.allowNodeModulesSuffixMatch) {\n continue;\n }\n // Refined issuerLayer matching logic for reconstructed path\n if (options.issuerLayer) {\n if (!contextInfo.issuerLayer) {\n continue; // Option is layered, request is not: skip\n }\n if (contextInfo.issuerLayer !== options.issuerLayer) {\n continue; // Both are layered but do not match: skip\n }\n }\n // If contextInfo.issuerLayer exists but options.issuerLayer does not, allow (non-layered option matches layered request)\n const lookup = options.request || prefix;\n if (modulePathAfterNodeModules.startsWith(lookup)) {\n const remainder = modulePathAfterNodeModules.slice(\n lookup.length,\n );\n\n if (\n !testRequestFilters(\n remainder,\n options.include?.request,\n options.exclude?.request,\n )\n ) {\n continue;\n }\n\n return boundCreateConsumeSharedModule(\n compilation,\n context,\n modulePathAfterNodeModules,\n {\n ...options,\n import: options.import\n ? options.import + remainder\n : undefined,\n shareKey: options.shareKey + remainder,\n layer: options.layer,\n },\n );\n }\n }\n }\n\n return;\n });\n },\n );\n normalModuleFactory.hooks.createModule.tapPromise(\n PLUGIN_NAME,\n ({ resource }, { context, dependencies }) => {\n // BIND `this` for createConsumeSharedModule call\n const boundCreateConsumeSharedModule =\n this.createConsumeSharedModule.bind(this);\n if (\n dependencies[0] instanceof ConsumeSharedFallbackDependency ||\n dependencies[0] instanceof ProvideForSharedDependency\n ) {\n return Promise.resolve();\n }\n if (resource) {\n const options = resolvedConsumes.get(resource);\n if (options !== undefined) {\n // Use the bound function\n return boundCreateConsumeSharedModule(\n compilation,\n context,\n resource,\n options,\n );\n }\n }\n return Promise.resolve();\n },\n );\n\n // Add finishModules hook to copy buildMeta/buildInfo from fallback modules *after* webpack's export analysis\n // Running earlier causes failures, so we intentionally execute later than plugins like FlagDependencyExportsPlugin.\n // This still follows webpack's pattern used by FlagDependencyExportsPlugin and InferAsyncModulesPlugin, but with a\n // later stage. Based on webpack's Compilation.js: finishModules (line 2833) runs before seal (line 2920).\n compilation.hooks.finishModules.tapAsync(\n {\n name: PLUGIN_NAME,\n stage: 10, // Run after FlagDependencyExportsPlugin (default stage 0)\n },\n (modules, callback) => {\n for (const module of modules) {\n // Only process ConsumeSharedModule instances with fallback dependencies\n if (\n !(module instanceof ConsumeSharedModule) ||\n !module.options.import\n ) {\n continue;\n }\n\n let dependency;\n if (module.options.eager) {\n // For eager mode, get the fallback directly from dependencies\n dependency = module.dependencies[0];\n } else {\n // For async mode, get it from the async dependencies block\n dependency = module.blocks[0]?.dependencies[0];\n }\n\n if (dependency) {\n const fallbackModule =\n compilation.moduleGraph.getModule(dependency);\n if (\n fallbackModule &&\n fallbackModule.buildMeta &&\n fallbackModule.buildInfo\n ) {\n // Copy buildMeta and buildInfo following webpack's DelegatedModule pattern: this.buildMeta = { ...delegateData.buildMeta };\n // This ensures ConsumeSharedModule inherits ESM/CJS detection (exportsType) and other optimization metadata\n module.buildMeta = { ...fallbackModule.buildMeta };\n module.buildInfo = { ...fallbackModule.buildInfo };\n // Mark all exports as provided, to avoid webpack's export analysis from marking them as unused since we copy buildMeta\n compilation.moduleGraph\n .getExportsInfo(module)\n .setUnknownExportsProvided();\n }\n }\n }\n callback();\n },\n );\n\n compilation.hooks.additionalTreeRuntimeRequirements.tap(\n PLUGIN_NAME,\n (chunk, set) => {\n set.add(RuntimeGlobals.module);\n set.add(RuntimeGlobals.moduleCache);\n set.add(RuntimeGlobals.moduleFactoriesAddOnly);\n set.add(RuntimeGlobals.shareScopeMap);\n set.add(RuntimeGlobals.initializeSharing);\n set.add(RuntimeGlobals.hasOwnProperty);\n compilation.addRuntimeModule(\n chunk,\n new ConsumeSharedRuntimeModule(set),\n );\n // FIXME: need to remove webpack internal inject ShareRuntimeModule, otherwise there will be two ShareRuntimeModule\n compilation.addRuntimeModule(chunk, new ShareRuntimeModule());\n },\n );\n },\n );\n }\n}\n\nexport default ConsumeSharedPlugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAQA,MAAM,wBAAwB;AAC9B,MAAM,sBAAsB;AAC5B,MAAM,kCAAkC;AACxC,MAAM,qBAAqB;AAiC3B,MAAM,EAAE,SAAS,eAAe,gFACT,0BAA0B,CAChD;AAQD,MAAM,sBAAsB,gFACL,kCAAkC,CACxD;AACD,MAAM,EAAE,mBAAmB,gFACJ,UAAU,CAChC;AACD,MAAM,UAAU,gFACO,2BAA2B,CACjD;AACD,MAAM,eAAe,gFACE,2BAA2B,CACjD;AAED,MAAM,WAAWA,6OAE+C,gMACH,SAC3D;CACE,MAAM;CACN,cAAc;CACf,CACF;AAED,MAAM,kBAAoD,EACxD,gBAAgB,OACjB;AACD,MAAM,cAAc;AAEpB,IAAM,sBAAN,MAA0B;CAGxB,Y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iB,IAAI,SAAS;AAC9C,SAAI,YAAY,OAEd,QAAO,+BACL,aACA,SACA,UACA,QACD;;AAGL,WAAO,QAAQ,SAAS;KAE3B;AAMD,eAAY,MAAM,cAAc,SAC9B;IACE,MAAM;IACN,OAAO;IACR,GACA,SAAS,aAAa;AACrB,SAAK,MAAM,UAAU,SAAS;AAE5B,SACE,EAAE,kBAAkBJ,oDACpB,CAAC,OAAO,QAAQ,OAEhB;KAGF,IAAI;AACJ,SAAI,OAAO,QAAQ,MAEjB,cAAa,OAAO,aAAa;SAGjC,cAAa,OAAO,OAAO,IAAI,aAAa;AAG9C,SAAI,YAAY;MACd,MAAM,iBACJ,YAAY,YAAY,UAAU,WAAW;AAC/C,UACE,kBACA,eAAe,aACf,eAAe,WACf;AAGA,cAAO,YAAY,EAAE,GAAG,eAAe,WAAW;AAClD,cAAO,YAAY,EAAE,GAAG,eAAe,WAAW;AAElD,mBAAY,YACT,eAAe,OAAO,CACtB,2BAA2B;;;;AAIpC,cAAU;KAEb;AAED,eAAY,MAAM,kCAAkC,IAClD,cACC,OAAO,QAAQ;AACd,QAAI,IAAI,eAAe,OAAO;AAC9B,QAAI,IAAI,eAAe,YAAY;AACnC,QAAI,IAAI,eAAe,uBAAuB;AAC9C,QAAI,IAAI,eAAe,cAAc;AACrC,QAAI,IAAI,eAAe,kBAAkB;AACzC,QAAI,IAAI,eAAe,eAAe;AACtC,gBAAY,iBACV,OACA,IAAIQ,uDAA2B,IAAI,CACpC;AAED,gBAAY,iBAAiB,OAAO,IAAIC,gDAAoB,CAAC;KAEhE;IAEJ"}
1
+ {"version":3,"file":"ConsumeSharedPlugin.js","names":["createSchemaValidation","parseOptions","getRequiredVersionFromDescriptionFile","ConsumeSharedModule","FederationRuntimePlugin","ConsumeSharedFallbackDependency","resolveMatchedConfigs","ProvideForSharedDependency","createLookupKeyForSharing","extractPathAfterNodeModules","testRequestFilters","ConsumeSharedRuntimeModule","ShareRuntimeModule"],"sources":["../../../../src/lib/sharing/ConsumeSharedPlugin.ts"],"sourcesContent":["/*\n MIT License http://www.opensource.org/licenses/mit-license.php\n Author Tobias Koppers @sokra, Zackary Jackson @ScriptedAlchemy\n*/\n\n'use strict';\n\n// Hoisted regex constants\nconst DIRECT_FALLBACK_REGEX = /^(\\.\\.?(\\/|$)|\\/|[A-Za-z]:|\\\\\\\\)/;\nconst ABSOLUTE_PATH_REGEX = /^(\\/|[A-Za-z]:|\\\\\\\\)/;\nconst RELATIVE_OR_ABSOLUTE_PATH_REGEX = /^(?:\\.{1,2}[\\\\/]|\\/|[A-Za-z]:|\\\\\\\\)/;\nconst PACKAGE_NAME_REGEX = /^((?:@[^\\\\/]+[\\\\/])?[^\\\\/]+)/;\n\nimport {\n getWebpackPath,\n normalizeWebpackPath,\n} from '@module-federation/sdk/normalize-webpack-path';\nimport { isRequiredVersion } from '@module-federation/sdk';\nimport type { Compiler, Compilation, Module } from 'webpack';\nimport { parseOptions } from '../container/options';\nimport type { consumeSharedPlugin } from '@module-federation/sdk';\ntype ConsumeSharedPluginOptions =\n consumeSharedPlugin.ConsumeSharedPluginOptions;\nimport { resolveMatchedConfigs } from './resolveMatchedConfigs';\nimport {\n getDescriptionFile,\n getRequiredVersionFromDescriptionFile,\n} from './utils';\nimport type {\n ResolveOptionsWithDependencyType,\n ResolverWithOptions,\n} from 'webpack/lib/ResolverFactory';\nimport ConsumeSharedFallbackDependency from './ConsumeSharedFallbackDependency';\nimport ConsumeSharedModule from './ConsumeSharedModule';\nimport ConsumeSharedRuntimeModule from './ConsumeSharedRuntimeModule';\nimport ProvideForSharedDependency from './ProvideForSharedDependency';\nimport FederationRuntimePlugin from '../container/runtime/FederationRuntimePlugin';\nimport ShareRuntimeModule from './ShareRuntimeModule';\nimport type { SemVerRange } from 'webpack/lib/util/semver';\nimport type { InputFileSystem } from 'webpack/lib/util/fs';\nimport type { ResolveData } from 'webpack/lib/NormalModuleFactory';\nimport type { ModuleFactoryCreateDataContextInfo } from 'webpack/lib/ModuleFactory';\nimport type { ConsumeOptions } from '@module-federation/sdk';\nimport { createSchemaValidation } from '../../utils';\nimport path from 'path';\nconst { satisfy, parseRange } = require(\n normalizeWebpackPath('webpack/lib/util/semver'),\n) as typeof import('webpack/lib/util/semver');\nimport {\n addSingletonFilterWarning,\n testRequestFilters,\n createLookupKeyForSharing,\n extractPathAfterNodeModules,\n} from './utils';\n\nconst ModuleNotFoundError = require(\n normalizeWebpackPath('webpack/lib/ModuleNotFoundError'),\n) as typeof import('webpack/lib/ModuleNotFoundError');\nconst { RuntimeGlobals } = require(\n normalizeWebpackPath('webpack'),\n) as typeof import('webpack');\nconst LazySet = require(\n normalizeWebpackPath('webpack/lib/util/LazySet'),\n) as typeof import('webpack/lib/util/LazySet');\nconst WebpackError = require(\n normalizeWebpackPath('webpack/lib/WebpackError'),\n) as typeof import('webpack/lib/WebpackError');\n\nconst validate = createSchemaValidation(\n // eslint-disable-next-line\n require('../../schemas/sharing/ConsumeSharedPlugin.check.js').validate,\n () => require('../../schemas/sharing/ConsumeSharedPlugin').default,\n {\n name: 'Consume Shared Plugin',\n baseDataPath: 'options',\n },\n);\n\nconst RESOLVE_OPTIONS: ResolveOptionsWithDependencyType = {\n dependencyType: 'esm',\n};\nconst PLUGIN_NAME = 'ConsumeSharedPlugin';\n\nfunction getPackageVersion(\n fs: InputFileSystem,\n resource: string,\n packageName: string,\n): Promise<string | undefined> {\n return new Promise((resolve) => {\n getDescriptionFile(\n fs,\n path.dirname(resource),\n ['package.json'],\n (err, result) => resolve(err ? undefined : result?.data['version']),\n (result) =>\n !!result &&\n typeof result.data['version'] === 'string' &&\n result.data['name'] === packageName,\n );\n });\n}\n\nclass ConsumeSharedPlugin {\n private _consumes: [string, ConsumeOptions][];\n\n constructor(options: ConsumeSharedPluginOptions) {\n if (typeof options !== 'string') {\n validate(options);\n }\n\n this._consumes = parseOptions(\n options.consumes,\n (item, key) => {\n if (Array.isArray(item)) throw new Error('Unexpected array in options');\n //@ts-ignore\n const result: ConsumeOptions =\n item === key || !isRequiredVersion(item)\n ? // item is a request/key\n {\n import: key,\n shareScope: options.shareScope || 'default',\n shareKey: key,\n requiredVersion: undefined,\n packageName: undefined,\n strictVersion: false,\n singleton: false,\n eager: false,\n issuerLayer: undefined,\n layer: undefined,\n request: key,\n include: undefined,\n exclude: undefined,\n allowNodeModulesSuffixMatch: undefined,\n treeShakingMode: undefined,\n }\n : // key is a request/key\n // item is a version\n {\n import: key,\n shareScope: options.shareScope || 'default',\n shareKey: key,\n // webpack internal semver has some issue, use runtime semver , related issue: https://github.com/webpack/webpack/issues/17756\n requiredVersion: item,\n strictVersion: true,\n packageName: undefined,\n singleton: false,\n eager: false,\n issuerLayer: undefined,\n layer: undefined,\n request: key,\n include: undefined,\n exclude: undefined,\n allowNodeModulesSuffixMatch: undefined,\n treeShakingMode: undefined,\n };\n return result;\n },\n (item, key) => {\n const request = item.request || key;\n return {\n import: item.import === false ? undefined : item.import || request,\n shareScope: item.shareScope || options.shareScope || 'default',\n shareKey: item.shareKey || request,\n requiredVersion:\n item.requiredVersion === false\n ? false\n : // @ts-ignore webpack internal semver has some issue, use runtime semver , related issue: https://github.com/webpack/webpack/issues/17756\n (item.requiredVersion as SemVerRange),\n strictVersion:\n typeof item.strictVersion === 'boolean'\n ? item.strictVersion\n : item.import !== false && !item.singleton,\n packageName: item.packageName,\n singleton: !!item.singleton,\n eager: !!item.eager,\n exclude: item.exclude,\n include: item.include,\n issuerLayer: item.issuerLayer ? item.issuerLayer : undefined,\n layer: item.layer ? item.layer : undefined,\n request,\n allowNodeModulesSuffixMatch: item.allowNodeModulesSuffixMatch,\n treeShakingMode: item.treeShakingMode,\n } as ConsumeOptions;\n },\n );\n }\n\n createConsumeSharedModule(\n compilation: Compilation,\n context: string,\n request: string,\n config: ConsumeOptions,\n ): Promise<ConsumeSharedModule | undefined> {\n const requiredVersionWarning = (details: string) => {\n const error = new WebpackError(\n `No required version specified and unable to automatically determine one. ${details}`,\n );\n error.file = `shared module ${request}`;\n compilation.warnings.push(error);\n };\n const directFallback =\n config.import && DIRECT_FALLBACK_REGEX.test(config.import);\n const packageName =\n config.packageName ??\n (ABSOLUTE_PATH_REGEX.test(request)\n ? undefined\n : PACKAGE_NAME_REGEX.exec(request)?.[0]);\n\n const resolver: ResolverWithOptions = compilation.resolverFactory.get(\n 'normal',\n RESOLVE_OPTIONS as ResolveOptionsWithDependencyType,\n );\n\n return Promise.all([\n new Promise<string | undefined>((resolve) => {\n if (!config.import) return resolve(undefined);\n const resolveContext = {\n fileDependencies: new LazySet<string>(),\n contextDependencies: new LazySet<string>(),\n missingDependencies: new LazySet<string>(),\n };\n resolver.resolve(\n {},\n directFallback ? compilation.compiler.context : context,\n config.import,\n resolveContext,\n (err, result) => {\n compilation.contextDependencies.addAll(\n resolveContext.contextDependencies,\n );\n compilation.fileDependencies.addAll(\n resolveContext.fileDependencies,\n );\n compilation.missingDependencies.addAll(\n resolveContext.missingDependencies,\n );\n if (err) {\n compilation.errors.push(\n new ModuleNotFoundError(null, err, {\n name: `resolving fallback for shared module ${request}`,\n }),\n );\n return resolve(undefined);\n }\n //@ts-ignore\n resolve(result);\n },\n );\n }),\n new Promise<false | undefined | SemVerRange>((resolve) => {\n if (config.requiredVersion !== undefined) {\n return resolve(config.requiredVersion);\n }\n if (packageName === undefined) {\n if (!ABSOLUTE_PATH_REGEX.test(request)) {\n requiredVersionWarning(\n 'Unable to extract the package name from request.',\n );\n }\n return resolve(undefined);\n }\n\n getDescriptionFile(\n compilation.inputFileSystem,\n context,\n ['package.json'],\n (err, result, checkedDescriptionFilePaths) => {\n if (err) {\n requiredVersionWarning(`Unable to read description file: ${err}`);\n return resolve(undefined);\n }\n const { data } = /** @type {DescriptionFile} */ result || {};\n if (!data) {\n if (checkedDescriptionFilePaths?.length) {\n requiredVersionWarning(\n [\n `Unable to find required version for \"${packageName}\" in description file/s`,\n checkedDescriptionFilePaths.join('\\n'),\n 'It need to be in dependencies, devDependencies or peerDependencies.',\n ].join('\\n'),\n );\n } else {\n requiredVersionWarning(\n `Unable to find description file in ${context}.`,\n );\n }\n\n return resolve(undefined);\n }\n if (data['name'] === packageName) {\n // Package self-referencing\n return resolve(undefined);\n }\n const requiredVersion = getRequiredVersionFromDescriptionFile(\n data,\n packageName,\n );\n //TODO: align with webpck semver parser again\n // @ts-ignore webpack internal semver has some issue, use runtime semver , related issue: https://github.com/webpack/webpack/issues/17756\n resolve(requiredVersion);\n },\n (result) => {\n if (!result) return false;\n const { data } = result;\n const maybeRequiredVersion = getRequiredVersionFromDescriptionFile(\n data,\n packageName,\n );\n return (\n data['name'] === packageName ||\n typeof maybeRequiredVersion === 'string'\n );\n },\n );\n }),\n ]).then(([importResolved, requiredVersion]) => {\n const currentConfig = {\n ...config,\n importResolved,\n import: importResolved ? config.import : undefined,\n requiredVersion,\n };\n const consumedModule = new ConsumeSharedModule(\n directFallback ? compilation.compiler.context : context,\n currentConfig,\n );\n\n const { include, exclude } = config;\n if (include && typeof include.version === 'string') {\n if (!importResolved || packageName === undefined) {\n return consumedModule;\n }\n const includeVersion = include.version;\n return getPackageVersion(\n compilation.inputFileSystem,\n importResolved,\n packageName,\n ).then((version) => {\n if (!version) {\n return consumedModule;\n }\n if (satisfy(parseRange(includeVersion), version)) {\n if (config.singleton) {\n addSingletonFilterWarning(\n compilation,\n config.shareKey || request,\n 'include',\n 'version',\n includeVersion,\n request,\n importResolved,\n );\n }\n return consumedModule;\n }\n if (\n typeof include.fallbackVersion === 'string' &&\n include.fallbackVersion &&\n satisfy(parseRange(includeVersion), include.fallbackVersion)\n ) {\n return consumedModule;\n }\n return undefined;\n });\n }\n\n if (exclude && typeof exclude.version === 'string') {\n if (!importResolved) {\n return consumedModule;\n }\n const excludeVersion = exclude.version;\n if (\n typeof exclude.fallbackVersion === 'string' &&\n exclude.fallbackVersion\n ) {\n return satisfy(parseRange(excludeVersion), exclude.fallbackVersion)\n ? undefined\n : consumedModule;\n }\n if (packageName === undefined) {\n return consumedModule;\n }\n return getPackageVersion(\n compilation.inputFileSystem,\n importResolved,\n packageName,\n ).then((version) => {\n if (!version) {\n return consumedModule;\n }\n if (satisfy(parseRange(excludeVersion), version)) {\n return undefined;\n }\n if (config.singleton) {\n addSingletonFilterWarning(\n compilation,\n config.shareKey || request,\n 'exclude',\n 'version',\n excludeVersion,\n request,\n importResolved,\n );\n }\n return consumedModule;\n });\n }\n\n return consumedModule;\n });\n }\n\n apply(compiler: Compiler): void {\n new FederationRuntimePlugin().apply(compiler);\n process.env['FEDERATION_WEBPACK_PATH'] =\n process.env['FEDERATION_WEBPACK_PATH'] || getWebpackPath(compiler);\n\n compiler.hooks.thisCompilation.tap(\n PLUGIN_NAME,\n (compilation: Compilation, { normalModuleFactory }) => {\n compilation.dependencyFactories.set(\n ConsumeSharedFallbackDependency,\n normalModuleFactory,\n );\n\n let unresolvedConsumes: Map<string, ConsumeOptions>,\n resolvedConsumes: Map<string, ConsumeOptions>,\n prefixedConsumes: Map<string, ConsumeOptions>;\n const promise = resolveMatchedConfigs(compilation, this._consumes).then(\n ({ resolved, unresolved, prefixed }) => {\n resolvedConsumes = resolved;\n unresolvedConsumes = unresolved;\n prefixedConsumes = prefixed;\n },\n );\n\n normalModuleFactory.hooks.factorize.tapPromise(\n PLUGIN_NAME,\n async (resolveData: ResolveData): Promise<Module | undefined> => {\n const { context, request, dependencies, contextInfo } = resolveData;\n // wait for resolving to be complete\n // BIND `this` for createConsumeSharedModule call\n const boundCreateConsumeSharedModule =\n this.createConsumeSharedModule.bind(this);\n\n return promise.then(() => {\n if (\n dependencies[0] instanceof ConsumeSharedFallbackDependency ||\n dependencies[0] instanceof ProvideForSharedDependency\n ) {\n return;\n }\n const { context, request, contextInfo } = resolveData;\n\n const match =\n unresolvedConsumes.get(\n createLookupKeyForSharing(request, contextInfo.issuerLayer),\n ) ||\n unresolvedConsumes.get(\n createLookupKeyForSharing(request, undefined),\n );\n\n // First check direct match with original request\n if (match !== undefined) {\n // Use the bound function\n return boundCreateConsumeSharedModule(\n compilation,\n context,\n request,\n match,\n );\n }\n\n // Then try relative path handling and node_modules paths\n let reconstructed: string | null = null;\n let modulePathAfterNodeModules: string | null = null;\n\n if (\n request &&\n !path.isAbsolute(request) &&\n RELATIVE_OR_ABSOLUTE_PATH_REGEX.test(request)\n ) {\n reconstructed = path.join(context, request);\n modulePathAfterNodeModules =\n extractPathAfterNodeModules(reconstructed);\n\n // Try to match with module path after node_modules\n if (modulePathAfterNodeModules) {\n const moduleMatch =\n unresolvedConsumes.get(\n createLookupKeyForSharing(\n modulePathAfterNodeModules,\n contextInfo.issuerLayer,\n ),\n ) ||\n unresolvedConsumes.get(\n createLookupKeyForSharing(\n modulePathAfterNodeModules,\n undefined,\n ),\n );\n\n if (\n moduleMatch !== undefined &&\n moduleMatch.allowNodeModulesSuffixMatch\n ) {\n return boundCreateConsumeSharedModule(\n compilation,\n context,\n modulePathAfterNodeModules,\n moduleMatch,\n );\n }\n }\n\n // Try to match with the full reconstructed path\n const reconstructedMatch =\n unresolvedConsumes.get(\n createLookupKeyForSharing(\n reconstructed,\n contextInfo.issuerLayer,\n ),\n ) ||\n unresolvedConsumes.get(\n createLookupKeyForSharing(reconstructed, undefined),\n );\n\n if (reconstructedMatch !== undefined) {\n return boundCreateConsumeSharedModule(\n compilation,\n context,\n reconstructed,\n reconstructedMatch,\n );\n }\n }\n // Check for prefixed consumes with original request\n for (const [prefix, options] of prefixedConsumes) {\n const lookup = options.request || prefix;\n // Refined issuerLayer matching logic\n if (options.issuerLayer) {\n if (!contextInfo.issuerLayer) {\n continue; // Option is layered, request is not: skip\n }\n if (contextInfo.issuerLayer !== options.issuerLayer) {\n continue; // Both are layered but do not match: skip\n }\n }\n // If contextInfo.issuerLayer exists but options.issuerLayer does not, allow (non-layered option matches layered request)\n if (request.startsWith(lookup)) {\n const remainder = request.slice(lookup.length);\n if (\n !testRequestFilters(\n remainder,\n options.include?.request,\n options.exclude?.request,\n )\n ) {\n continue;\n }\n\n // Use the bound function\n return boundCreateConsumeSharedModule(\n compilation,\n context,\n request,\n {\n ...options,\n import: options.import\n ? options.import + remainder\n : undefined,\n shareKey: options.shareKey + remainder,\n layer: options.layer,\n },\n );\n }\n }\n\n // Also check prefixed consumes with modulePathAfterNodeModules\n if (modulePathAfterNodeModules) {\n for (const [prefix, options] of prefixedConsumes) {\n if (!options.allowNodeModulesSuffixMatch) {\n continue;\n }\n // Refined issuerLayer matching logic for reconstructed path\n if (options.issuerLayer) {\n if (!contextInfo.issuerLayer) {\n continue; // Option is layered, request is not: skip\n }\n if (contextInfo.issuerLayer !== options.issuerLayer) {\n continue; // Both are layered but do not match: skip\n }\n }\n // If contextInfo.issuerLayer exists but options.issuerLayer does not, allow (non-layered option matches layered request)\n const lookup = options.request || prefix;\n if (modulePathAfterNodeModules.startsWith(lookup)) {\n const remainder = modulePathAfterNodeModules.slice(\n lookup.length,\n );\n\n if (\n !testRequestFilters(\n remainder,\n options.include?.request,\n options.exclude?.request,\n )\n ) {\n continue;\n }\n\n return boundCreateConsumeSharedModule(\n compilation,\n context,\n modulePathAfterNodeModules,\n {\n ...options,\n import: options.import\n ? options.import + remainder\n : undefined,\n shareKey: options.shareKey + remainder,\n layer: options.layer,\n },\n );\n }\n }\n }\n\n return;\n });\n },\n );\n normalModuleFactory.hooks.createModule.tapPromise(\n PLUGIN_NAME,\n ({ resource }, { context, dependencies }) => {\n // BIND `this` for createConsumeSharedModule call\n const boundCreateConsumeSharedModule =\n this.createConsumeSharedModule.bind(this);\n if (\n dependencies[0] instanceof ConsumeSharedFallbackDependency ||\n dependencies[0] instanceof ProvideForSharedDependency\n ) {\n return Promise.resolve();\n }\n if (resource) {\n const options = resolvedConsumes.get(resource);\n if (options !== undefined) {\n // Use the bound function\n return boundCreateConsumeSharedModule(\n compilation,\n context,\n resource,\n options,\n );\n }\n }\n return Promise.resolve();\n },\n );\n\n // Add finishModules hook to copy buildMeta/buildInfo from fallback modules *after* webpack's export analysis\n // Running earlier causes failures, so we intentionally execute later than plugins like FlagDependencyExportsPlugin.\n // This still follows webpack's pattern used by FlagDependencyExportsPlugin and InferAsyncModulesPlugin, but with a\n // later stage. Based on webpack's Compilation.js: finishModules (line 2833) runs before seal (line 2920).\n compilation.hooks.finishModules.tapAsync(\n {\n name: PLUGIN_NAME,\n stage: 10, // Run after FlagDependencyExportsPlugin (default stage 0)\n },\n (modules, callback) => {\n for (const module of modules) {\n // Only process ConsumeSharedModule instances with fallback dependencies\n if (\n !(module instanceof ConsumeSharedModule) ||\n !module.options.import\n ) {\n continue;\n }\n\n let dependency;\n if (module.options.eager) {\n // For eager mode, get the fallback directly from dependencies\n dependency = module.dependencies[0];\n } else {\n // For async mode, get it from the async dependencies block\n dependency = module.blocks[0]?.dependencies[0];\n }\n\n if (dependency) {\n const fallbackModule =\n compilation.moduleGraph.getModule(dependency);\n if (\n fallbackModule &&\n fallbackModule.buildMeta &&\n fallbackModule.buildInfo\n ) {\n // Copy buildMeta and buildInfo following webpack's DelegatedModule pattern: this.buildMeta = { ...delegateData.buildMeta };\n // This ensures ConsumeSharedModule inherits ESM/CJS detection (exportsType) and other optimization metadata\n module.buildMeta = { ...fallbackModule.buildMeta };\n module.buildInfo = { ...fallbackModule.buildInfo };\n // Mark all exports as provided, to avoid webpack's export analysis from marking them as unused since we copy buildMeta\n compilation.moduleGraph\n .getExportsInfo(module)\n .setUnknownExportsProvided();\n }\n }\n }\n callback();\n },\n );\n\n compilation.hooks.additionalTreeRuntimeRequirements.tap(\n PLUGIN_NAME,\n (chunk, set) => {\n set.add(RuntimeGlobals.module);\n set.add(RuntimeGlobals.moduleCache);\n set.add(RuntimeGlobals.moduleFactoriesAddOnly);\n set.add(RuntimeGlobals.shareScopeMap);\n set.add(RuntimeGlobals.initializeSharing);\n set.add(RuntimeGlobals.hasOwnProperty);\n compilation.addRuntimeModule(\n chunk,\n new ConsumeSharedRuntimeModule(set),\n );\n // FIXME: need to remove webpack internal inject ShareRuntimeModule, otherwise there will be two ShareRuntimeModule\n compilation.addRuntimeModule(chunk, new ShareRuntimeModule());\n },\n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K,0BAA0B,KAAK,KAAK;AAC3C,QACE,aAAa,cAAcL,+DAC3B,aAAa,cAAcE,uDAE3B,QAAO,QAAQ,SAAS;AAE1B,QAAI,UAAU;KACZ,MAAM,UAAU,iBAAiB,IAAI,SAAS;AAC9C,SAAI,YAAY,OAEd,QAAO,+BACL,aACA,SACA,UACA,QACD;;AAGL,WAAO,QAAQ,SAAS;KAE3B;AAMD,eAAY,MAAM,cAAc,SAC9B;IACE,MAAM;IACN,OAAO;IACR,GACA,SAAS,aAAa;AACrB,SAAK,MAAM,UAAU,SAAS;AAE5B,SACE,EAAE,kBAAkBJ,oDACpB,CAAC,OAAO,QAAQ,OAEhB;KAGF,IAAI;AACJ,SAAI,OAAO,QAAQ,MAEjB,cAAa,OAAO,aAAa;SAGjC,cAAa,OAAO,OAAO,IAAI,aAAa;AAG9C,SAAI,YAAY;MACd,MAAM,iBACJ,YAAY,YAAY,UAAU,WAAW;AAC/C,UACE,kBACA,eAAe,aACf,eAAe,WACf;AAGA,cAAO,YAAY,EAAE,GAAG,eAAe,WAAW;AAClD,cAAO,YAAY,EAAE,GAAG,eAAe,WAAW;AAElD,mBAAY,YACT,eAAe,OAAO,CACtB,2BAA2B;;;;AAIpC,cAAU;KAEb;AAED,eAAY,MAAM,kCAAkC,IAClD,cACC,OAAO,QAAQ;AACd,QAAI,IAAI,eAAe,OAAO;AAC9B,QAAI,IAAI,eAAe,YAAY;AACnC,QAAI,IAAI,eAAe,uBAAuB;AAC9C,QAAI,IAAI,eAAe,cAAc;AACrC,QAAI,IAAI,eAAe,kBAAkB;AACzC,QAAI,IAAI,eAAe,eAAe;AACtC,gBAAY,iBACV,OACA,IAAIQ,uDAA2B,IAAI,CACpC;AAED,gBAAY,iBAAiB,OAAO,IAAIC,gDAAoB,CAAC;KAEhE;IAEJ"}
@@ -1,9 +1,9 @@
1
1
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
2
2
  const require_runtime = require('../../_virtual/_rolldown/runtime.js');
3
+ const require_lib_makeSerializable = require('../makeSerializable.js');
3
4
  let _module_federation_sdk_normalize_webpack_path = require("@module-federation/sdk/normalize-webpack-path");
4
5
 
5
6
  //#region src/lib/sharing/ProvideForSharedDependency.ts
6
- const makeSerializable = require((0, _module_federation_sdk_normalize_webpack_path.normalizeWebpackPath)("webpack/lib/util/makeSerializable"));
7
7
  const { dependencies } = require((0, _module_federation_sdk_normalize_webpack_path.normalizeWebpackPath)("webpack"));
8
8
  var ProvideForSharedDependency = class extends dependencies.ModuleDependency {
9
9
  /**
@@ -20,7 +20,7 @@ var ProvideForSharedDependency = class extends dependencies.ModuleDependency {
20
20
  return "esm";
21
21
  }
22
22
  };
23
- makeSerializable(ProvideForSharedDependency, "enhanced/lib/sharing/ProvideForSharedDependency");
23
+ require_lib_makeSerializable.default(ProvideForSharedDependency, "enhanced/lib/sharing/ProvideForSharedDependency");
24
24
 
25
25
  //#endregion
26
26
  exports.default = ProvideForSharedDependency;
@@ -1 +1 @@
1
- {"version":3,"file":"ProvideForSharedDependency.js","names":[],"sources":["../../../../src/lib/sharing/ProvideForSharedDependency.ts"],"sourcesContent":["/*\n\tMIT License http://www.opensource.org/licenses/mit-license.php\n\tAuthor Tobias Koppers @sokra, Zackary Jackson @ScriptedAlchemy\n*/\nimport { normalizeWebpackPath } from '@module-federation/sdk/normalize-webpack-path';\n\nconst makeSerializable = require(\n normalizeWebpackPath('webpack/lib/util/makeSerializable'),\n) as typeof import('webpack/lib/util/makeSerializable');\nconst { dependencies } = require(\n normalizeWebpackPath('webpack'),\n) as typeof import('webpack');\n\nclass ProvideForSharedDependency extends dependencies.ModuleDependency {\n /**\n *\n * @param request request string\n */\n constructor(request: string) {\n super(request);\n }\n\n override get type(): string {\n return 'provide module for shared';\n }\n\n override get category(): string {\n return 'esm';\n }\n}\n\nmakeSerializable(\n ProvideForSharedDependency,\n 'enhanced/lib/sharing/ProvideForSharedDependency',\n);\n\nexport default ProvideForSharedDependency;\n"],"mappings":";;;;;AAMA,MAAM,mBAAmB,gFACF,oCAAoC,CAC1D;AACD,MAAM,EAAE,iBAAiB,gFACF,UAAU,CAChC;AAED,IAAM,6BAAN,cAAyC,aAAa,iBAAiB;;;;;CAKrE,YAAY,SAAiB;AAC3B,QAAM,QAAQ;;CAGhB,IAAa,OAAe;AAC1B,SAAO;;CAGT,IAAa,WAAmB;AAC9B,SAAO;;;AAIX,iBACE,4BACA,kDACD"}
1
+ {"version":3,"file":"ProvideForSharedDependency.js","names":["makeSerializable"],"sources":["../../../../src/lib/sharing/ProvideForSharedDependency.ts"],"sourcesContent":["/*\n\tMIT License http://www.opensource.org/licenses/mit-license.php\n\tAuthor Tobias Koppers @sokra, Zackary Jackson @ScriptedAlchemy\n*/\nimport { normalizeWebpackPath } from '@module-federation/sdk/normalize-webpack-path';\n\nimport makeSerializable from '../makeSerializable';\nconst { dependencies } = require(\n normalizeWebpackPath('webpack'),\n) as typeof import('webpack');\n\nclass ProvideForSharedDependency extends dependencies.ModuleDependency {\n /**\n *\n * @param request request string\n */\n constructor(request: string) {\n super(request);\n }\n\n override get type(): string {\n return 'provide module for shared';\n }\n\n override get category(): string {\n return 'esm';\n }\n}\n\nmakeSerializable(\n ProvideForSharedDependency,\n 'enhanced/lib/sharing/ProvideForSharedDependency',\n);\n\nexport default ProvideForSharedDependency;\n"],"mappings":";;;;;;AAOA,MAAM,EAAE,iBAAiB,gFACF,UAAU,CAChC;AAED,IAAM,6BAAN,cAAyC,aAAa,iBAAiB;;;;;CAKrE,YAAY,SAAiB;AAC3B,QAAM,QAAQ;;CAGhB,IAAa,OAAe;AAC1B,SAAO;;CAGT,IAAa,WAAmB;AAC9B,SAAO;;;AAIXA,qCACE,4BACA,kDACD"}
@@ -1,9 +1,9 @@
1
1
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
2
2
  const require_runtime = require('../../_virtual/_rolldown/runtime.js');
3
+ const require_lib_makeSerializable = require('../makeSerializable.js');
3
4
  let _module_federation_sdk_normalize_webpack_path = require("@module-federation/sdk/normalize-webpack-path");
4
5
 
5
6
  //#region src/lib/sharing/ProvideSharedDependency.ts
6
- const makeSerializable = require((0, _module_federation_sdk_normalize_webpack_path.normalizeWebpackPath)("webpack/lib/util/makeSerializable"));
7
7
  const { Dependency } = require((0, _module_federation_sdk_normalize_webpack_path.normalizeWebpackPath)("webpack"));
8
8
  var ProvideSharedDependency = class ProvideSharedDependency extends Dependency {
9
9
  /**
@@ -67,7 +67,7 @@ var ProvideSharedDependency = class ProvideSharedDependency extends Dependency {
67
67
  return obj;
68
68
  }
69
69
  };
70
- makeSerializable(ProvideSharedDependency, "enhanced/lib/sharing/ProvideSharedDependency");
70
+ require_lib_makeSerializable.default(ProvideSharedDependency, "enhanced/lib/sharing/ProvideSharedDependency");
71
71
 
72
72
  //#endregion
73
73
  exports.default = ProvideSharedDependency;
@@ -1 +1 @@
1
- {"version":3,"file":"ProvideSharedDependency.js","names":[],"sources":["../../../../src/lib/sharing/ProvideSharedDependency.ts"],"sourcesContent":["/*\n MIT License http://www.opensource.org/licenses/mit-license.php\n Author Tobias Koppers @sokra, Zackary Jackson @ScriptedAlchemy\n*/\n\nimport { normalizeWebpackPath } from '@module-federation/sdk/normalize-webpack-path';\n\nconst makeSerializable = require(\n normalizeWebpackPath('webpack/lib/util/makeSerializable'),\n) as typeof import('webpack/lib/util/makeSerializable');\nconst { Dependency } = require(\n normalizeWebpackPath('webpack'),\n) as typeof import('webpack');\n\nimport type {\n ObjectDeserializerContext,\n ObjectSerializerContext,\n} from 'webpack/lib/Dependency';\n\nclass ProvideSharedDependency extends Dependency {\n shareScope: string | string[];\n name: string;\n version: string | false;\n request: string;\n eager: boolean;\n requiredVersion: string | false;\n strictVersion: boolean;\n singleton: boolean;\n layer?: string;\n treeShakingMode?: 'server-calc' | 'runtime-infer';\n\n /**\n * @param {string|string[]} shareScope share scope\n * @param {string} name module name\n * @param {string | false} version version\n * @param {string} request request\n * @param {boolean} eager true, if this is an eager dependency\n * @param {boolean} requiredVersion version requirement\n * @param {boolean} strictVersion don't use shared version even if version isn't valid\n * @param {boolean} singleton use single global version\n * @param {string} [layer] layer information\n */\n constructor(\n shareScope: string | string[],\n name: string,\n version: string | false,\n request: string,\n eager: boolean,\n requiredVersion: string | false,\n strictVersion: boolean,\n singleton: boolean,\n layer?: string,\n treeShakingMode?: 'server-calc' | 'runtime-infer',\n ) {\n super();\n this.shareScope = shareScope;\n this.name = name;\n this.version = version;\n this.request = request;\n this.eager = eager;\n this.requiredVersion = requiredVersion;\n this.strictVersion = strictVersion;\n this.singleton = singleton;\n this.layer = layer;\n this.treeShakingMode = treeShakingMode;\n }\n\n override get type(): string {\n return 'provide shared module';\n }\n\n /**\n * @returns {string | null} an identifier to merge equal requests\n */\n override getResourceIdentifier(): string | null {\n const scopeStr = Array.isArray(this.shareScope)\n ? this.shareScope.join('|')\n : this.shareScope;\n\n return `provide module (${scopeStr})${this.layer ? ` (${this.layer})` : ''} ${this.request} as ${\n this.name\n } @ ${this.version}${this.eager ? ' (eager)' : ''}`;\n }\n\n /**\n * @param {ObjectSerializerContext} context context\n */\n override serialize(context: ObjectSerializerContext): void {\n context.write(this.shareScope);\n context.write(this.name);\n context.write(this.version);\n context.write(this.request);\n context.write(this.eager);\n context.write(this.requiredVersion);\n context.write(this.strictVersion);\n context.write(this.singleton);\n context.write(this.layer);\n context.write(this.treeShakingMode);\n super.serialize(context);\n }\n\n /**\n * @param {ObjectDeserializerContext} context context\n * @returns {ProvideSharedDependency} deserialize fallback dependency\n */\n static deserialize(\n context: ObjectDeserializerContext,\n ): ProvideSharedDependency {\n const { read } = context;\n const obj = new ProvideSharedDependency(\n read(),\n read(),\n read(),\n read(),\n read(),\n read(),\n read(),\n read(),\n read(),\n read(),\n );\n // @ts-expect-error - webpack serializer pattern requires static property\n this.shareScope = context.read();\n obj.deserialize(context);\n return obj;\n }\n}\n\nmakeSerializable(\n ProvideSharedDependency,\n 'enhanced/lib/sharing/ProvideSharedD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,EACN,MAAM,EACN,MAAM,EACN,MAAM,EACN,MAAM,EACN,MAAM,CACP;AAED,OAAK,aAAa,QAAQ,MAAM;AAChC,MAAI,YAAY,QAAQ;AACxB,SAAO;;;AAIX,iBACE,yBACA,+CACD"}
1
+ {"version":3,"file":"ProvideSharedDependency.js","names":["makeSerializable"],"sources":["../../../../src/lib/sharing/ProvideSharedDependency.ts"],"sourcesContent":["/*\n MIT License http://www.opensource.org/licenses/mit-license.php\n Author Tobias Koppers @sokra, Zackary Jackson @ScriptedAlchemy\n*/\n\nimport { normalizeWebpackPath } from '@module-federation/sdk/normalize-webpack-path';\n\nimport makeSerializable from '../makeSerializable';\nconst { Dependency } = require(\n normalizeWebpackPath('webpack'),\n) as typeof import('webpack');\n\nimport type {\n ObjectDeserializerContext,\n ObjectSerializerContext,\n} from 'webpack/lib/Dependency';\n\nclass ProvideSharedDependency extends Dependency {\n shareScope: string | string[];\n name: string;\n version: string | false;\n request: string;\n eager: boolean;\n requiredVersion: string | false;\n strictVersion: boolean;\n singleton: boolean;\n layer?: string;\n treeShakingMode?: 'server-calc' | 'runtime-infer';\n\n /**\n * @param {string|string[]} shareScope share scope\n * @param {string} name module name\n * @param {string | false} version version\n * @param {string} request request\n * @param {boolean} eager true, if this is an eager dependency\n * @param {boolean} requiredVersion version requirement\n * @param {boolean} strictVersion don't use shared version even if version isn't valid\n * @param {boolean} singleton use single global version\n * @param {string} [layer] layer information\n */\n constructor(\n shareScope: string | string[],\n name: string,\n version: string | false,\n request: string,\n eager: boolean,\n requiredVersion: string | false,\n strictVersion: boolean,\n singleton: boolean,\n layer?: string,\n treeShakingMode?: 'server-calc' | 'runtime-infer',\n ) {\n super();\n this.shareScope = shareScope;\n this.name = name;\n this.version = version;\n this.request = request;\n this.eager = eager;\n this.requiredVersion = requiredVersion;\n this.strictVersion = strictVersion;\n this.singleton = singleton;\n this.layer = layer;\n this.treeShakingMode = treeShakingMode;\n }\n\n override get type(): string {\n return 'provide shared module';\n }\n\n /**\n * @returns {string | null} an identifier to merge equal requests\n */\n override getResourceIdentifier(): string | null {\n const scopeStr = Array.isArray(this.shareScope)\n ? this.shareScope.join('|')\n : this.shareScope;\n\n return `provide module (${scopeStr})${this.layer ? ` (${this.layer})` : ''} ${this.request} as ${\n this.name\n } @ ${this.version}${this.eager ? ' (eager)' : ''}`;\n }\n\n /**\n * @param {ObjectSerializerContext} context context\n */\n override serialize(context: ObjectSerializerContext): void {\n context.write(this.shareScope);\n context.write(this.name);\n context.write(this.version);\n context.write(this.request);\n context.write(this.eager);\n context.write(this.requiredVersion);\n context.write(this.strictVersion);\n context.write(this.singleton);\n context.write(this.layer);\n context.write(this.treeShakingMode);\n super.serialize(context);\n }\n\n /**\n * @param {ObjectDeserializerContext} context context\n * @returns {ProvideSharedDependency} deserialize fallback dependency\n */\n static deserialize(\n context: ObjectDeserializerContext,\n ): ProvideSharedDependency {\n const { read } = context;\n const obj = new ProvideSharedDependency(\n read(),\n read(),\n read(),\n read(),\n read(),\n read(),\n read(),\n read(),\n read(),\n read(),\n );\n // @ts-expect-error - webpack serializer pattern requires static property\n this.shareScope = context.read();\n obj.deserialize(context);\n return obj;\n }\n}\n\nmakeSerializable(\n ProvideSharedDependency,\n 'enhanced/lib/sharing/ProvideSharedDependency',\n);\n\nexport default ProvideSharedDependency;\n"],"mappings":";;;;;;AAQA,MAAM,EAAE,eAAe,gFACA,UAAU,CAChC;AAOD,IAAM,0BAAN,MAAM,gCAAgC,WAAW;;;;;;;;;;;;CAuB/C,YACE,YACA,MACA,SACA,SACA,OACA,iBACA,eACA,WACA,OACA,iBACA;AACA,SAAO;AACP,OAAK,aAAa;AAClB,OAAK,OAAO;AACZ,OAAK,UAAU;AACf,OAAK,UAAU;AACf,OAAK,QAAQ;AACb,OAAK,kBAAkB;AACvB,OAAK,gBAAgB;AACrB,OAAK,YAAY;AACjB,OAAK,QAAQ;AACb,OAAK,kBAAkB;;CAGzB,IAAa,OAAe;AAC1B,SAAO;;;;;CAMT,AAAS,wBAAuC;AAK9C,SAAO,mBAJU,MAAM,QAAQ,KAAK,WAAW,GAC3C,KAAK,WAAW,KAAK,IAAI,GACzB,KAAK,WAE0B,GAAG,KAAK,QAAQ,KAAK,KAAK,MAAM,KAAK,GAAG,GAAG,KAAK,QAAQ,MACzF,KAAK,KACN,KAAK,KAAK,UAAU,KAAK,QAAQ,aAAa;;;;;CAMjD,AAAS,UAAU,SAAwC;AACzD,UAAQ,MAAM,KAAK,WAAW;AAC9B,UAAQ,MAAM,KAAK,KAAK;AACxB,UAAQ,MAAM,KAAK,QAAQ;AAC3B,UAAQ,MAAM,KAAK,QAAQ;AAC3B,UAAQ,MAAM,KAAK,MAAM;AACzB,UAAQ,MAAM,KAAK,gBAAgB;AACnC,UAAQ,MAAM,KAAK,cAAc;AACjC,UAAQ,MAAM,KAAK,UAAU;AAC7B,UAAQ,MAAM,KAAK,MAAM;AACzB,UAAQ,MAAM,KAAK,gBAAgB;AACnC,QAAM,UAAU,QAAQ;;;;;;CAO1B,OAAO,YACL,SACyB;EACzB,MAAM,EAAE,SAAS;EACjB,MAAM,MAAM,IAAI,wBACd,MAAM,EACN,MAAM,EACN,MAAM,EACN,MAAM,EACN,MAAM,EACN,MAAM,EACN,MAAM,EACN,MAAM,EACN,MAAM,EACN,MAAM,CACP;AAED,OAAK,aAAa,QAAQ,MAAM;AAChC,MAAI,YAAY,QAAQ;AACxB,SAAO;;;AAIXA,qCACE,yBACA,+CACD"}
@@ -1,12 +1,12 @@
1
1
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
2
2
  const require_runtime = require('../../_virtual/_rolldown/runtime.js');
3
3
  const require_lib_Constants = require('../Constants.js');
4
+ const require_lib_makeSerializable = require('../makeSerializable.js');
4
5
  const require_lib_sharing_ProvideForSharedDependency = require('./ProvideForSharedDependency.js');
5
6
  let _module_federation_sdk_normalize_webpack_path = require("@module-federation/sdk/normalize-webpack-path");
6
7
 
7
8
  //#region src/lib/sharing/ProvideSharedModule.ts
8
9
  const { AsyncDependenciesBlock, Module, RuntimeGlobals } = require((0, _module_federation_sdk_normalize_webpack_path.normalizeWebpackPath)("webpack"));
9
- const makeSerializable = require((0, _module_federation_sdk_normalize_webpack_path.normalizeWebpackPath)("webpack/lib/util/makeSerializable"));
10
10
  const TYPES = new Set(["share-init"]);
11
11
  /**
12
12
  * @class
@@ -173,7 +173,7 @@ var ProvideSharedModule = class ProvideSharedModule extends Module {
173
173
  return obj;
174
174
  }
175
175
  };
176
- makeSerializable(ProvideSharedModule, "enhanced/lib/sharing/ProvideSharedModule");
176
+ require_lib_makeSerializable.default(ProvideSharedModule, "enhanced/lib/sharing/ProvideSharedModule");
177
177
 
178
178
  //#endregion
179
179
  exports.default = ProvideSharedModule;
@@ -1 +1 @@
1
- {"version":3,"file":"ProvideSharedModule.js","names":["WEBPACK_MODULE_TYPE_PROVIDE","ProvideForSharedDependency"],"sources":["../../../../src/lib/sharing/ProvideSharedModule.ts"],"sourcesContent":["/*\n MIT License http://www.opensource.org/licenses/mit-license.php\n Author Tobias Koppers @sokra and Zackary Jackson @ScriptedAlchemy\n*/\nimport { normalizeWebpackPath } from '@module-federation/sdk/normalize-webpack-path';\nimport type { Compilation } from 'webpack';\nimport type WebpackError from 'webpack/lib/WebpackError';\nimport type {\n CodeGenerationContext,\n CodeGenerationResult,\n LibIdentOptions,\n NeedBuildContext,\n RequestShortener,\n ResolverWithOptions,\n ObjectDeserializerContext,\n ObjectSerializerContext,\n} from 'webpack/lib/Module';\nimport ProvideForSharedDependency from './ProvideForSharedDependency';\nimport { WEBPACK_MODULE_TYPE_PROVIDE } from '../Constants';\nimport type { InputFileSystem } from 'webpack/lib/util/fs';\nimport type { WebpackOptionsNormalized as WebpackOptions } from 'webpack/declarations/WebpackOptions';\n\nconst { AsyncDependenciesBlock, Module, RuntimeGlobals } = require(\n normalizeWebpackPath('webpack'),\n) as typeof import('webpack');\nconst makeSerializable = require(\n normalizeWebpackPath('webpack/lib/util/makeSerializable'),\n) as typeof import('webpack/lib/util/makeSerializable');\n\nconst TYPES = new Set(['share-init']);\n\n/**\n * @class\n * @extends {Module}\n */\nclass ProvideSharedModule extends Module {\n private _shareScope: string | string[];\n private _name: string;\n private _version: string | false;\n private _request: string;\n private _eager: boolean;\n private _requiredVersion: string | false;\n private _strictVersion: boolean;\n private _singleton: boolean;\n private _treeShakingMode?: 'server-calc' | 'runtime-infer';\n\n /**\n * @constructor\n * @param {string|string[]} shareScope shared scope name\n * @param {string} name shared key\n * @param {string | false} version version\n * @param {string} request request to the provided module\n * @param {boolean} eager include the module in sync way\n * @param {boolean} requiredVersion version requirement\n * @param {boolean} strictVersion don't use shared version even if version isn't valid\n * @param {boolean} singleton use single global version\n * @param {string} [layer] layer information\n */\n constructor(\n shareScope: string | string[],\n name: string,\n version: string | false,\n request: string,\n eager: boolean,\n requiredVersion: string | false,\n strictVersion: boolean,\n singleton: boolean,\n layer?: string,\n treeShakingMode?: 'server-calc' | 'runtime-infer',\n ) {\n super(WEBPACK_MODULE_TYPE_PROVIDE, undefined, layer);\n this._shareScope = shareScope;\n this._name = name;\n this._version = version;\n this._request = request;\n this._eager = eager;\n this._requiredVersion = requiredVersion;\n this._strictVersion = strictVersion;\n this._singleton = singleton;\n this._treeShakingMode = treeShakingMode;\n }\n\n /**\n * @returns {string} a unique identifier of the module\n */\n override identifier(): string {\n return `provide module (${this._shareScope})${\n this.layer ? ` (${this.layer})` : ''\n } ${this._name}@${this._version} = ${this._request}`;\n }\n\n /**\n * @param {RequestShortener} requestShortener the request shortener\n * @returns {string} a user readable identifier of the module\n */\n override readableIdentifier(requestShortener: RequestShortener): string {\n return `provide shared module (${this._shareScope})${\n this.layer ? ` (${this.layer})` : ''\n } ${this._name}@${this._version} = ${requestShortener.shorten(this._request)}`;\n }\n\n /**\n * @param {LibIdentOptions} options options\n * @returns {string | null} an identifier for library inclusion\n */\n override libIdent(options: LibIdentOptions): string | null {\n return `${this.layer ? `(${this.layer})/` : ''}webpack/sharing/provide/${\n this._shareScope\n }/${this._name}`;\n }\n\n /**\n * @param {NeedBuildContext} context context info\n * @param {function((WebpackError | null)=, boolean=): void} callback callback function, returns true, if the module needs a rebuild\n * @returns {void}\n */\n override needBuild(\n context: NeedBuildContext,\n callback: (error?: WebpackError | null, needsRebuild?: boolean) => void,\n ): void {\n callback(null, !this.buildInfo);\n }\n\n /**\n * @param {WebpackOptions} options webpack options\n * @param {Compilation} compilation the compilation\n * @param {ResolverWithOptions} resolver the resolver\n * @param {InputFileSystem} fs the file system\n * @param {function(WebpackError=): void} callback callback function\n * @returns {void}\n */\n override build(\n options: WebpackOptions,\n compilation: Compilation,\n resolver: ResolverWithOptions,\n fs: InputFileSystem,\n callback: (error?: WebpackError) => void,\n ): void {\n this.buildMeta = {};\n this.buildInfo = {\n strict: true,\n };\n\n this.clearDependenciesAndBlocks();\n const dep = new ProvideForSharedDependency(this._request);\n if (this._eager) {\n this.addDependency(dep);\n } else {\n const block = new AsyncDependenciesBlock({});\n block.addDependency(dep);\n this.addBlock(block);\n }\n\n callback();\n }\n\n /**\n * @param {string=} type the source type for which the size should be estimated\n * @returns {number} the estimated size of the module (must be non-zero)\n */\n override size(type?: string): number {\n return 42;\n }\n\n /**\n * @returns {Set<string>} types available (do not mutate)\n */\n override getSourceTypes(): Set<string> {\n return TYPES;\n }\n\n /**\n * @param {CodeGenerationContext} context context for code generation\n * @returns {CodeGenerationResult} result\n */\n override codeGeneration({\n runtimeTemplate,\n moduleGraph,\n chunkGraph,\n }: CodeGenerationContext): CodeGenerationResult {\n const runtimeRequirements = new Set([RuntimeGlobals.initializeSharing]);\n const moduleGetter = this._eager\n ? runtimeTemplate.syncModuleFactory({\n dependency: this.dependencies[0],\n chunkGraph,\n request: this._request,\n runtimeRequirements,\n })\n : runtimeTemplate.asyncModuleFactory({\n block: this.blocks[0],\n chunkGraph,\n request: this._request,\n runtimeRequirements,\n });\n const code = `register(${JSON.stringify(this._name)}, ${JSON.stringify(\n this._version || '0',\n )}, ${moduleGetter}${this._eager ? ', 1' : ''});`;\n const sources = new Map();\n const data = new Map();\n data.set('share-init', [\n {\n shareScope: this._shareScope,\n initStage: 10,\n init: code,\n },\n ]);\n data.set('share-init-option', {\n name: this._name,\n version: JSON.stringify(this._version || '0'),\n request: this._request,\n getter: moduleGetter,\n shareScope: this._shareScope,\n shareConfig: {\n eager: this._eager,\n requiredVersion: this._requiredVersion,\n strictVersion: this._strictVersion,\n singleton: this._singleton,\n layer: this.layer,\n },\n treeShakingMode: this._treeShakingMode,\n });\n return { sources, data, runtimeRequirements };\n }\n\n /**\n * @param {ObjectSerializerContext} context context\n */\n override serialize(context: ObjectSerializerContext): void {\n const { write } = context;\n write(this._shareScope);\n write(this._name);\n write(this._version);\n write(this._request);\n write(this._eager);\n write(this._requiredVersion);\n write(this._strictVersion);\n write(this._singleton);\n write(this.layer);\n write(this._treeShakingMode);\n super.serialize(context);\n }\n\n /**\n * @param {ObjectDeserializerContext} context context\n * @returns {ProvideSharedModule} deserialize fallback dependency\n */\n static deserialize(context: ObjectDeserializerContext): ProvideSharedModule {\n const { read } = context;\n const obj = new ProvideSharedModule(\n read(),\n read(),\n read(),\n read(),\n read(),\n read(),\n read(),\n read(),\n read(),\n read(),\n );\n obj.deserialize(context);\n return obj;\n }\n}\n\nmakeSerializable(\n ProvideSharedModule,\n 'enhanced/lib/sharing/ProvideSharedModule',\n);\n\nexport default ProvideSharedModule;\n"],"mappings":";;;;;;;AAsBA,MAAM,EAAE,wBAAwB,QAAQ,mBAAmB,gFACpC,UAAU,CAChC;AACD,MAAM,mBAAmB,gFACF,oCAAoC,CAC1D;AAED,MAAM,QAAQ,IAAI,IAAI,CAAC,aAAa,CAAC;;;;;AAMrC,IAAM,sBAAN,MAAM,4BAA4B,OAAO;;;;;;;;;;;;;CAuBvC,YACE,YACA,MACA,SACA,SACA,OACA,iBACA,eACA,WACA,OACA,iBACA;AACA,QAAMA,mDAA6B,QAAW,MAAM;AACpD,OAAK,cAAc;AACnB,OAAK,QAA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AAM,EACN,MAAM,EACN,MAAM,EACN,MAAM,CACP;AACD,MAAI,YAAY,QAAQ;AACxB,SAAO;;;AAIX,iBACE,qBACA,2CACD"}
1
+ {"version":3,"file":"ProvideSharedModule.js","names":["WEBPACK_MODULE_TYPE_PROVIDE","ProvideForSharedDependency","makeSerializable"],"sources":["../../../../src/lib/sharing/ProvideSharedModule.ts"],"sourcesContent":["/*\n MIT License http://www.opensource.org/licenses/mit-license.php\n Author Tobias Koppers @sokra and Zackary Jackson @ScriptedAlchemy\n*/\nimport { normalizeWebpackPath } from '@module-federation/sdk/normalize-webpack-path';\nimport type { Compilation } from 'webpack';\nimport type WebpackError from 'webpack/lib/WebpackError';\nimport type {\n CodeGenerationContext,\n CodeGenerationResult,\n LibIdentOptions,\n NeedBuildContext,\n RequestShortener,\n ResolverWithOptions,\n ObjectDeserializerContext,\n ObjectSerializerContext,\n} from 'webpack/lib/Module';\nimport ProvideForSharedDependency from './ProvideForSharedDependency';\nimport { WEBPACK_MODULE_TYPE_PROVIDE } from '../Constants';\nimport type { InputFileSystem } from 'webpack/lib/util/fs';\nimport type { WebpackOptionsNormalized as WebpackOptions } from 'webpack/declarations/WebpackOptions';\n\nconst { AsyncDependenciesBlock, Module, RuntimeGlobals } = require(\n normalizeWebpackPath('webpack'),\n) as typeof import('webpack');\nimport makeSerializable from '../makeSerializable';\n\nconst TYPES = new Set(['share-init']);\n\n/**\n * @class\n * @extends {Module}\n */\nclass ProvideSharedModule extends Module {\n private _shareScope: string | string[];\n private _name: string;\n private _version: string | false;\n private _request: string;\n private _eager: boolean;\n private _requiredVersion: string | false;\n private _strictVersion: boolean;\n private _singleton: boolean;\n private _treeShakingMode?: 'server-calc' | 'runtime-infer';\n\n /**\n * @constructor\n * @param {string|string[]} shareScope shared scope name\n * @param {string} name shared key\n * @param {string | false} version version\n * @param {string} request request to the provided module\n * @param {boolean} eager include the module in sync way\n * @param {boolean} requiredVersion version requirement\n * @param {boolean} strictVersion don't use shared version even if version isn't valid\n * @param {boolean} singleton use single global version\n * @param {string} [layer] layer information\n */\n constructor(\n shareScope: string | string[],\n name: string,\n version: string | false,\n request: string,\n eager: boolean,\n requiredVersion: string | false,\n strictVersion: boolean,\n singleton: boolean,\n layer?: string,\n treeShakingMode?: 'server-calc' | 'runtime-infer',\n ) {\n super(WEBPACK_MODULE_TYPE_PROVIDE, undefined, layer);\n this._shareScope = shareScope;\n this._name = name;\n this._version = version;\n this._request = request;\n this._eager = eager;\n this._requiredVersion = requiredVersion;\n this._strictVersion = strictVersion;\n this._singleton = singleton;\n this._treeShakingMode = treeShakingMode;\n }\n\n /**\n * @returns {string} a unique identifier of the module\n */\n override identifier(): string {\n return `provide module (${this._shareScope})${\n this.layer ? ` (${this.layer})` : ''\n } ${this._name}@${this._version} = ${this._request}`;\n }\n\n /**\n * @param {RequestShortener} requestShortener the request shortener\n * @returns {string} a user readable identifier of the module\n */\n override readableIdentifier(requestShortener: RequestShortener): string {\n return `provide shared module (${this._shareScope})${\n this.layer ? ` (${this.layer})` : ''\n } ${this._name}@${this._version} = ${requestShortener.shorten(this._request)}`;\n }\n\n /**\n * @param {LibIdentOptions} options options\n * @returns {string | null} an identifier for library inclusion\n */\n override libIdent(options: LibIdentOptions): string | null {\n return `${this.layer ? `(${this.layer})/` : ''}webpack/sharing/provide/${\n this._shareScope\n }/${this._name}`;\n }\n\n /**\n * @param {NeedBuildContext} context context info\n * @param {function((WebpackError | null)=, boolean=): void} callback callback function, returns true, if the module needs a rebuild\n * @returns {void}\n */\n override needBuild(\n context: NeedBuildContext,\n callback: (error?: WebpackError | null, needsRebuild?: boolean) => void,\n ): void {\n callback(null, !this.buildInfo);\n }\n\n /**\n * @param {WebpackOptions} options webpack options\n * @param {Compilation} compilation the compilation\n * @param {ResolverWithOptions} resolver the resolver\n * @param {InputFileSystem} fs the file system\n * @param {function(WebpackError=): void} callback callback function\n * @returns {void}\n */\n override build(\n options: WebpackOptions,\n compilation: Compilation,\n resolver: ResolverWithOptions,\n fs: InputFileSystem,\n callback: (error?: WebpackError) => void,\n ): void {\n this.buildMeta = {};\n this.buildInfo = {\n strict: true,\n };\n\n this.clearDependenciesAndBlocks();\n const dep = new ProvideForSharedDependency(this._request);\n if (this._eager) {\n this.addDependency(dep);\n } else {\n const block = new AsyncDependenciesBlock({});\n block.addDependency(dep);\n this.addBlock(block);\n }\n\n callback();\n }\n\n /**\n * @param {string=} type the source type for which the size should be estimated\n * @returns {number} the estimated size of the module (must be non-zero)\n */\n override size(type?: string): number {\n return 42;\n }\n\n /**\n * @returns {Set<string>} types available (do not mutate)\n */\n override getSourceTypes(): Set<string> {\n return TYPES;\n }\n\n /**\n * @param {CodeGenerationContext} context context for code generation\n * @returns {CodeGenerationResult} result\n */\n override codeGeneration({\n runtimeTemplate,\n moduleGraph,\n chunkGraph,\n }: CodeGenerationContext): CodeGenerationResult {\n const runtimeRequirements = new Set([RuntimeGlobals.initializeSharing]);\n const moduleGetter = this._eager\n ? runtimeTemplate.syncModuleFactory({\n dependency: this.dependencies[0],\n chunkGraph,\n request: this._request,\n runtimeRequirements,\n })\n : runtimeTemplate.asyncModuleFactory({\n block: this.blocks[0],\n chunkGraph,\n request: this._request,\n runtimeRequirements,\n });\n const code = `register(${JSON.stringify(this._name)}, ${JSON.stringify(\n this._version || '0',\n )}, ${moduleGetter}${this._eager ? ', 1' : ''});`;\n const sources = new Map();\n const data = new Map();\n data.set('share-init', [\n {\n shareScope: this._shareScope,\n initStage: 10,\n init: code,\n },\n ]);\n data.set('share-init-option', {\n name: this._name,\n version: JSON.stringify(this._version || '0'),\n request: this._request,\n getter: moduleGetter,\n shareScope: this._shareScope,\n shareConfig: {\n eager: this._eager,\n requiredVersion: this._requiredVersion,\n strictVersion: this._strictVersion,\n singleton: this._singleton,\n layer: this.layer,\n },\n treeShakingMode: this._treeShakingMode,\n });\n return { sources, data, runtimeRequirements };\n }\n\n /**\n * @param {ObjectSerializerContext} context context\n */\n override serialize(context: ObjectSerializerContext): void {\n const { write } = context;\n write(this._shareScope);\n write(this._name);\n write(this._version);\n write(this._request);\n write(this._eager);\n write(this._requiredVersion);\n write(this._strictVersion);\n write(this._singleton);\n write(this.layer);\n write(this._treeShakingMode);\n super.serialize(context);\n }\n\n /**\n * @param {ObjectDeserializerContext} context context\n * @returns {ProvideSharedModule} deserialize fallback dependency\n */\n static deserialize(context: ObjectDeserializerContext): ProvideSharedModule {\n const { read } = context;\n const obj = new ProvideSharedModule(\n read(),\n read(),\n read(),\n read(),\n read(),\n read(),\n read(),\n read(),\n read(),\n read(),\n );\n obj.deserialize(context);\n return obj;\n }\n}\n\nmakeSerializable(\n ProvideSharedModule,\n 'enhanced/lib/sharing/ProvideSharedModule',\n);\n\nexport default ProvideSharedModule;\n"],"mappings":";;;;;;;;AAsBA,MAAM,EAAE,wBAAwB,QAAQ,mBAAmB,gFACpC,UAAU,CAChC;AAGD,MAAM,QAAQ,IAAI,IAAI,CAAC,aAAa,CAAC;;;;;AAMrC,IAAM,sBAAN,MAAM,4BAA4B,OAAO;;;;;;;;;;;;;CAuBvC,YACE,YACA,MACA,SACA,SACA,OACA,iBACA,eACA,WACA,OACA,iBACA;AACA,QAAMA,mDAA6B,QAAW,MAAM;AACpD,OAAK,cAAc;AACnB,OAAK,QAAQ;AACb,OAAK,WAAW;AAChB,OAAK,WAAW;AAChB,OAAK,SAAS;AACd,OAAK,mBAAmB;AACxB,OAAK,iBAAiB;AACtB,OAAK,aAAa;AAClB,OAAK,mBAAmB;;;;;CAM1B,AAAS,aAAqB;AAC5B,SAAO,mBAAmB,KAAK,YAAY,GACzC,KAAK,QAAQ,KAAK,KAAK,MAAM,KAAK,GACnC,GAAG,KAAK,MAAM,GAAG,KAAK,SAAS,KAAK,KAAK;;;;;;CAO5C,AAAS,mBAAmB,kBAA4C;AACtE,SAAO,0BAA0B,KAAK,YAAY,GAChD,KAAK,QAAQ,KAAK,KAAK,MAAM,KAAK,GACnC,GAAG,KAAK,MAAM,GAAG,KAAK,SAAS,KAAK,iBAAiB,QAAQ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GAC5B,MAAM,KAAK;GACX,SAAS,KAAK,UAAU,KAAK,YAAY,IAAI;GAC7C,SAAS,KAAK;GACd,QAAQ;GACR,YAAY,KAAK;GACjB,aAAa;IACX,OAAO,KAAK;IACZ,iBAAiB,KAAK;IACtB,eAAe,KAAK;IACpB,WAAW,KAAK;IAChB,OAAO,KAAK;IACb;GACD,iBAAiB,KAAK;GACvB,CAAC;AACF,SAAO;GAAE;GAAS;GAAM;GAAqB;;;;;CAM/C,AAAS,UAAU,SAAwC;EACzD,MAAM,EAAE,UAAU;AAClB,QAAM,KAAK,YAAY;AACvB,QAAM,KAAK,MAAM;AACjB,QAAM,KAAK,SAAS;AACpB,QAAM,KAAK,SAAS;AACpB,QAAM,KAAK,OAAO;AAClB,QAAM,KAAK,iBAAiB;AAC5B,QAAM,KAAK,eAAe;AAC1B,QAAM,KAAK,WAAW;AACtB,QAAM,KAAK,MAAM;AACjB,QAAM,KAAK,iBAAiB;AAC5B,QAAM,UAAU,QAAQ;;;;;;CAO1B,OAAO,YAAY,SAAyD;EAC1E,MAAM,EAAE,SAAS;EACjB,MAAM,MAAM,IAAI,oBACd,MAAM,EACN,MAAM,EACN,MAAM,EACN,MAAM,EACN,MAAM,EACN,MAAM,EACN,MAAM,EACN,MAAM,EACN,MAAM,EACN,MAAM,CACP;AACD,MAAI,YAAY,QAAQ;AACxB,SAAO;;;AAIXC,qCACE,qBACA,2CACD"}
@@ -95,13 +95,7 @@ var ProvideSharedPlugin = class {
95
95
  const actualRequest = config.request || request;
96
96
  const lookupKey = require_lib_sharing_utils.createLookupKeyForSharing(actualRequest, config.layer);
97
97
  if (/^(\/|[A-Za-z]:\\|\\\\|\.\.?(\/|$))/.test(actualRequest)) {
98
- if (this.shouldProvideSharedModule(config)) resolvedProvideMap.set(lookupKey, {
99
- config,
100
- version: config.version,
101
- resource: actualRequest
102
- });
103
- } else if (/^(\/|[A-Za-z]:\\|\\\\)/.test(actualRequest)) {
104
- if (this.shouldProvideSharedModule(config)) resolvedProvideMap.set(lookupKey, {
98
+ if (this.shouldProvideSharedModule(config) && require_lib_sharing_utils.testRequestFilters(actualRequest, config.include?.request, config.exclude?.request)) resolvedProvideMap.set(lookupKey, {
105
99
  config,
106
100
  version: config.version,
107
101
  resource: actualRequest
@@ -140,7 +134,6 @@ var ProvideSharedPlugin = class {
140
134
  ...originalPrefixConfig,
141
135
  shareKey: finalShareKey,
142
136
  request: originalRequestString,
143
- _originalPrefix: configuredPrefix,
144
137
  include: originalPrefixConfig.include ? { ...originalPrefixConfig.include } : void 0,
145
138
  exclude: originalPrefixConfig.exclude ? { ...originalPrefixConfig.exclude } : void 0
146
139
  };
@@ -154,7 +147,7 @@ var ProvideSharedPlugin = class {
154
147
  if (modulePathAfterNodeModules) {
155
148
  const reconstructedLookupKey = require_lib_sharing_utils.createLookupKeyForSharing(modulePathAfterNodeModules, moduleLayer || void 0);
156
149
  const configFromReconstructedDirect = matchProvides.get(reconstructedLookupKey);
157
- if (configFromReconstructedDirect !== void 0 && configFromReconstructedDirect.allowNodeModulesSuffixMatch && !resolvedProvideMap.has(lookupKeyForResource)) {
150
+ if (configFromReconstructedDirect !== void 0 && configFromReconstructedDirect.allowNodeModulesSuffixMatch && !resolvedProvideMap.has(lookupKeyForResource) && require_lib_sharing_utils.testRequestFilters(modulePathAfterNodeModules, configFromReconstructedDirect.include?.request, configFromReconstructedDirect.exclude?.request)) {
158
151
  this.provideSharedModule(compilation, resolvedProvideMap, modulePathAfterNodeModules, configFromReconstructedDirect, resource, resourceResolveData);
159
152
  resolveData.cacheable = false;
160
153
  }
@@ -176,7 +169,6 @@ var ProvideSharedPlugin = class {
176
169
  ...originalPrefixConfig,
177
170
  shareKey: finalShareKey,
178
171
  request: modulePathAfterNodeModules,
179
- _originalPrefix: configuredPrefix,
180
172
  include: originalPrefixConfig.include ? { ...originalPrefixConfig.include } : void 0,
181
173
  exclude: originalPrefixConfig.exclude ? { ...originalPrefixConfig.exclude } : void 0
182
174
  };
@@ -193,38 +185,11 @@ var ProvideSharedPlugin = class {
193
185
  compiler.hooks.finishMake.tapPromise("ProvideSharedPlugin", async (compilation) => {
194
186
  const resolvedProvideMap = compilationData.get(compilation);
195
187
  if (!resolvedProvideMap) return;
196
- const filteredEntries = Array.from(resolvedProvideMap).filter(([resourceKey, { config, version, resource }]) => {
197
- const actualResource = resource || resourceKey;
198
- if (config.include) {
199
- let versionIncludeFailed = false;
200
- if (typeof config.include.version === "string") if (typeof version === "string" && version) {
201
- if (!satisfy(parseRange(config.include.version), version)) versionIncludeFailed = true;
202
- } else versionIncludeFailed = true;
203
- let requestIncludeFailed = false;
204
- if (config.include.request) {
205
- const includeRequestValue = config.include.request;
206
- let testString = actualResource;
207
- if (config._originalPrefix && actualResource.startsWith(config._originalPrefix)) testString = actualResource.slice(config._originalPrefix.length);
208
- if (!(includeRequestValue instanceof RegExp ? includeRequestValue.test(testString) : testString === includeRequestValue)) requestIncludeFailed = true;
209
- }
210
- const shouldSkipVersion = typeof config.include.version === "string" && versionIncludeFailed;
211
- const shouldSkipRequest = config.include.request && requestIncludeFailed;
212
- if (shouldSkipVersion || shouldSkipRequest) return false;
213
- }
214
- if (config.exclude) {
215
- let versionExcludeMatches = false;
216
- if (typeof config.exclude.version === "string" && typeof version === "string" && version) {
217
- if (satisfy(parseRange(config.exclude.version), version)) versionExcludeMatches = true;
218
- }
219
- let requestExcludeMatches = false;
220
- if (config.exclude.request) {
221
- const excludeRequestValue = config.exclude.request;
222
- let testString = actualResource;
223
- if (config._originalPrefix && actualResource.startsWith(config._originalPrefix)) testString = actualResource.slice(config._originalPrefix.length);
224
- if (excludeRequestValue instanceof RegExp ? excludeRequestValue.test(testString) : testString === excludeRequestValue) requestExcludeMatches = true;
225
- }
226
- if (versionExcludeMatches || requestExcludeMatches) return false;
188
+ const filteredEntries = Array.from(resolvedProvideMap).filter(([, { config, version }]) => {
189
+ if (typeof config.include?.version === "string") {
190
+ if (typeof version !== "string" || !version || !satisfy(parseRange(config.include.version), version)) return false;
227
191
  }
192
+ if (typeof config.exclude?.version === "string" && typeof version === "string" && version && satisfy(parseRange(config.exclude.version), version)) return false;
228
193
  return true;
229
194
  });
230
195
  await Promise.all(filteredEntries.map(([resourceKey, { config, version, resource }]) => {
@@ -277,19 +242,10 @@ var ProvideSharedPlugin = class {
277
242
  if (typeof config.include.version === "string") if (typeof version === "string" && version) {
278
243
  if (!satisfy(parseRange(config.include.version), version)) versionIncludeFailed = true;
279
244
  } else versionIncludeFailed = true;
280
- let requestIncludeFailed = false;
281
- if (config.include.request) {
282
- const includeRequestValue = config.include.request;
283
- if (!(includeRequestValue instanceof RegExp ? includeRequestValue.test(resource) : resource === includeRequestValue)) requestIncludeFailed = true;
284
- }
285
- const shouldSkipVersion = typeof config.include.version === "string" && versionIncludeFailed;
286
- const shouldSkipRequest = config.include.request && requestIncludeFailed;
287
- if (shouldSkipVersion || shouldSkipRequest) {
288
- if (shouldSkipVersion) {
289
- const error = new WebpackError(`Provided module "${key}" version "${version}" does not satisfy include filter "${config.include.version}"`);
290
- error.file = `shared module ${key} -> ${resource}`;
291
- compilation.warnings.push(error);
292
- }
245
+ if (versionIncludeFailed) {
246
+ const error = new WebpackError(`Provided module "${key}" version "${version}" does not satisfy include filter "${config.include.version}"`);
247
+ error.file = `shared module ${key} -> ${resource}`;
248
+ compilation.warnings.push(error);
293
249
  return;
294
250
  }
295
251
  if (config.include.version && config.singleton) require_lib_sharing_utils.addSingletonFilterWarning(compilation, config.shareKey || key, "include", "version", config.include.version, key, resource);
@@ -299,17 +255,10 @@ var ProvideSharedPlugin = class {
299
255
  if (typeof config.exclude.version === "string" && typeof version === "string" && version) {
300
256
  if (satisfy(parseRange(config.exclude.version), version)) versionExcludeMatches = true;
301
257
  }
302
- let requestExcludeMatches = false;
303
- if (config.exclude.request) {
304
- const excludeRequestValue = config.exclude.request;
305
- if (excludeRequestValue instanceof RegExp ? excludeRequestValue.test(resource) : resource === excludeRequestValue) requestExcludeMatches = true;
306
- }
307
- if (versionExcludeMatches || requestExcludeMatches) {
308
- if (versionExcludeMatches) {
309
- const error = new WebpackError(`Provided module "${key}" version "${version}" matches exclude filter "${config.exclude.version}"`);
310
- error.file = `shared module ${key} -> ${resource}`;
311
- compilation.warnings.push(error);
312
- }
258
+ if (versionExcludeMatches) {
259
+ const error = new WebpackError(`Provided module "${key}" version "${version}" matches exclude filter "${config.exclude.version}"`);
260
+ error.file = `shared module ${key} -> ${resource}`;
261
+ compilation.warnings.push(error);
313
262
  return;
314
263
  }
315
264
  if (config.exclude.version && config.singleton) require_lib_sharing_utils.addSingletonFilterWarning(compilation, config.shareKey || key, "exclude", "version", config.exclude.version, key, resource);