@module-federation/enhanced 2.1.0 → 2.2.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 +2357 -0
- package/dist/README.md +213 -0
- package/dist/rstestmigrate.md +140 -0
- package/dist/src/_virtual/_rolldown/runtime.js +47 -0
- package/dist/src/index.d.ts +22 -19
- package/dist/src/index.js +47 -43
- package/dist/src/index.js.map +1 -1
- package/dist/src/lib/Constants.d.ts +25 -29
- package/dist/src/lib/Constants.js +136 -116
- package/dist/src/lib/Constants.js.map +1 -1
- package/dist/src/lib/container/AsyncBoundaryPlugin.d.ts +20 -16
- package/dist/src/lib/container/AsyncBoundaryPlugin.js +137 -200
- package/dist/src/lib/container/AsyncBoundaryPlugin.js.map +1 -1
- package/dist/src/lib/container/ContainerEntryDependency.d.ts +28 -23
- package/dist/src/lib/container/ContainerEntryDependency.js +39 -39
- package/dist/src/lib/container/ContainerEntryDependency.js.map +1 -1
- package/dist/src/lib/container/ContainerEntryModule.d.ts +93 -84
- package/dist/src/lib/container/ContainerEntryModule.js +219 -234
- package/dist/src/lib/container/ContainerEntryModule.js.map +1 -1
- package/dist/src/lib/container/ContainerEntryModuleFactory.d.ts +15 -10
- package/dist/src/lib/container/ContainerEntryModuleFactory.js +21 -25
- package/dist/src/lib/container/ContainerEntryModuleFactory.js.map +1 -1
- package/dist/src/lib/container/ContainerExposedDependency.d.ts +29 -24
- package/dist/src/lib/container/ContainerExposedDependency.js +47 -47
- package/dist/src/lib/container/ContainerExposedDependency.js.map +1 -1
- package/dist/src/lib/container/ContainerPlugin.d.ts +12 -8
- package/dist/src/lib/container/ContainerPlugin.js +147 -211
- package/dist/src/lib/container/ContainerPlugin.js.map +1 -1
- package/dist/src/lib/container/ContainerReferencePlugin.d.ts +16 -12
- package/dist/src/lib/container/ContainerReferencePlugin.js +74 -102
- package/dist/src/lib/container/ContainerReferencePlugin.js.map +1 -1
- package/dist/src/lib/container/FallbackDependency.d.ts +24 -19
- package/dist/src/lib/container/FallbackDependency.js +46 -44
- package/dist/src/lib/container/FallbackDependency.js.map +1 -1
- package/dist/src/lib/container/FallbackItemDependency.d.ts +13 -8
- package/dist/src/lib/container/FallbackItemDependency.js +24 -24
- package/dist/src/lib/container/FallbackItemDependency.js.map +1 -1
- package/dist/src/lib/container/FallbackModule.d.ts +82 -71
- package/dist/src/lib/container/FallbackModule.js +133 -145
- package/dist/src/lib/container/FallbackModule.js.map +1 -1
- package/dist/src/lib/container/FallbackModuleFactory.d.ts +15 -10
- package/dist/src/lib/container/FallbackModuleFactory.js +20 -24
- package/dist/src/lib/container/FallbackModuleFactory.js.map +1 -1
- package/dist/src/lib/container/HoistContainerReferencesPlugin.d.ts +11 -7
- package/dist/src/lib/container/HoistContainerReferencesPlugin.js +125 -188
- package/dist/src/lib/container/HoistContainerReferencesPlugin.js.map +1 -1
- package/dist/src/lib/container/ModuleFederationPlugin.d.ts +20 -16
- package/dist/src/lib/container/ModuleFederationPlugin.js +143 -181
- package/dist/src/lib/container/ModuleFederationPlugin.js.map +1 -1
- package/dist/src/lib/container/RemoteModule.d.ts +79 -74
- package/dist/src/lib/container/RemoteModule.js +143 -153
- package/dist/src/lib/container/RemoteModule.js.map +1 -1
- package/dist/src/lib/container/RemoteRuntimeModule.d.ts +12 -7
- package/dist/src/lib/container/RemoteRuntimeModule.js +86 -132
- package/dist/src/lib/container/RemoteRuntimeModule.js.map +1 -1
- package/dist/src/lib/container/RemoteToExternalDependency.d.ts +13 -8
- package/dist/src/lib/container/RemoteToExternalDependency.js +25 -23
- package/dist/src/lib/container/RemoteToExternalDependency.js.map +1 -1
- package/dist/src/lib/container/constant.d.ts +3 -0
- package/dist/src/lib/container/constant.js +11 -14
- package/dist/src/lib/container/constant.js.map +1 -1
- package/dist/src/lib/container/options.d.ts +7 -3
- package/dist/src/lib/container/options.js +51 -69
- package/dist/src/lib/container/options.js.map +1 -1
- package/dist/src/lib/container/runtime/EmbedFederationRuntimeModule.d.ts +14 -9
- package/dist/src/lib/container/runtime/EmbedFederationRuntimeModule.js +56 -64
- package/dist/src/lib/container/runtime/EmbedFederationRuntimeModule.js.map +1 -1
- package/dist/src/lib/container/runtime/EmbedFederationRuntimePlugin.d.ts +23 -19
- package/dist/src/lib/container/runtime/EmbedFederationRuntimePlugin.js +71 -101
- package/dist/src/lib/container/runtime/EmbedFederationRuntimePlugin.js.map +1 -1
- package/dist/src/lib/container/runtime/FederationModulesPlugin.d.ts +20 -16
- package/dist/src/lib/container/runtime/FederationModulesPlugin.js +55 -47
- package/dist/src/lib/container/runtime/FederationModulesPlugin.js.map +1 -1
- package/dist/src/lib/container/runtime/FederationRuntimeDependency.d.ts +9 -4
- package/dist/src/lib/container/runtime/FederationRuntimeDependency.js +16 -12
- package/dist/src/lib/container/runtime/FederationRuntimeDependency.js.map +1 -1
- package/dist/src/lib/container/runtime/FederationRuntimeModule.d.ts +16 -11
- package/dist/src/lib/container/runtime/FederationRuntimeModule.js +39 -46
- package/dist/src/lib/container/runtime/FederationRuntimeModule.js.map +1 -1
- package/dist/src/lib/container/runtime/FederationRuntimePlugin.d.ts +31 -20
- package/dist/src/lib/container/runtime/FederationRuntimePlugin.js +265 -358
- package/dist/src/lib/container/runtime/FederationRuntimePlugin.js.map +1 -1
- package/dist/src/lib/container/runtime/getFederationGlobal.d.ts +9 -4
- package/dist/src/lib/container/runtime/getFederationGlobal.js +43 -41
- package/dist/src/lib/container/runtime/getFederationGlobal.js.map +1 -1
- package/dist/src/lib/container/runtime/utils.d.ts +24 -13
- package/dist/src/lib/container/runtime/utils.js +83 -101
- package/dist/src/lib/container/runtime/utils.js.map +1 -1
- package/dist/src/lib/sharing/ConsumeSharedFallbackDependency.d.ts +15 -10
- package/dist/src/lib/sharing/ConsumeSharedFallbackDependency.js +27 -25
- package/dist/src/lib/sharing/ConsumeSharedFallbackDependency.js.map +1 -1
- package/dist/src/lib/sharing/ConsumeSharedModule.d.ts +77 -68
- package/dist/src/lib/sharing/ConsumeSharedModule.js +186 -214
- package/dist/src/lib/sharing/ConsumeSharedModule.js.map +1 -1
- package/dist/src/lib/sharing/ConsumeSharedPlugin.d.ts +13 -9
- package/dist/src/lib/sharing/ConsumeSharedPlugin.js +308 -475
- package/dist/src/lib/sharing/ConsumeSharedPlugin.js.map +1 -1
- package/dist/src/lib/sharing/ConsumeSharedRuntimeModule.d.ts +16 -11
- package/dist/src/lib/sharing/ConsumeSharedRuntimeModule.js +107 -137
- package/dist/src/lib/sharing/ConsumeSharedRuntimeModule.js.map +1 -1
- package/dist/src/lib/sharing/ProvideForSharedDependency.d.ts +14 -9
- package/dist/src/lib/sharing/ProvideForSharedDependency.js +25 -25
- package/dist/src/lib/sharing/ProvideForSharedDependency.js.map +1 -1
- package/dist/src/lib/sharing/ProvideSharedDependency.d.ts +44 -39
- package/dist/src/lib/sharing/ProvideSharedDependency.js +72 -76
- package/dist/src/lib/sharing/ProvideSharedDependency.js.map +1 -1
- package/dist/src/lib/sharing/ProvideSharedModule.d.ts +91 -82
- package/dist/src/lib/sharing/ProvideSharedModule.js +177 -184
- package/dist/src/lib/sharing/ProvideSharedModule.js.map +1 -1
- package/dist/src/lib/sharing/ProvideSharedModuleFactory.d.ts +14 -9
- package/dist/src/lib/sharing/ProvideSharedModuleFactory.js +19 -25
- package/dist/src/lib/sharing/ProvideSharedModuleFactory.js.map +1 -1
- package/dist/src/lib/sharing/ProvideSharedPlugin.d.ts +27 -21
- package/dist/src/lib/sharing/ProvideSharedPlugin.js +341 -550
- package/dist/src/lib/sharing/ProvideSharedPlugin.js.map +1 -1
- package/dist/src/lib/sharing/SharePlugin.d.ts +53 -49
- package/dist/src/lib/sharing/SharePlugin.js +86 -100
- package/dist/src/lib/sharing/SharePlugin.js.map +1 -1
- package/dist/src/lib/sharing/ShareRuntimeModule.d.ts +12 -7
- package/dist/src/lib/sharing/ShareRuntimeModule.js +81 -103
- package/dist/src/lib/sharing/ShareRuntimeModule.js.map +1 -1
- package/dist/src/lib/sharing/resolveMatchedConfigs.d.ts +11 -7
- package/dist/src/lib/sharing/resolveMatchedConfigs.js +58 -71
- package/dist/src/lib/sharing/resolveMatchedConfigs.js.map +1 -1
- package/dist/src/lib/sharing/tree-shaking/CollectSharedEntryPlugin.d.ts +18 -14
- package/dist/src/lib/sharing/tree-shaking/CollectSharedEntryPlugin.js +74 -128
- package/dist/src/lib/sharing/tree-shaking/CollectSharedEntryPlugin.js.map +1 -1
- package/dist/src/lib/sharing/tree-shaking/IndependentSharedPlugin.d.ts +39 -34
- package/dist/src/lib/sharing/tree-shaking/IndependentSharedPlugin.js +234 -328
- package/dist/src/lib/sharing/tree-shaking/IndependentSharedPlugin.js.map +1 -1
- package/dist/src/lib/sharing/tree-shaking/IndependentSharedRuntimeModule.d.ts +16 -11
- package/dist/src/lib/sharing/tree-shaking/IndependentSharedRuntimeModule.js +30 -28
- package/dist/src/lib/sharing/tree-shaking/IndependentSharedRuntimeModule.js.map +1 -1
- package/dist/src/lib/sharing/tree-shaking/SharedContainerPlugin/SharedContainerPlugin.d.ts +28 -24
- package/dist/src/lib/sharing/tree-shaking/SharedContainerPlugin/SharedContainerPlugin.js +91 -95
- package/dist/src/lib/sharing/tree-shaking/SharedContainerPlugin/SharedContainerPlugin.js.map +1 -1
- package/dist/src/lib/sharing/tree-shaking/SharedContainerPlugin/SharedDependency.d.ts +29 -24
- package/dist/src/lib/sharing/tree-shaking/SharedContainerPlugin/SharedDependency.js +47 -43
- package/dist/src/lib/sharing/tree-shaking/SharedContainerPlugin/SharedDependency.js.map +1 -1
- package/dist/src/lib/sharing/tree-shaking/SharedContainerPlugin/SharedEntryDependency.d.ts +20 -15
- package/dist/src/lib/sharing/tree-shaking/SharedContainerPlugin/SharedEntryDependency.js +33 -29
- package/dist/src/lib/sharing/tree-shaking/SharedContainerPlugin/SharedEntryDependency.js.map +1 -1
- package/dist/src/lib/sharing/tree-shaking/SharedContainerPlugin/SharedEntryModule.d.ts +85 -77
- package/dist/src/lib/sharing/tree-shaking/SharedContainerPlugin/SharedEntryModule.js +141 -153
- package/dist/src/lib/sharing/tree-shaking/SharedContainerPlugin/SharedEntryModule.js.map +1 -1
- package/dist/src/lib/sharing/tree-shaking/SharedContainerPlugin/SharedEntryModuleFactory.d.ts +15 -10
- package/dist/src/lib/sharing/tree-shaking/SharedContainerPlugin/SharedEntryModuleFactory.js +20 -24
- package/dist/src/lib/sharing/tree-shaking/SharedContainerPlugin/SharedEntryModuleFactory.js.map +1 -1
- package/dist/src/lib/sharing/tree-shaking/SharedUsedExportsOptimizerPlugin.d.ts +21 -16
- package/dist/src/lib/sharing/tree-shaking/SharedUsedExportsOptimizerPlugin.js +157 -231
- package/dist/src/lib/sharing/tree-shaking/SharedUsedExportsOptimizerPlugin.js.map +1 -1
- package/dist/src/lib/sharing/tree-shaking/SharedUsedExportsOptimizerRuntimeModule.d.ts +14 -9
- package/dist/src/lib/sharing/tree-shaking/SharedUsedExportsOptimizerRuntimeModule.js +26 -27
- package/dist/src/lib/sharing/tree-shaking/SharedUsedExportsOptimizerRuntimeModule.js.map +1 -1
- package/dist/src/lib/sharing/tree-shaking/TreeShakingSharedPlugin.d.ts +18 -13
- package/dist/src/lib/sharing/tree-shaking/TreeShakingSharedPlugin.js +41 -49
- package/dist/src/lib/sharing/tree-shaking/TreeShakingSharedPlugin.js.map +1 -1
- package/dist/src/lib/sharing/utils.d.ts +27 -24
- package/dist/src/lib/sharing/utils.js +224 -367
- package/dist/src/lib/sharing/utils.js.map +1 -1
- package/dist/src/lib/startup/MfStartupChunkDependenciesPlugin.d.ts +11 -7
- package/dist/src/lib/startup/MfStartupChunkDependenciesPlugin.js +56 -75
- package/dist/src/lib/startup/MfStartupChunkDependenciesPlugin.js.map +1 -1
- package/dist/src/lib/startup/StartupHelpers.d.ts +11 -6
- package/dist/src/lib/startup/StartupHelpers.js +128 -178
- package/dist/src/lib/startup/StartupHelpers.js.map +1 -1
- package/dist/src/prefetch.d.ts +3 -2
- package/dist/src/prefetch.js +17 -8
- package/dist/src/rspack.d.ts +3 -2
- package/dist/src/rspack.js +35 -11
- package/dist/src/runtime/AddRuntimeRequirementToPromiseExternalPlugin.d.ts +8 -4
- package/dist/src/runtime/AddRuntimeRequirementToPromiseExternalPlugin.js +19 -16
- package/dist/src/runtime/AddRuntimeRequirementToPromiseExternalPlugin.js.map +1 -1
- package/dist/src/runtime.d.ts +1 -1
- package/dist/src/runtime.js +11 -18
- package/dist/src/schemas/container/ContainerPlugin.check.d.ts +13 -5
- package/dist/src/schemas/container/ContainerPlugin.check.js +958 -1218
- package/dist/src/schemas/container/ContainerPlugin.check.js.map +1 -1
- package/dist/src/schemas/container/ContainerPlugin.d.ts +271 -268
- package/dist/src/schemas/container/ContainerPlugin.js +273 -361
- package/dist/src/schemas/container/ContainerPlugin.js.map +1 -1
- package/dist/src/schemas/container/ContainerReferencePlugin.check.d.ts +13 -5
- package/dist/src/schemas/container/ContainerReferencePlugin.check.js +335 -443
- package/dist/src/schemas/container/ContainerReferencePlugin.check.js.map +1 -1
- package/dist/src/schemas/container/ContainerReferencePlugin.d.ts +102 -99
- package/dist/src/schemas/container/ContainerReferencePlugin.js +122 -162
- package/dist/src/schemas/container/ContainerReferencePlugin.js.map +1 -1
- package/dist/src/schemas/container/ExternalsType.check.d.ts +13 -5
- package/dist/src/schemas/container/ExternalsType.check.js +36 -62
- package/dist/src/schemas/container/ExternalsType.check.js.map +1 -1
- package/dist/src/schemas/container/ExternalsType.d.ts +5 -2
- package/dist/src/schemas/container/ExternalsType.js +8 -11
- package/dist/src/schemas/container/ExternalsType.js.map +1 -1
- package/dist/src/schemas/container/ModuleFederationPlugin.check.js +3001 -4812
- package/dist/src/schemas/container/ModuleFederationPlugin.check.js.map +1 -1
- package/dist/src/schemas/container/ModuleFederationPlugin.d.ts +819 -814
- package/dist/src/schemas/container/ModuleFederationPlugin.js +780 -1053
- package/dist/src/schemas/container/ModuleFederationPlugin.js.map +1 -1
- package/dist/src/schemas/sharing/ConsumeSharedPlugin.check.d.ts +13 -5
- package/dist/src/schemas/sharing/ConsumeSharedPlugin.check.js +568 -768
- package/dist/src/schemas/sharing/ConsumeSharedPlugin.check.js.map +1 -1
- package/dist/src/schemas/sharing/ConsumeSharedPlugin.d.ts +197 -194
- package/dist/src/schemas/sharing/ConsumeSharedPlugin.js +212 -238
- package/dist/src/schemas/sharing/ConsumeSharedPlugin.js.map +1 -1
- package/dist/src/schemas/sharing/ProvideSharedPlugin.check.d.ts +13 -5
- package/dist/src/schemas/sharing/ProvideSharedPlugin.check.js +598 -804
- package/dist/src/schemas/sharing/ProvideSharedPlugin.check.js.map +1 -1
- package/dist/src/schemas/sharing/ProvideSharedPlugin.d.ts +184 -181
- package/dist/src/schemas/sharing/ProvideSharedPlugin.js +196 -229
- package/dist/src/schemas/sharing/ProvideSharedPlugin.js.map +1 -1
- package/dist/src/schemas/sharing/ProviderSharedPlugin.check.d.ts +12 -4
- package/dist/src/schemas/sharing/ProviderSharedPlugin.check.js +285 -482
- package/dist/src/schemas/sharing/ProviderSharedPlugin.check.js.map +1 -1
- package/dist/src/schemas/sharing/ProviderSharedPlugin.d.ts +103 -100
- package/dist/src/schemas/sharing/ProviderSharedPlugin.js +104 -126
- package/dist/src/schemas/sharing/ProviderSharedPlugin.js.map +1 -1
- package/dist/src/schemas/sharing/SharePlugin.check.d.ts +13 -5
- package/dist/src/schemas/sharing/SharePlugin.check.js +749 -965
- package/dist/src/schemas/sharing/SharePlugin.check.js.map +1 -1
- package/dist/src/schemas/sharing/SharePlugin.d.ts +245 -242
- package/dist/src/schemas/sharing/SharePlugin.js +256 -293
- package/dist/src/schemas/sharing/SharePlugin.js.map +1 -1
- package/dist/src/utils.d.ts +3 -0
- package/dist/src/utils.js +35 -26
- package/dist/src/utils.js.map +1 -1
- package/dist/src/webpack.d.ts +2 -2
- package/dist/src/webpack.js +6 -40
- package/dist/src/wrapper/AsyncBoundaryPlugin.d.ts +9 -4
- package/dist/src/wrapper/AsyncBoundaryPlugin.js +12 -11
- package/dist/src/wrapper/AsyncBoundaryPlugin.js.map +1 -1
- package/dist/src/wrapper/BaseWrapperPlugin.d.ts +18 -13
- package/dist/src/wrapper/BaseWrapperPlugin.js +39 -39
- package/dist/src/wrapper/BaseWrapperPlugin.js.map +1 -1
- package/dist/src/wrapper/ConsumeSharedPlugin.d.ts +10 -4
- package/dist/src/wrapper/ConsumeSharedPlugin.js +12 -11
- package/dist/src/wrapper/ConsumeSharedPlugin.js.map +1 -1
- package/dist/src/wrapper/ContainerPlugin.d.ts +9 -4
- package/dist/src/wrapper/ContainerPlugin.js +12 -11
- package/dist/src/wrapper/ContainerPlugin.js.map +1 -1
- package/dist/src/wrapper/ContainerReferencePlugin.d.ts +9 -4
- package/dist/src/wrapper/ContainerReferencePlugin.js +12 -11
- package/dist/src/wrapper/ContainerReferencePlugin.js.map +1 -1
- package/dist/src/wrapper/FederationModulesPlugin.d.ts +18 -10
- package/dist/src/wrapper/FederationModulesPlugin.js +19 -19
- package/dist/src/wrapper/FederationModulesPlugin.js.map +1 -1
- package/dist/src/wrapper/FederationRuntimePlugin.d.ts +11 -6
- package/dist/src/wrapper/FederationRuntimePlugin.js +18 -17
- package/dist/src/wrapper/FederationRuntimePlugin.js.map +1 -1
- package/dist/src/wrapper/HoistContainerReferencesPlugin.d.ts +8 -3
- package/dist/src/wrapper/HoistContainerReferencesPlugin.js +12 -11
- package/dist/src/wrapper/HoistContainerReferencesPlugin.js.map +1 -1
- package/dist/src/wrapper/ModuleFederationPlugin.d.ts +12 -7
- package/dist/src/wrapper/ModuleFederationPlugin.js +73 -99
- package/dist/src/wrapper/ModuleFederationPlugin.js.map +1 -1
- package/dist/src/wrapper/ProvideSharedPlugin.d.ts +10 -4
- package/dist/src/wrapper/ProvideSharedPlugin.js +12 -11
- package/dist/src/wrapper/ProvideSharedPlugin.js.map +1 -1
- package/dist/src/wrapper/SharePlugin.d.ts +10 -4
- package/dist/src/wrapper/SharePlugin.js +12 -11
- package/dist/src/wrapper/SharePlugin.js.map +1 -1
- package/dist/src/wrapper/TreeShakingSharedPlugin.d.ts +9 -4
- package/dist/src/wrapper/TreeShakingSharedPlugin.js +12 -11
- package/dist/src/wrapper/TreeShakingSharedPlugin.js.map +1 -1
- package/package.json +20 -13
- package/dist/package.json +0 -110
- package/dist/src/declarations/plugins/container/AsyncDependenciesBlock.d.ts +0 -57
- package/dist/src/declarations/plugins/container/ModuleFactory.d.ts +0 -33
- package/dist/src/declarations/plugins/container/ObjectDeserializerContext.d.ts +0 -4
- package/dist/src/declarations/plugins/container/StaticExportsDependency.d.ts +0 -28
- package/dist/src/declarations/plugins/container/Template.d.ts +0 -198
- package/dist/src/declarations/plugins/container/WebpackError.d.ts +0 -33
- package/dist/src/declarations/plugins/sharing/ConsumeSharedModule.d.ts +0 -86
- package/dist/src/declarations/plugins/sharing/ConsumeSharedPlugin.d.ts +0 -100
- package/dist/src/declarations/plugins/sharing/ProvideSharedPlugin.d.ts +0 -102
- package/dist/src/declarations/plugins/sharing/SharePlugin.d.ts +0 -116
- package/dist/src/lib/container/runtime/ChildCompilationRuntimePlugin.d.ts +0 -20
- package/dist/src/lib/container/runtime/ChildCompilationRuntimePlugin.js +0 -222
- package/dist/src/lib/container/runtime/ChildCompilationRuntimePlugin.js.map +0 -1
- package/dist/src/prefetch.js.map +0 -1
- package/dist/src/rspack.js.map +0 -1
- package/dist/src/runtime.js.map +0 -1
- package/dist/src/types/runtime.d.ts +0 -10
- package/dist/src/types/runtime.js +0 -3
- package/dist/src/types/runtime.js.map +0 -1
- package/dist/src/webpack.js.map +0 -1
|
@@ -1,556 +1,347 @@
|
|
|
1
|
-
/*
|
|
2
|
-
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
3
|
-
Author Tobias Koppers @sokra and Zackary Jackson @ScriptedAlchemy
|
|
4
|
-
*/
|
|
5
1
|
'use strict';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
require(
|
|
23
|
-
|
|
24
|
-
|
|
2
|
+
|
|
3
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
|
|
4
|
+
const require_runtime = require('../../_virtual/_rolldown/runtime.js');
|
|
5
|
+
const require_lib_container_options = require('../container/options.js');
|
|
6
|
+
const require_utils = require('../../utils.js');
|
|
7
|
+
const require_lib_container_runtime_FederationRuntimePlugin = require('../container/runtime/FederationRuntimePlugin.js');
|
|
8
|
+
const require_lib_sharing_utils = require('./utils.js');
|
|
9
|
+
const require_lib_sharing_ProvideForSharedDependency = require('./ProvideForSharedDependency.js');
|
|
10
|
+
const require_lib_sharing_ProvideSharedDependency = require('./ProvideSharedDependency.js');
|
|
11
|
+
const require_lib_sharing_ProvideSharedModuleFactory = require('./ProvideSharedModuleFactory.js');
|
|
12
|
+
const require_schemas_sharing_ProvideSharedPlugin_check = require('../../schemas/sharing/ProvideSharedPlugin.check.js');
|
|
13
|
+
const require_schemas_sharing_ProvideSharedPlugin = require('../../schemas/sharing/ProvideSharedPlugin.js');
|
|
14
|
+
let _module_federation_sdk_normalize_webpack_path = require("@module-federation/sdk/normalize-webpack-path");
|
|
15
|
+
|
|
16
|
+
//#region src/lib/sharing/ProvideSharedPlugin.ts
|
|
17
|
+
const { satisfy, parseRange } = require((0, _module_federation_sdk_normalize_webpack_path.normalizeWebpackPath)("webpack/lib/util/semver"));
|
|
18
|
+
const WebpackError = require((0, _module_federation_sdk_normalize_webpack_path.normalizeWebpackPath)("webpack/lib/WebpackError"));
|
|
19
|
+
const validate = require_utils.createSchemaValidation((require_schemas_sharing_ProvideSharedPlugin_check.init_ProvideSharedPlugin_check(), require_runtime.__toCommonJS(require_schemas_sharing_ProvideSharedPlugin_check.ProvideSharedPlugin_check_exports)).validate, () => (require_schemas_sharing_ProvideSharedPlugin.init_ProvideSharedPlugin(), require_runtime.__toCommonJS(require_schemas_sharing_ProvideSharedPlugin.ProvideSharedPlugin_exports)).default, {
|
|
20
|
+
name: "Provide Shared Plugin",
|
|
21
|
+
baseDataPath: "options"
|
|
25
22
|
});
|
|
26
23
|
/**
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
24
|
+
* @typedef {Object} ProvideOptions
|
|
25
|
+
* @property {string} shareKey
|
|
26
|
+
* @property {string | string[]} shareScope
|
|
27
|
+
* @property {string | undefined | false} version
|
|
28
|
+
* @property {boolean} eager
|
|
29
|
+
* @property {string} [request] The actual request to use for importing the module
|
|
30
|
+
* @property {{ version?: string; request?: string | RegExp; fallbackVersion?: string }} [exclude] Options for excluding certain versions or requests
|
|
31
|
+
* @property {{ version?: string; request?: string | RegExp; fallbackVersion?: string }} [include] Options for including only certain versions or requests
|
|
32
|
+
*/
|
|
36
33
|
/** @typedef {Map<string, { config: ProvideOptions, version: string | undefined | false }>} ResolvedProvideMap */
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
const remainder = actualResource.slice(config._originalPrefix.length);
|
|
350
|
-
testString = remainder;
|
|
351
|
-
}
|
|
352
|
-
const requestActuallyMatchesExclude = excludeRequestValue instanceof RegExp
|
|
353
|
-
? excludeRequestValue.test(testString)
|
|
354
|
-
: testString === excludeRequestValue;
|
|
355
|
-
if (requestActuallyMatchesExclude) {
|
|
356
|
-
requestExcludeMatches = true;
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
// Skip if any specified exclude condition matched
|
|
360
|
-
if (versionExcludeMatches || requestExcludeMatches) {
|
|
361
|
-
return false;
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
return true;
|
|
365
|
-
});
|
|
366
|
-
await Promise.all(filteredEntries.map(([resourceKey, { config, version, resource }]) => {
|
|
367
|
-
return new Promise((resolve, reject) => {
|
|
368
|
-
compilation.addInclude(compiler.context, new ProvideSharedDependency_1.default(config.shareScope, config.shareKey, version || false, resource || resourceKey, config.eager, config.requiredVersion, config.strictVersion, config.singleton, config.layer, config.treeShakingMode), {
|
|
369
|
-
name: undefined,
|
|
370
|
-
}, (err) => {
|
|
371
|
-
if (err) {
|
|
372
|
-
return reject(err);
|
|
373
|
-
}
|
|
374
|
-
resolve();
|
|
375
|
-
});
|
|
376
|
-
});
|
|
377
|
-
}));
|
|
378
|
-
});
|
|
379
|
-
compiler.hooks.compilation.tap('ProvideSharedPlugin', (compilation, { normalModuleFactory }) => {
|
|
380
|
-
compilation.dependencyFactories.set(ProvideForSharedDependency_1.default, normalModuleFactory);
|
|
381
|
-
compilation.dependencyFactories.set(ProvideSharedDependency_1.default, new ProvideSharedModuleFactory_1.default());
|
|
382
|
-
});
|
|
383
|
-
}
|
|
384
|
-
provideSharedModule(compilation, resolvedProvideMap, key, config, resource, resourceResolveData) {
|
|
385
|
-
let version = config.version;
|
|
386
|
-
if (version === undefined) {
|
|
387
|
-
let details = '';
|
|
388
|
-
if (!resourceResolveData) {
|
|
389
|
-
details = `No resolve data provided from resolver.`;
|
|
390
|
-
}
|
|
391
|
-
else {
|
|
392
|
-
const descriptionFileData = resourceResolveData.descriptionFileData;
|
|
393
|
-
if (!descriptionFileData) {
|
|
394
|
-
details =
|
|
395
|
-
'No description file (usually package.json) found. Add description file with name and version, or manually specify version in shared config.';
|
|
396
|
-
}
|
|
397
|
-
else if (!descriptionFileData.version) {
|
|
398
|
-
// Try to get version from parent package.json dependencies (PR7 enhanced feature)
|
|
399
|
-
if (resourceResolveData.descriptionFilePath) {
|
|
400
|
-
try {
|
|
401
|
-
// fs is now imported at the top of the file
|
|
402
|
-
const path = require('path');
|
|
403
|
-
const fs = require('fs');
|
|
404
|
-
const parentPkgPath = path.resolve(path.dirname(resourceResolveData.descriptionFilePath), '..', 'package.json');
|
|
405
|
-
if (fs.existsSync(parentPkgPath)) {
|
|
406
|
-
const parentPkg = JSON.parse(fs.readFileSync(parentPkgPath, 'utf8'));
|
|
407
|
-
const parentVersion = (0, utils_2.getRequiredVersionFromDescriptionFile)(parentPkg, key);
|
|
408
|
-
if (parentVersion) {
|
|
409
|
-
version = parentVersion;
|
|
410
|
-
details = `Using version from parent package.json dependencies: ${version}`;
|
|
411
|
-
}
|
|
412
|
-
else {
|
|
413
|
-
details = `No version in description file (usually package.json). Add version to description file ${resourceResolveData.descriptionFilePath}, or manually specify version in shared config.`;
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
else {
|
|
417
|
-
details = `No version in description file (usually package.json). Add version to description file ${resourceResolveData.descriptionFilePath}, or manually specify version in shared config.`;
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
catch (e) {
|
|
421
|
-
details = `No version in description file (usually package.json). Add version to description file ${resourceResolveData.descriptionFilePath}, or manually specify version in shared config.`;
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
else {
|
|
425
|
-
details = `No version in description file (usually package.json). Add version to description file ${resourceResolveData.descriptionFilePath}, or manually specify version in shared config.`;
|
|
426
|
-
}
|
|
427
|
-
}
|
|
428
|
-
else {
|
|
429
|
-
version = descriptionFileData.version;
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
if (!version) {
|
|
433
|
-
const error = new WebpackError(`No version specified and unable to automatically determine one. ${details}`);
|
|
434
|
-
error.file = `shared module ${key} -> ${resource}`;
|
|
435
|
-
compilation.warnings.push(error);
|
|
436
|
-
}
|
|
437
|
-
}
|
|
438
|
-
// Check include/exclude conditions
|
|
439
|
-
if (config.include) {
|
|
440
|
-
let versionIncludeFailed = false;
|
|
441
|
-
if (typeof config.include.version === 'string') {
|
|
442
|
-
if (typeof version === 'string' && version) {
|
|
443
|
-
if (!satisfy(parseRange(config.include.version), version)) {
|
|
444
|
-
versionIncludeFailed = true;
|
|
445
|
-
}
|
|
446
|
-
}
|
|
447
|
-
else {
|
|
448
|
-
versionIncludeFailed = true;
|
|
449
|
-
}
|
|
450
|
-
}
|
|
451
|
-
let requestIncludeFailed = false;
|
|
452
|
-
if (config.include.request) {
|
|
453
|
-
const includeRequestValue = config.include.request;
|
|
454
|
-
const requestActuallyMatches = includeRequestValue instanceof RegExp
|
|
455
|
-
? includeRequestValue.test(resource)
|
|
456
|
-
: resource === includeRequestValue;
|
|
457
|
-
if (!requestActuallyMatches) {
|
|
458
|
-
requestIncludeFailed = true;
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
|
-
// Skip if any specified include condition failed
|
|
462
|
-
const shouldSkipVersion = typeof config.include.version === 'string' && versionIncludeFailed;
|
|
463
|
-
const shouldSkipRequest = config.include.request && requestIncludeFailed;
|
|
464
|
-
if (shouldSkipVersion || shouldSkipRequest) {
|
|
465
|
-
// Generate warning for better debugging (combining both approaches)
|
|
466
|
-
if (shouldSkipVersion) {
|
|
467
|
-
const error = new WebpackError(`Provided module "${key}" version "${version}" does not satisfy include filter "${config.include.version}"`);
|
|
468
|
-
error.file = `shared module ${key} -> ${resource}`;
|
|
469
|
-
compilation.warnings.push(error);
|
|
470
|
-
}
|
|
471
|
-
return;
|
|
472
|
-
}
|
|
473
|
-
// Validate singleton usage when using include.version
|
|
474
|
-
if (config.include.version && config.singleton) {
|
|
475
|
-
(0, utils_2.addSingletonFilterWarning)(compilation, config.shareKey || key, 'include', 'version', config.include.version, key, // moduleRequest
|
|
476
|
-
resource);
|
|
477
|
-
}
|
|
478
|
-
}
|
|
479
|
-
if (config.exclude) {
|
|
480
|
-
let versionExcludeMatches = false;
|
|
481
|
-
if (typeof config.exclude.version === 'string' &&
|
|
482
|
-
typeof version === 'string' &&
|
|
483
|
-
version) {
|
|
484
|
-
if (satisfy(parseRange(config.exclude.version), version)) {
|
|
485
|
-
versionExcludeMatches = true;
|
|
486
|
-
}
|
|
487
|
-
}
|
|
488
|
-
let requestExcludeMatches = false;
|
|
489
|
-
if (config.exclude.request) {
|
|
490
|
-
const excludeRequestValue = config.exclude.request;
|
|
491
|
-
const requestActuallyMatchesExclude = excludeRequestValue instanceof RegExp
|
|
492
|
-
? excludeRequestValue.test(resource)
|
|
493
|
-
: resource === excludeRequestValue;
|
|
494
|
-
if (requestActuallyMatchesExclude) {
|
|
495
|
-
requestExcludeMatches = true;
|
|
496
|
-
}
|
|
497
|
-
}
|
|
498
|
-
// Skip if any specified exclude condition matched
|
|
499
|
-
if (versionExcludeMatches || requestExcludeMatches) {
|
|
500
|
-
// Generate warning for better debugging (combining both approaches)
|
|
501
|
-
if (versionExcludeMatches) {
|
|
502
|
-
const error = new WebpackError(`Provided module "${key}" version "${version}" matches exclude filter "${config.exclude.version}"`);
|
|
503
|
-
error.file = `shared module ${key} -> ${resource}`;
|
|
504
|
-
compilation.warnings.push(error);
|
|
505
|
-
}
|
|
506
|
-
return;
|
|
507
|
-
}
|
|
508
|
-
// Validate singleton usage when using exclude.version
|
|
509
|
-
if (config.exclude.version && config.singleton) {
|
|
510
|
-
(0, utils_2.addSingletonFilterWarning)(compilation, config.shareKey || key, 'exclude', 'version', config.exclude.version, key, // moduleRequest
|
|
511
|
-
resource);
|
|
512
|
-
}
|
|
513
|
-
}
|
|
514
|
-
const lookupKey = (0, utils_2.createLookupKeyForSharing)(resource, config.layer);
|
|
515
|
-
resolvedProvideMap.set(lookupKey, {
|
|
516
|
-
config,
|
|
517
|
-
version,
|
|
518
|
-
resource,
|
|
519
|
-
layer: config.layer,
|
|
520
|
-
});
|
|
521
|
-
}
|
|
522
|
-
shouldProvideSharedModule(config) {
|
|
523
|
-
// For static (relative/absolute path) modules, we can only check version filters
|
|
524
|
-
// if the version is explicitly provided in the config
|
|
525
|
-
if (!config.version) {
|
|
526
|
-
// If no version is provided and there are version filters,
|
|
527
|
-
// we'll defer to runtime filtering
|
|
528
|
-
return true;
|
|
529
|
-
}
|
|
530
|
-
const version = config.version;
|
|
531
|
-
if (typeof version !== 'string') {
|
|
532
|
-
return true;
|
|
533
|
-
}
|
|
534
|
-
// Check include version filter
|
|
535
|
-
if (config.include?.version) {
|
|
536
|
-
const includeVersion = config.include.version;
|
|
537
|
-
if (typeof includeVersion === 'string') {
|
|
538
|
-
if (!satisfy(parseRange(includeVersion), version)) {
|
|
539
|
-
return false; // Skip providing this module
|
|
540
|
-
}
|
|
541
|
-
}
|
|
542
|
-
}
|
|
543
|
-
// Check exclude version filter
|
|
544
|
-
if (config.exclude?.version) {
|
|
545
|
-
const excludeVersion = config.exclude.version;
|
|
546
|
-
if (typeof excludeVersion === 'string') {
|
|
547
|
-
if (satisfy(parseRange(excludeVersion), version)) {
|
|
548
|
-
return false; // Skip providing this module
|
|
549
|
-
}
|
|
550
|
-
}
|
|
551
|
-
}
|
|
552
|
-
return true; // All filters pass
|
|
553
|
-
}
|
|
554
|
-
}
|
|
34
|
+
var ProvideSharedPlugin = class {
|
|
35
|
+
/**
|
|
36
|
+
* @param {ProvideSharedPluginOptions} options options
|
|
37
|
+
*/
|
|
38
|
+
constructor(options) {
|
|
39
|
+
validate(options);
|
|
40
|
+
this._provides = require_lib_container_options.parseOptions(options.provides, (item) => {
|
|
41
|
+
if (Array.isArray(item)) throw new Error("Unexpected array of provides");
|
|
42
|
+
return {
|
|
43
|
+
shareKey: item,
|
|
44
|
+
version: void 0,
|
|
45
|
+
shareScope: options.shareScope || "default",
|
|
46
|
+
eager: false,
|
|
47
|
+
requiredVersion: false,
|
|
48
|
+
strictVersion: false,
|
|
49
|
+
singleton: false,
|
|
50
|
+
layer: void 0,
|
|
51
|
+
request: item,
|
|
52
|
+
exclude: void 0,
|
|
53
|
+
include: void 0,
|
|
54
|
+
allowNodeModulesSuffixMatch: false,
|
|
55
|
+
treeShakingMode: void 0
|
|
56
|
+
};
|
|
57
|
+
}, (item, key) => {
|
|
58
|
+
const request = item.request || key;
|
|
59
|
+
return {
|
|
60
|
+
shareScope: item.shareScope || options.shareScope || "default",
|
|
61
|
+
shareKey: item.shareKey || request,
|
|
62
|
+
version: item.version,
|
|
63
|
+
eager: !!item.eager,
|
|
64
|
+
requiredVersion: item.requiredVersion,
|
|
65
|
+
strictVersion: item.strictVersion,
|
|
66
|
+
singleton: !!item.singleton,
|
|
67
|
+
layer: item.layer,
|
|
68
|
+
request,
|
|
69
|
+
exclude: item.exclude,
|
|
70
|
+
include: item.include,
|
|
71
|
+
allowNodeModulesSuffixMatch: !!item.allowNodeModulesSuffixMatch,
|
|
72
|
+
treeShakingMode: item.treeShakingMode
|
|
73
|
+
};
|
|
74
|
+
});
|
|
75
|
+
this._provides.sort(([a], [b]) => {
|
|
76
|
+
if (a < b) return -1;
|
|
77
|
+
if (b < a) return 1;
|
|
78
|
+
return 0;
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Apply the plugin
|
|
83
|
+
* @param {Compiler} compiler the compiler instance
|
|
84
|
+
* @returns {void}
|
|
85
|
+
*/
|
|
86
|
+
apply(compiler) {
|
|
87
|
+
new require_lib_container_runtime_FederationRuntimePlugin.default().apply(compiler);
|
|
88
|
+
process.env["FEDERATION_WEBPACK_PATH"] = process.env["FEDERATION_WEBPACK_PATH"] || (0, _module_federation_sdk_normalize_webpack_path.getWebpackPath)(compiler);
|
|
89
|
+
const compilationData = /* @__PURE__ */ new WeakMap();
|
|
90
|
+
compiler.hooks.compilation.tap("ProvideSharedPlugin", (compilation, { normalModuleFactory }) => {
|
|
91
|
+
const resolvedProvideMap = /* @__PURE__ */ new Map();
|
|
92
|
+
const matchProvides = /* @__PURE__ */ new Map();
|
|
93
|
+
const prefixMatchProvides = /* @__PURE__ */ new Map();
|
|
94
|
+
for (const [request, config] of this._provides) {
|
|
95
|
+
const actualRequest = config.request || request;
|
|
96
|
+
const lookupKey = require_lib_sharing_utils.createLookupKeyForSharing(actualRequest, config.layer);
|
|
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, {
|
|
105
|
+
config,
|
|
106
|
+
version: config.version,
|
|
107
|
+
resource: actualRequest
|
|
108
|
+
});
|
|
109
|
+
} else if (actualRequest.endsWith("/")) prefixMatchProvides.set(lookupKey, config);
|
|
110
|
+
else matchProvides.set(lookupKey, config);
|
|
111
|
+
}
|
|
112
|
+
compilationData.set(compilation, resolvedProvideMap);
|
|
113
|
+
normalModuleFactory.hooks.module.tap("ProvideSharedPlugin", (module, { resource, resourceResolveData }, resolveData) => {
|
|
114
|
+
const moduleLayer = module.layer;
|
|
115
|
+
const lookupKeyForResource = require_lib_sharing_utils.createLookupKeyForSharing(resource || "", moduleLayer || void 0);
|
|
116
|
+
if (resource && resolvedProvideMap.has(lookupKeyForResource)) return module;
|
|
117
|
+
const { request: originalRequestString } = resolveData;
|
|
118
|
+
const originalRequestLookupKey = require_lib_sharing_utils.createLookupKeyForSharing(originalRequestString, moduleLayer || void 0);
|
|
119
|
+
const configFromOriginalDirect = matchProvides.get(originalRequestLookupKey);
|
|
120
|
+
if (configFromOriginalDirect !== void 0 && resource && !resolvedProvideMap.has(lookupKeyForResource)) {
|
|
121
|
+
if (require_lib_sharing_utils.testRequestFilters(originalRequestString, configFromOriginalDirect.include?.request, configFromOriginalDirect.exclude?.request)) {
|
|
122
|
+
this.provideSharedModule(compilation, resolvedProvideMap, originalRequestString, configFromOriginalDirect, resource, resourceResolveData);
|
|
123
|
+
resolveData.cacheable = false;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
if (resource && !resolvedProvideMap.has(lookupKeyForResource)) for (const [prefixLookupKey, originalPrefixConfig] of prefixMatchProvides) {
|
|
127
|
+
const configuredPrefix = originalPrefixConfig.request || prefixLookupKey.split("?")[0];
|
|
128
|
+
if (originalPrefixConfig.layer) {
|
|
129
|
+
if (!moduleLayer) continue;
|
|
130
|
+
if (moduleLayer !== originalPrefixConfig.layer) continue;
|
|
131
|
+
}
|
|
132
|
+
if (originalRequestString.startsWith(configuredPrefix)) {
|
|
133
|
+
if (resolvedProvideMap.has(lookupKeyForResource)) continue;
|
|
134
|
+
const remainder = originalRequestString.slice(configuredPrefix.length);
|
|
135
|
+
if (!require_lib_sharing_utils.testRequestFilters(remainder, originalPrefixConfig.include?.request, originalPrefixConfig.exclude?.request)) continue;
|
|
136
|
+
const finalShareKey = originalPrefixConfig.shareKey ? originalPrefixConfig.shareKey + remainder : configuredPrefix + remainder;
|
|
137
|
+
if (originalPrefixConfig.include?.request && originalPrefixConfig.singleton) require_lib_sharing_utils.addSingletonFilterWarning(compilation, finalShareKey, "include", "request", originalPrefixConfig.include.request, originalRequestString, resource);
|
|
138
|
+
if (originalPrefixConfig.exclude?.request && originalPrefixConfig.singleton) require_lib_sharing_utils.addSingletonFilterWarning(compilation, finalShareKey, "exclude", "request", originalPrefixConfig.exclude.request, originalRequestString, resource);
|
|
139
|
+
const configForSpecificModule = {
|
|
140
|
+
...originalPrefixConfig,
|
|
141
|
+
shareKey: finalShareKey,
|
|
142
|
+
request: originalRequestString,
|
|
143
|
+
_originalPrefix: configuredPrefix,
|
|
144
|
+
include: originalPrefixConfig.include ? { ...originalPrefixConfig.include } : void 0,
|
|
145
|
+
exclude: originalPrefixConfig.exclude ? { ...originalPrefixConfig.exclude } : void 0
|
|
146
|
+
};
|
|
147
|
+
this.provideSharedModule(compilation, resolvedProvideMap, originalRequestString, configForSpecificModule, resource, resourceResolveData);
|
|
148
|
+
resolveData.cacheable = false;
|
|
149
|
+
break;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
if (resource && !resolvedProvideMap.has(lookupKeyForResource)) {
|
|
153
|
+
const modulePathAfterNodeModules = require_lib_sharing_utils.extractPathAfterNodeModules(resource);
|
|
154
|
+
if (modulePathAfterNodeModules) {
|
|
155
|
+
const reconstructedLookupKey = require_lib_sharing_utils.createLookupKeyForSharing(modulePathAfterNodeModules, moduleLayer || void 0);
|
|
156
|
+
const configFromReconstructedDirect = matchProvides.get(reconstructedLookupKey);
|
|
157
|
+
if (configFromReconstructedDirect !== void 0 && configFromReconstructedDirect.allowNodeModulesSuffixMatch && !resolvedProvideMap.has(lookupKeyForResource)) {
|
|
158
|
+
this.provideSharedModule(compilation, resolvedProvideMap, modulePathAfterNodeModules, configFromReconstructedDirect, resource, resourceResolveData);
|
|
159
|
+
resolveData.cacheable = false;
|
|
160
|
+
}
|
|
161
|
+
if (resource && !resolvedProvideMap.has(lookupKeyForResource)) for (const [prefixLookupKey, originalPrefixConfig] of prefixMatchProvides) {
|
|
162
|
+
if (!originalPrefixConfig.allowNodeModulesSuffixMatch) continue;
|
|
163
|
+
const configuredPrefix = originalPrefixConfig.request || prefixLookupKey.split("?")[0];
|
|
164
|
+
if (originalPrefixConfig.layer) {
|
|
165
|
+
if (!moduleLayer) continue;
|
|
166
|
+
if (moduleLayer !== originalPrefixConfig.layer) continue;
|
|
167
|
+
}
|
|
168
|
+
if (modulePathAfterNodeModules.startsWith(configuredPrefix)) {
|
|
169
|
+
if (resolvedProvideMap.has(lookupKeyForResource)) continue;
|
|
170
|
+
const remainder = modulePathAfterNodeModules.slice(configuredPrefix.length);
|
|
171
|
+
if (!require_lib_sharing_utils.testRequestFilters(remainder, originalPrefixConfig.include?.request, originalPrefixConfig.exclude?.request)) continue;
|
|
172
|
+
const finalShareKey = originalPrefixConfig.shareKey ? originalPrefixConfig.shareKey + remainder : configuredPrefix + remainder;
|
|
173
|
+
if (originalPrefixConfig.include?.request && originalPrefixConfig.singleton) require_lib_sharing_utils.addSingletonFilterWarning(compilation, finalShareKey, "include", "request", originalPrefixConfig.include.request, modulePathAfterNodeModules, resource);
|
|
174
|
+
if (originalPrefixConfig.exclude?.request && originalPrefixConfig.singleton) require_lib_sharing_utils.addSingletonFilterWarning(compilation, finalShareKey, "exclude", "request", originalPrefixConfig.exclude.request, modulePathAfterNodeModules, resource);
|
|
175
|
+
const configForSpecificModule = {
|
|
176
|
+
...originalPrefixConfig,
|
|
177
|
+
shareKey: finalShareKey,
|
|
178
|
+
request: modulePathAfterNodeModules,
|
|
179
|
+
_originalPrefix: configuredPrefix,
|
|
180
|
+
include: originalPrefixConfig.include ? { ...originalPrefixConfig.include } : void 0,
|
|
181
|
+
exclude: originalPrefixConfig.exclude ? { ...originalPrefixConfig.exclude } : void 0
|
|
182
|
+
};
|
|
183
|
+
this.provideSharedModule(compilation, resolvedProvideMap, modulePathAfterNodeModules, configForSpecificModule, resource, resourceResolveData);
|
|
184
|
+
resolveData.cacheable = false;
|
|
185
|
+
break;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
return module;
|
|
191
|
+
});
|
|
192
|
+
});
|
|
193
|
+
compiler.hooks.finishMake.tapPromise("ProvideSharedPlugin", async (compilation) => {
|
|
194
|
+
const resolvedProvideMap = compilationData.get(compilation);
|
|
195
|
+
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;
|
|
227
|
+
}
|
|
228
|
+
return true;
|
|
229
|
+
});
|
|
230
|
+
await Promise.all(filteredEntries.map(([resourceKey, { config, version, resource }]) => {
|
|
231
|
+
return new Promise((resolve, reject) => {
|
|
232
|
+
compilation.addInclude(compiler.context, new require_lib_sharing_ProvideSharedDependency.default(config.shareScope, config.shareKey, version || false, resource || resourceKey, config.eager, config.requiredVersion, config.strictVersion, config.singleton, config.layer, config.treeShakingMode), { name: void 0 }, (err) => {
|
|
233
|
+
if (err) return reject(err);
|
|
234
|
+
resolve();
|
|
235
|
+
});
|
|
236
|
+
});
|
|
237
|
+
}));
|
|
238
|
+
});
|
|
239
|
+
compiler.hooks.compilation.tap("ProvideSharedPlugin", (compilation, { normalModuleFactory }) => {
|
|
240
|
+
compilation.dependencyFactories.set(require_lib_sharing_ProvideForSharedDependency.default, normalModuleFactory);
|
|
241
|
+
compilation.dependencyFactories.set(require_lib_sharing_ProvideSharedDependency.default, new require_lib_sharing_ProvideSharedModuleFactory.default());
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
provideSharedModule(compilation, resolvedProvideMap, key, config, resource, resourceResolveData) {
|
|
245
|
+
let version = config.version;
|
|
246
|
+
if (version === void 0) {
|
|
247
|
+
let details = "";
|
|
248
|
+
if (!resourceResolveData) details = `No resolve data provided from resolver.`;
|
|
249
|
+
else {
|
|
250
|
+
const descriptionFileData = resourceResolveData.descriptionFileData;
|
|
251
|
+
if (!descriptionFileData) details = "No description file (usually package.json) found. Add description file with name and version, or manually specify version in shared config.";
|
|
252
|
+
else if (!descriptionFileData.version) if (resourceResolveData.descriptionFilePath) try {
|
|
253
|
+
const path = require("path");
|
|
254
|
+
const fs = require("fs");
|
|
255
|
+
const parentPkgPath = path.resolve(path.dirname(resourceResolveData.descriptionFilePath), "..", "package.json");
|
|
256
|
+
if (fs.existsSync(parentPkgPath)) {
|
|
257
|
+
const parentVersion = require_lib_sharing_utils.getRequiredVersionFromDescriptionFile(JSON.parse(fs.readFileSync(parentPkgPath, "utf8")), key);
|
|
258
|
+
if (parentVersion) {
|
|
259
|
+
version = parentVersion;
|
|
260
|
+
details = `Using version from parent package.json dependencies: ${version}`;
|
|
261
|
+
} else details = `No version in description file (usually package.json). Add version to description file ${resourceResolveData.descriptionFilePath}, or manually specify version in shared config.`;
|
|
262
|
+
} else details = `No version in description file (usually package.json). Add version to description file ${resourceResolveData.descriptionFilePath}, or manually specify version in shared config.`;
|
|
263
|
+
} catch (e) {
|
|
264
|
+
details = `No version in description file (usually package.json). Add version to description file ${resourceResolveData.descriptionFilePath}, or manually specify version in shared config.`;
|
|
265
|
+
}
|
|
266
|
+
else details = `No version in description file (usually package.json). Add version to description file ${resourceResolveData.descriptionFilePath}, or manually specify version in shared config.`;
|
|
267
|
+
else version = descriptionFileData.version;
|
|
268
|
+
}
|
|
269
|
+
if (!version) {
|
|
270
|
+
const error = new WebpackError(`No version specified and unable to automatically determine one. ${details}`);
|
|
271
|
+
error.file = `shared module ${key} -> ${resource}`;
|
|
272
|
+
compilation.warnings.push(error);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
if (config.include) {
|
|
276
|
+
let versionIncludeFailed = false;
|
|
277
|
+
if (typeof config.include.version === "string") if (typeof version === "string" && version) {
|
|
278
|
+
if (!satisfy(parseRange(config.include.version), version)) versionIncludeFailed = true;
|
|
279
|
+
} 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
|
+
}
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
295
|
+
if (config.include.version && config.singleton) require_lib_sharing_utils.addSingletonFilterWarning(compilation, config.shareKey || key, "include", "version", config.include.version, key, resource);
|
|
296
|
+
}
|
|
297
|
+
if (config.exclude) {
|
|
298
|
+
let versionExcludeMatches = false;
|
|
299
|
+
if (typeof config.exclude.version === "string" && typeof version === "string" && version) {
|
|
300
|
+
if (satisfy(parseRange(config.exclude.version), version)) versionExcludeMatches = true;
|
|
301
|
+
}
|
|
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
|
+
}
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
if (config.exclude.version && config.singleton) require_lib_sharing_utils.addSingletonFilterWarning(compilation, config.shareKey || key, "exclude", "version", config.exclude.version, key, resource);
|
|
316
|
+
}
|
|
317
|
+
const lookupKey = require_lib_sharing_utils.createLookupKeyForSharing(resource, config.layer);
|
|
318
|
+
resolvedProvideMap.set(lookupKey, {
|
|
319
|
+
config,
|
|
320
|
+
version,
|
|
321
|
+
resource,
|
|
322
|
+
layer: config.layer
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
shouldProvideSharedModule(config) {
|
|
326
|
+
if (!config.version) return true;
|
|
327
|
+
const version = config.version;
|
|
328
|
+
if (typeof version !== "string") return true;
|
|
329
|
+
if (config.include?.version) {
|
|
330
|
+
const includeVersion = config.include.version;
|
|
331
|
+
if (typeof includeVersion === "string") {
|
|
332
|
+
if (!satisfy(parseRange(includeVersion), version)) return false;
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
if (config.exclude?.version) {
|
|
336
|
+
const excludeVersion = config.exclude.version;
|
|
337
|
+
if (typeof excludeVersion === "string") {
|
|
338
|
+
if (satisfy(parseRange(excludeVersion), version)) return false;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
return true;
|
|
342
|
+
}
|
|
343
|
+
};
|
|
344
|
+
|
|
345
|
+
//#endregion
|
|
555
346
|
exports.default = ProvideSharedPlugin;
|
|
556
347
|
//# sourceMappingURL=ProvideSharedPlugin.js.map
|