@module-federation/enhanced 2.8.2 → 2.9.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 +17 -0
- package/dist/src/lib/container/ModuleFederationPlugin.js.map +1 -1
- package/dist/src/lib/container/RemoteRuntimeModule.js.map +1 -1
- package/dist/src/lib/sharing/tree-shaking/IndependentSharedPlugin.js +2 -10
- package/dist/src/lib/sharing/tree-shaking/IndependentSharedPlugin.js.map +1 -1
- package/package.json +12 -12
package/dist/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @module-federation/enhanced
|
|
2
2
|
|
|
3
|
+
## 2.9.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [df8b40f]
|
|
8
|
+
- @module-federation/webpack-bundler-runtime@2.9.0
|
|
9
|
+
- @module-federation/dts-plugin@2.9.0
|
|
10
|
+
- @module-federation/runtime-tools@2.9.0
|
|
11
|
+
- @module-federation/rspack@2.9.0
|
|
12
|
+
- @module-federation/inject-external-runtime-core-plugin@2.9.0
|
|
13
|
+
- @module-federation/sdk@2.9.0
|
|
14
|
+
- @module-federation/managers@2.9.0
|
|
15
|
+
- @module-federation/manifest@2.9.0
|
|
16
|
+
- @module-federation/bridge-react-webpack-plugin@2.9.0
|
|
17
|
+
- @module-federation/error-codes@2.9.0
|
|
18
|
+
- @module-federation/cli@2.9.0
|
|
19
|
+
|
|
3
20
|
## 2.8.2
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModuleFederationPlugin.js","names":["createSchemaValidation","path","fs","utils","infrastructureLogger","RemoteEntryPlugin","FederationModulesPlugin","StartupChunkDependenciesPlugin","DtsPlugin","FederationRuntimePlugin","ContainerManager","ContainerPlugin","ContainerReferencePlugin","TreeShakingSharedPlugin","SharePlugin","StatsPlugin"],"sources":["../../../../src/lib/container/ModuleFederationPlugin.ts"],"sourcesContent":["/*\n MIT License http://www.opensource.org/licenses/mit-license.php\n Author Tobias Koppers @sokra and Zackary Jackson @ScriptedAlchemy\n*/\n\n'use strict';\nimport { DtsPlugin } from '@module-federation/dts-plugin';\nimport { ContainerManager, utils } from '@module-federation/managers';\nimport { StatsPlugin } from '@module-federation/manifest';\nimport {\n bindLoggerToCompiler,\n composeKeyWithSeparator,\n type moduleFederationPlugin,\n infrastructureLogger,\n} from '@module-federation/sdk';\nimport { normalizeWebpackPath } from '@module-federation/sdk/normalize-webpack-path';\nimport type { Compiler, WebpackPluginInstance } from 'webpack';\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport SharePlugin from '../sharing/SharePlugin';\nimport ContainerPlugin from './ContainerPlugin';\nimport ContainerReferencePlugin from './ContainerReferencePlugin';\nimport FederationRuntimePlugin from './runtime/FederationRuntimePlugin';\nimport { RemoteEntryPlugin } from '@module-federation/rspack/remote-entry-plugin';\nimport StartupChunkDependenciesPlugin from '../startup/MfStartupChunkDependenciesPlugin';\nimport FederationModulesPlugin from './runtime/FederationModulesPlugin';\nimport { createSchemaValidation } from '../../utils';\nimport TreeShakingSharedPlugin from '../sharing/tree-shaking/TreeShakingSharedPlugin';\n\nconst isValidExternalsType = require(\n normalizeWebpackPath(\n 'webpack/schemas/plugins/container/ExternalsType.check.js',\n ),\n) as typeof import('webpack/schemas/plugins/container/ExternalsType.check.js');\n\nconst { ExternalsPlugin } = require(\n normalizeWebpackPath('webpack'),\n) as typeof import('webpack');\n\nconst validate = createSchemaValidation(\n //eslint-disable-next-line\n require('../../schemas/container/ModuleFederationPlugin.check.js').validate,\n () => require('../../schemas/container/ModuleFederationPlugin').default,\n {\n name: 'Module Federation Plugin',\n baseDataPath: 'options',\n },\n);\n\nfunction hasExposes(\n exposes: moduleFederationPlugin.ModuleFederationPluginOptions['exposes'],\n): boolean {\n return Boolean(\n exposes &&\n (Array.isArray(exposes)\n ? exposes.length > 0\n : Object.keys(exposes).length > 0),\n );\n}\n\nfunction getEnhancedPackageVersion(): string {\n let currentDir = __dirname;\n\n while (true) {\n const packageJsonPath = path.join(currentDir, 'package.json');\n\n if (fs.existsSync(packageJsonPath)) {\n const pkg = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8')) as {\n name?: string;\n version?: string;\n };\n\n if (pkg.name === '@module-federation/enhanced' && pkg.version) {\n return pkg.version;\n }\n }\n\n const parentDir = path.dirname(currentDir);\n if (parentDir === currentDir) {\n break;\n }\n currentDir = parentDir;\n }\n\n throw new Error('Unable to resolve @module-federation/enhanced package.json');\n}\n\nclass ModuleFederationPlugin implements WebpackPluginInstance {\n private _options: moduleFederationPlugin.ModuleFederationPluginOptions;\n private _statsPlugin?: StatsPlugin;\n /**\n * @param {moduleFederationPlugin.ModuleFederationPluginOptions} options options\n */\n constructor(options: moduleFederationPlugin.ModuleFederationPluginOptions) {\n validate(options);\n this._options = options;\n }\n\n private _patchBundlerConfig(compiler: Compiler): void {\n const { name, experiments, exposes } = this._options;\n const definePluginOptions: Record<string, string | boolean> = {};\n\n const MFPluginNum = compiler.options.plugins.filter(\n (p): p is WebpackPluginInstance =>\n !!p && (p as any).name === 'ModuleFederationPlugin',\n ).length;\n\n if (name && MFPluginNum < 2) {\n definePluginOptions['FEDERATION_BUILD_IDENTIFIER'] = JSON.stringify(\n composeKeyWithSeparator(name, utils.getBuildVersion()),\n );\n }\n\n const disableSnapshot = experiments?.optimization?.disableSnapshot ?? false;\n definePluginOptions['FEDERATION_OPTIMIZE_NO_SNAPSHOT_PLUGIN'] =\n disableSnapshot;\n definePluginOptions['FEDERATION_OPTIMIZE_NO_REMOTE'] =\n experiments?.optimization?.disableRemote ?? false;\n definePluginOptions['FEDERATION_OPTIMIZE_NO_SHARED'] =\n experiments?.optimization?.disableShared ?? false;\n definePluginOptions['FEDERATION_HAS_EXPOSES'] =\n hasExposes(exposes) ||\n compiler.options.plugins.some((plugin) => {\n if (!plugin || typeof plugin !== 'object') {\n return false;\n }\n\n const namedPlugin = plugin as WebpackPluginInstance & {\n name?: string;\n _options?: moduleFederationPlugin.ModuleFederationPluginOptions;\n };\n if (namedPlugin.name !== 'ModuleFederationPlugin') {\n return false;\n }\n\n return hasExposes(namedPlugin._options?.exposes);\n });\n\n // Determine ENV_TARGET: only if manually specified in experiments.optimization.target\n if (\n experiments?.optimization &&\n typeof experiments.optimization === 'object' &&\n experiments.optimization !== null &&\n 'target' in experiments.optimization\n ) {\n const manualTarget = experiments.optimization.target as\n | 'web'\n | 'node'\n | undefined;\n // Ensure the target is one of the expected values before setting\n if (manualTarget === 'web' || manualTarget === 'node') {\n definePluginOptions['ENV_TARGET'] = JSON.stringify(manualTarget);\n }\n }\n // No inference for ENV_TARGET. If not manually set and valid, it's not defined.\n\n new compiler.webpack.DefinePlugin(definePluginOptions).apply(compiler);\n }\n\n /**\n * Apply the plugin\n * @param {Compiler} compiler the compiler instance\n * @returns {void}\n */\n apply(compiler: Compiler): void {\n bindLoggerToCompiler(\n infrastructureLogger,\n compiler,\n 'EnhancedModuleFederationPlugin',\n );\n const { _options: options } = this;\n const { name, experiments, dts, remotes, shared, shareScope } = options;\n if (!name) {\n // TODO: remove the comment\n throw new Error('ModuleFederationPlugin name is required');\n }\n // must before ModuleFederationPlugin\n (new RemoteEntryPlugin(options) as unknown as WebpackPluginInstance).apply(\n compiler,\n );\n const useContainerPlugin = hasExposes(options.exposes);\n\n if (experiments?.provideExternalRuntime) {\n if (useContainerPlugin) {\n throw new Error(\n 'You can only set provideExternalRuntime: true in pure consumer which not expose modules.',\n );\n }\n const runtimePlugins = options.runtimePlugins || [];\n options.runtimePlugins = runtimePlugins.concat(\n require.resolve('@module-federation/inject-external-runtime-core-plugin'),\n );\n }\n\n if (experiments?.externalRuntime === true) {\n const Externals = compiler.webpack.ExternalsPlugin || ExternalsPlugin;\n new Externals(compiler.options.externalsType || 'global', {\n '@module-federation/runtime-core': '_FEDERATION_RUNTIME_CORE',\n }).apply(compiler);\n }\n\n // federation hooks\n new FederationModulesPlugin().apply(compiler);\n\n if (experiments?.asyncStartup) {\n new StartupChunkDependenciesPlugin({\n asyncChunkLoading: true,\n }).apply(compiler);\n }\n\n if (dts !== false) {\n const dtsPlugin = new DtsPlugin(options);\n dtsPlugin.apply(compiler);\n dtsPlugin.addRuntimePlugins();\n }\n new FederationRuntimePlugin(options).apply(compiler);\n\n const library = options.library || { type: 'var', name: name };\n const remoteType =\n options.remoteType ||\n (options.library && isValidExternalsType(options.library.type)\n ? (options.library.type as moduleFederationPlugin.ExternalsType)\n : ('script' as moduleFederationPlugin.ExternalsType));\n const containerRemoteType =\n remoteType as moduleFederationPlugin.ExternalsType;\n\n let disableManifest = options.manifest === false;\n if (useContainerPlugin) {\n ContainerPlugin.patchChunkSplit(compiler, name);\n }\n this._patchBundlerConfig(compiler);\n if (!disableManifest && useContainerPlugin) {\n try {\n const containerManager = new ContainerManager();\n containerManager.init(options);\n options.exposes = containerManager.containerPluginExposesOptions;\n } catch (err) {\n if (err instanceof Error) {\n err.message = `[ ModuleFederationPlugin ]: Manifest will not generate, because: ${err.message}`;\n }\n infrastructureLogger.warn(err);\n disableManifest = true;\n }\n }\n\n if (\n library &&\n !compiler.options.output.enabledLibraryTypes?.includes(library.type)\n ) {\n compiler.options.output.enabledLibraryTypes?.push(library.type);\n }\n\n compiler.hooks.afterPlugins.tap('ModuleFederationPlugin', () => {\n if (useContainerPlugin) {\n new ContainerPlugin({\n name,\n library,\n filename: options.filename,\n runtime: options.runtime,\n shareScope: options.shareScope,\n exposes: options.exposes!,\n runtimePlugins: options.runtimePlugins,\n }).apply(compiler);\n }\n if (\n remotes &&\n (Array.isArray(remotes)\n ? remotes.length > 0\n : Object.keys(remotes).length > 0)\n ) {\n new ContainerReferencePlugin({\n remoteType: containerRemoteType,\n shareScope,\n remotes,\n }).apply(compiler);\n }\n if (shared) {\n new TreeShakingSharedPlugin({\n mfConfig: options,\n }).apply(compiler);\n new SharePlugin({\n shared,\n shareScope,\n }).apply(compiler);\n }\n });\n\n if (!disableManifest) {\n this._statsPlugin = new StatsPlugin(options, {\n pluginVersion: getEnhancedPackageVersion(),\n bundler: 'webpack',\n });\n this._statsPlugin.apply(compiler);\n }\n }\n}\n\nexport default ModuleFederationPlugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,MAAM,uBAAuB,gFAEzB,2DACD,CACF;AAED,MAAM,EAAE,oBAAoB,gFACL,UAAU,CAChC;AAED,MAAM,WAAWA,6PAEoD,gNACH,SAChE;CACE,MAAM;CACN,cAAc;CACf,CACF;AAED,SAAS,WACP,SACS;AACT,QAAO,QACL,YACC,MAAM,QAAQ,QAAQ,GACnB,QAAQ,SAAS,IACjB,OAAO,KAAK,QAAQ,CAAC,SAAS,GACnC;;AAGH,SAAS,4BAAoC;CAC3C,IAAI,aAAa;AAEjB,QAAO,MAAM;EACX,MAAM,kBAAkBC,kBAAK,KAAK,YAAY,eAAe;AAE7D,MAAIC,gBAAG,WAAW,gBAAgB,EAAE;GAClC,MAAM,MAAM,KAAK,MAAMA,gBAAG,aAAa,iBAAiB,QAAQ,CAAC;AAKjE,OAAI,IAAI,SAAS,iCAAiC,IAAI,QACpD,QAAO,IAAI;;EAIf,MAAM,YAAYD,kBAAK,QAAQ,WAAW;AAC1C,MAAI,cAAc,WAChB;AAEF,eAAa;;AAGf,OAAM,IAAI,MAAM,6DAA6D;;AAG/E,IAAM,yBAAN,MAA8D;;;;CAM5D,YAAY,SAA+D;AACzE,WAAS,QAAQ;AACjB,OAAK,WAAW;;CAGlB,AAAQ,oBAAoB,UAA0B;EACpD,MAAM,EAAE,MAAM,aAAa,YAAY,KAAK;EAC5C,MAAM,sBAAwD,EAAE;EAEhE,MAAM,cAAc,SAAS,QAAQ,QAAQ,QAC1C,MACC,CAAC,CAAC,KAAM,EAAU,SAAS,yBAC9B,CAAC;AAEF,MAAI,QAAQ,cAAc,EACxB,qBAAoB,iCAAiC,KAAK,8DAChC,MAAME,kCAAM,iBAAiB,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;IACA;IACD,CAAC,CAAC,MAAM,SAAS;AAEpB,OAAI,QAAQ;AACV,QAAIC,iEAAwB,EAC1B,UAAU,SACX,CAAC,CAAC,MAAM,SAAS;AAClB,QAAIC,wCAAY;KACd;KACA;KACD,CAAC,CAAC,MAAM,SAAS;;IAEpB;AAEF,MAAI,CAAC,iBAAiB;AACpB,QAAK,eAAe,IAAIC,wCAAY,SAAS;IAC3C,eAAe,2BAA2B;IAC1C,SAAS;IACV,CAAC;AACF,QAAK,aAAa,MAAM,SAAS"}
|
|
1
|
+
{"version":3,"file":"ModuleFederationPlugin.js","names":["createSchemaValidation","path","fs","utils","infrastructureLogger","RemoteEntryPlugin","FederationModulesPlugin","StartupChunkDependenciesPlugin","DtsPlugin","FederationRuntimePlugin","ContainerManager","ContainerPlugin","ContainerReferencePlugin","TreeShakingSharedPlugin","SharePlugin","StatsPlugin"],"sources":["../../../../src/lib/container/ModuleFederationPlugin.ts"],"sourcesContent":["/*\n MIT License http://www.opensource.org/licenses/mit-license.php\n Author Tobias Koppers @sokra and Zackary Jackson @ScriptedAlchemy\n*/\n\n'use strict';\nimport { DtsPlugin } from '@module-federation/dts-plugin';\nimport { ContainerManager, utils } from '@module-federation/managers';\nimport { StatsPlugin } from '@module-federation/manifest';\nimport {\n bindLoggerToCompiler,\n composeKeyWithSeparator,\n type moduleFederationPlugin,\n infrastructureLogger,\n} from '@module-federation/sdk';\nimport { normalizeWebpackPath } from '@module-federation/sdk/normalize-webpack-path';\nimport type { Compiler, WebpackPluginInstance } from 'webpack';\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport SharePlugin from '../sharing/SharePlugin';\nimport ContainerPlugin from './ContainerPlugin';\nimport ContainerReferencePlugin from './ContainerReferencePlugin';\nimport FederationRuntimePlugin from './runtime/FederationRuntimePlugin';\nimport { RemoteEntryPlugin } from '@module-federation/rspack/remote-entry-plugin';\nimport StartupChunkDependenciesPlugin from '../startup/MfStartupChunkDependenciesPlugin';\nimport FederationModulesPlugin from './runtime/FederationModulesPlugin';\nimport { createSchemaValidation } from '../../utils';\nimport TreeShakingSharedPlugin from '../sharing/tree-shaking/TreeShakingSharedPlugin';\n\nconst isValidExternalsType = require(\n normalizeWebpackPath(\n 'webpack/schemas/plugins/container/ExternalsType.check.js',\n ),\n) as typeof import('webpack/schemas/plugins/container/ExternalsType.check.js');\n\nconst { ExternalsPlugin } = require(\n normalizeWebpackPath('webpack'),\n) as typeof import('webpack');\n\nconst validate = createSchemaValidation(\n //eslint-disable-next-line\n require('../../schemas/container/ModuleFederationPlugin.check.js').validate,\n () => require('../../schemas/container/ModuleFederationPlugin').default,\n {\n name: 'Module Federation Plugin',\n baseDataPath: 'options',\n },\n);\n\nfunction hasExposes(\n exposes: moduleFederationPlugin.ModuleFederationPluginOptions['exposes'],\n): boolean {\n return Boolean(\n exposes &&\n (Array.isArray(exposes)\n ? exposes.length > 0\n : Object.keys(exposes).length > 0),\n );\n}\n\nfunction getEnhancedPackageVersion(): string {\n let currentDir = __dirname;\n\n while (true) {\n const packageJsonPath = path.join(currentDir, 'package.json');\n\n if (fs.existsSync(packageJsonPath)) {\n const pkg = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8')) as {\n name?: string;\n version?: string;\n };\n\n if (pkg.name === '@module-federation/enhanced' && pkg.version) {\n return pkg.version;\n }\n }\n\n const parentDir = path.dirname(currentDir);\n if (parentDir === currentDir) {\n break;\n }\n currentDir = parentDir;\n }\n\n throw new Error('Unable to resolve @module-federation/enhanced package.json');\n}\n\nclass ModuleFederationPlugin implements WebpackPluginInstance {\n private _options: moduleFederationPlugin.ModuleFederationPluginOptions;\n private _statsPlugin?: StatsPlugin;\n /**\n * @param {moduleFederationPlugin.ModuleFederationPluginOptions} options options\n */\n constructor(options: moduleFederationPlugin.ModuleFederationPluginOptions) {\n validate(options);\n this._options = options;\n }\n\n private _patchBundlerConfig(compiler: Compiler): void {\n const { name, experiments, exposes } = this._options;\n const definePluginOptions: Record<string, string | boolean> = {};\n\n const MFPluginNum = compiler.options.plugins.filter(\n (p): p is WebpackPluginInstance =>\n !!p && (p as any).name === 'ModuleFederationPlugin',\n ).length;\n\n if (name && MFPluginNum < 2) {\n definePluginOptions['FEDERATION_BUILD_IDENTIFIER'] = JSON.stringify(\n composeKeyWithSeparator(name, utils.getBuildVersion()),\n );\n }\n\n const disableSnapshot = experiments?.optimization?.disableSnapshot ?? false;\n definePluginOptions['FEDERATION_OPTIMIZE_NO_SNAPSHOT_PLUGIN'] =\n disableSnapshot;\n definePluginOptions['FEDERATION_OPTIMIZE_NO_REMOTE'] =\n experiments?.optimization?.disableRemote ?? false;\n definePluginOptions['FEDERATION_OPTIMIZE_NO_SHARED'] =\n experiments?.optimization?.disableShared ?? false;\n definePluginOptions['FEDERATION_HAS_EXPOSES'] =\n hasExposes(exposes) ||\n compiler.options.plugins.some((plugin) => {\n if (!plugin || typeof plugin !== 'object') {\n return false;\n }\n\n const namedPlugin = plugin as WebpackPluginInstance & {\n name?: string;\n _options?: moduleFederationPlugin.ModuleFederationPluginOptions;\n };\n if (namedPlugin.name !== 'ModuleFederationPlugin') {\n return false;\n }\n\n return hasExposes(namedPlugin._options?.exposes);\n });\n\n // Determine ENV_TARGET: only if manually specified in experiments.optimization.target\n if (\n experiments?.optimization &&\n typeof experiments.optimization === 'object' &&\n experiments.optimization !== null &&\n 'target' in experiments.optimization\n ) {\n const manualTarget = experiments.optimization.target as\n | 'web'\n | 'node'\n | undefined;\n // Ensure the target is one of the expected values before setting\n if (manualTarget === 'web' || manualTarget === 'node') {\n definePluginOptions['ENV_TARGET'] = JSON.stringify(manualTarget);\n }\n }\n // No inference for ENV_TARGET. If not manually set and valid, it's not defined.\n\n new compiler.webpack.DefinePlugin(definePluginOptions).apply(compiler);\n }\n\n /**\n * Apply the plugin\n * @param {Compiler} compiler the compiler instance\n * @returns {void}\n */\n apply(compiler: Compiler): void {\n bindLoggerToCompiler(\n infrastructureLogger,\n compiler,\n 'EnhancedModuleFederationPlugin',\n );\n const { _options: options } = this;\n const { name, experiments, dts, remotes, shared, shareScope } = options;\n if (!name) {\n throw new Error('ModuleFederationPlugin name is required');\n }\n // must before ModuleFederationPlugin\n (new RemoteEntryPlugin(options) as unknown as WebpackPluginInstance).apply(\n compiler,\n );\n const useContainerPlugin = hasExposes(options.exposes);\n\n if (experiments?.provideExternalRuntime) {\n if (useContainerPlugin) {\n throw new Error(\n 'You can only set provideExternalRuntime: true in pure consumer which not expose modules.',\n );\n }\n const runtimePlugins = options.runtimePlugins || [];\n options.runtimePlugins = runtimePlugins.concat(\n require.resolve('@module-federation/inject-external-runtime-core-plugin'),\n );\n }\n\n if (experiments?.externalRuntime === true) {\n const Externals = compiler.webpack.ExternalsPlugin || ExternalsPlugin;\n new Externals(compiler.options.externalsType || 'global', {\n '@module-federation/runtime-core': '_FEDERATION_RUNTIME_CORE',\n }).apply(compiler);\n }\n\n // federation hooks\n new FederationModulesPlugin().apply(compiler);\n\n if (experiments?.asyncStartup) {\n new StartupChunkDependenciesPlugin({\n asyncChunkLoading: true,\n }).apply(compiler);\n }\n\n if (dts !== false) {\n const dtsPlugin = new DtsPlugin(options);\n dtsPlugin.apply(compiler);\n dtsPlugin.addRuntimePlugins();\n }\n new FederationRuntimePlugin(options).apply(compiler);\n\n const library = options.library || { type: 'var', name: name };\n const remoteType =\n options.remoteType ||\n (options.library && isValidExternalsType(options.library.type)\n ? (options.library.type as moduleFederationPlugin.ExternalsType)\n : ('script' as moduleFederationPlugin.ExternalsType));\n const containerRemoteType =\n remoteType as moduleFederationPlugin.ExternalsType;\n\n let disableManifest = options.manifest === false;\n if (useContainerPlugin) {\n ContainerPlugin.patchChunkSplit(compiler, name);\n }\n this._patchBundlerConfig(compiler);\n if (!disableManifest && useContainerPlugin) {\n try {\n const containerManager = new ContainerManager();\n containerManager.init(options);\n options.exposes = containerManager.containerPluginExposesOptions;\n } catch (err) {\n if (err instanceof Error) {\n err.message = `[ ModuleFederationPlugin ]: Manifest will not generate, because: ${err.message}`;\n }\n infrastructureLogger.warn(err);\n disableManifest = true;\n }\n }\n\n if (\n library &&\n !compiler.options.output.enabledLibraryTypes?.includes(library.type)\n ) {\n compiler.options.output.enabledLibraryTypes?.push(library.type);\n }\n\n compiler.hooks.afterPlugins.tap('ModuleFederationPlugin', () => {\n if (useContainerPlugin) {\n new ContainerPlugin({\n name,\n library,\n filename: options.filename,\n runtime: options.runtime,\n shareScope: options.shareScope,\n exposes: options.exposes!,\n runtimePlugins: options.runtimePlugins,\n }).apply(compiler);\n }\n if (\n remotes &&\n (Array.isArray(remotes)\n ? remotes.length > 0\n : Object.keys(remotes).length > 0)\n ) {\n new ContainerReferencePlugin({\n remoteType: containerRemoteType,\n shareScope,\n remotes,\n }).apply(compiler);\n }\n if (shared) {\n new TreeShakingSharedPlugin({\n mfConfig: options,\n }).apply(compiler);\n new SharePlugin({\n shared,\n shareScope,\n }).apply(compiler);\n }\n });\n\n if (!disableManifest) {\n this._statsPlugin = new StatsPlugin(options, {\n pluginVersion: getEnhancedPackageVersion(),\n bundler: 'webpack',\n });\n this._statsPlugin.apply(compiler);\n }\n }\n}\n\nexport default ModuleFederationPlugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,MAAM,uBAAuB,gFAEzB,2DACD,CACF;AAED,MAAM,EAAE,oBAAoB,gFACL,UAAU,CAChC;AAED,MAAM,WAAWA,6PAEoD,gNACH,SAChE;CACE,MAAM;CACN,cAAc;CACf,CACF;AAED,SAAS,WACP,SACS;AACT,QAAO,QACL,YACC,MAAM,QAAQ,QAAQ,GACnB,QAAQ,SAAS,IACjB,OAAO,KAAK,QAAQ,CAAC,SAAS,GACnC;;AAGH,SAAS,4BAAoC;CAC3C,IAAI,aAAa;AAEjB,QAAO,MAAM;EACX,MAAM,kBAAkBC,kBAAK,KAAK,YAAY,eAAe;AAE7D,MAAIC,gBAAG,WAAW,gBAAgB,EAAE;GAClC,MAAM,MAAM,KAAK,MAAMA,gBAAG,aAAa,iBAAiB,QAAQ,CAAC;AAK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AI,UAAU,oEAAoE,IAAI;AAExF,+CAAqB,KAAK,IAAI;AAC9B,qBAAkB;;AAItB,MACE,WACA,CAAC,SAAS,QAAQ,OAAO,qBAAqB,SAAS,QAAQ,KAAK,CAEpE,UAAS,QAAQ,OAAO,qBAAqB,KAAK,QAAQ,KAAK;AAGjE,WAAS,MAAM,aAAa,IAAI,gCAAgC;AAC9D,OAAI,mBACF,KAAIC,8CAAgB;IAClB;IACA;IACA,UAAU,QAAQ;IAClB,SAAS,QAAQ;IACjB,YAAY,QAAQ;IACpB,SAAS,QAAQ;IACjB,gBAAgB,QAAQ;IACzB,CAAC,CAAC,MAAM,SAAS;AAEpB,OACE,YACC,MAAM,QAAQ,QAAQ,GACnB,QAAQ,SAAS,IACjB,OAAO,KAAK,QAAQ,CAAC,SAAS,GAElC,KAAIC,uDAAyB;IAC3B,YAAY;IACZ;IACA;IACD,CAAC,CAAC,MAAM,SAAS;AAEpB,OAAI,QAAQ;AACV,QAAIC,iEAAwB,EAC1B,UAAU,SACX,CAAC,CAAC,MAAM,SAAS;AAClB,QAAIC,wCAAY;KACd;KACA;KACD,CAAC,CAAC,MAAM,SAAS;;IAEpB;AAEF,MAAI,CAAC,iBAAiB;AACpB,QAAK,eAAe,IAAIC,wCAAY,SAAS;IAC3C,eAAe,2BAA2B;IAC1C,SAAS;IACV,CAAC;AACF,QAAK,aAAa,MAAM,SAAS"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RemoteRuntimeModule.js","names":["getFederationGlobalScope"],"sources":["../../../../src/lib/container/RemoteRuntimeModule.ts"],"sourcesContent":["/*\n MIT License http://www.opensource.org/licenses/mit-license.php\n Author Tobias Koppers @sokra, Zackary Jackson @ScriptedAlchemy\n*/\nimport { normalizeWebpackPath } from '@module-federation/sdk/normalize-webpack-path';\nimport type { Compilation } from 'webpack';\nimport RemoteModule from './RemoteModule';\nimport { getFederationGlobalScope } from './runtime/utils';\nimport type ExternalModule from 'webpack/lib/ExternalModule';\nimport type FallbackModule from './FallbackModule';\nimport type {\n ModuleIdToRemoteDataMapping,\n RemotesOptions,\n} from '@module-federation/webpack-bundler-runtime';\n\nconst extractUrlAndGlobal = require(\n normalizeWebpackPath('webpack/lib/util/extractUrlAndGlobal'),\n) as typeof import('webpack/lib/util/extractUrlAndGlobal');\n\nconst { Template, RuntimeModule, RuntimeGlobals } = require(\n normalizeWebpackPath('webpack'),\n) as typeof import('webpack');\n\nclass RemoteRuntimeModule extends RuntimeModule {\n constructor() {\n super('remotes loading');\n }\n\n /**\n * @returns {string | null} runtime code\n */\n override generate(): string | null {\n const { compilation, chunkGraph } = this;\n const { runtimeTemplate, moduleGraph } = compilation as Compilation;\n const chunkToRemotesMapping: Record<string, any> = {};\n const idToExternalAndNameMapping: Record<string | number, any> = {};\n const idToRemoteMap: RemotesOptions['idToRemoteMap'] = {};\n const moduleIdToRemoteDataMapping: ModuleIdToRemoteDataMapping = {};\n\n
|
|
1
|
+
{"version":3,"file":"RemoteRuntimeModule.js","names":["getFederationGlobalScope"],"sources":["../../../../src/lib/container/RemoteRuntimeModule.ts"],"sourcesContent":["/*\n MIT License http://www.opensource.org/licenses/mit-license.php\n Author Tobias Koppers @sokra, Zackary Jackson @ScriptedAlchemy\n*/\nimport { normalizeWebpackPath } from '@module-federation/sdk/normalize-webpack-path';\nimport type { Compilation } from 'webpack';\nimport RemoteModule from './RemoteModule';\nimport { getFederationGlobalScope } from './runtime/utils';\nimport type ExternalModule from 'webpack/lib/ExternalModule';\nimport type FallbackModule from './FallbackModule';\nimport type {\n ModuleIdToRemoteDataMapping,\n RemotesOptions,\n} from '@module-federation/webpack-bundler-runtime';\n\nconst extractUrlAndGlobal = require(\n normalizeWebpackPath('webpack/lib/util/extractUrlAndGlobal'),\n) as typeof import('webpack/lib/util/extractUrlAndGlobal');\n\nconst { Template, RuntimeModule, RuntimeGlobals } = require(\n normalizeWebpackPath('webpack'),\n) as typeof import('webpack');\n\nclass RemoteRuntimeModule extends RuntimeModule {\n constructor() {\n super('remotes loading');\n }\n\n /**\n * @returns {string | null} runtime code\n */\n override generate(): string | null {\n const { compilation, chunkGraph } = this;\n const { runtimeTemplate, moduleGraph } = compilation as Compilation;\n const chunkToRemotesMapping: Record<string, any> = {};\n const idToExternalAndNameMapping: Record<string | number, any> = {};\n const idToRemoteMap: RemotesOptions['idToRemoteMap'] = {};\n const moduleIdToRemoteDataMapping: ModuleIdToRemoteDataMapping = {};\n\n const allChunks = [\n ...Array.from(this.chunk?.getAllReferencedChunks() || []),\n ];\n\n for (const chunk of allChunks) {\n if (chunk.id === null || chunk.id === undefined) {\n continue;\n }\n const modules = chunkGraph?.getChunkModulesIterableBySourceType(\n chunk,\n 'remote',\n );\n if (!modules) {\n continue;\n }\n // @ts-ignore\n const remotes = (chunkToRemotesMapping[chunk.id] = []);\n for (const m of modules) {\n const module: RemoteModule = m as unknown as RemoteModule;\n const name = module.internalRequest;\n // @ts-ignore\n const id = chunkGraph ? chunkGraph.getModuleId(module) : undefined;\n const { shareScope } = module;\n const dep = module.dependencies[0];\n // @ts-ignore\n const externalModule = moduleGraph.getModule(dep) as\n | ExternalModule\n | FallbackModule;\n const externalModuleId =\n chunkGraph && externalModule\n ? // @ts-ignore\n chunkGraph.getModuleId(externalModule)\n : undefined;\n if (id !== undefined && id !== null) {\n //@ts-ignore\n remotes.push(id);\n\n const normalizedExternalModuleId =\n externalModuleId === null || externalModuleId === undefined\n ? undefined\n : externalModuleId;\n idToExternalAndNameMapping[id] = [\n shareScope,\n name,\n normalizedExternalModuleId,\n ];\n const remoteModules: ExternalModule[] = [];\n // FallbackModule has requests\n if ('requests' in externalModule && externalModule.requests) {\n externalModule.dependencies.forEach((dependency) => {\n const remoteModule = moduleGraph.getModule(dependency);\n if (remoteModule) {\n // @ts-ignore\n remoteModules.push(remoteModule as ExternalModule);\n }\n });\n } else {\n remoteModules.push(externalModule as ExternalModule);\n }\n\n idToRemoteMap[id] = [];\n remoteModules.forEach((remoteModule) => {\n let remoteName = '';\n try {\n const [_url, name] = extractUrlAndGlobal(\n remoteModule.request as string,\n );\n remoteName = name;\n } catch (err) {\n //noop\n }\n const externalModuleId =\n chunkGraph &&\n remoteModule &&\n // @ts-ignore\n chunkGraph.getModuleId(remoteModule);\n\n idToRemoteMap[id].push({\n externalType: remoteModule.externalType,\n name: remoteModule.externalType === 'script' ? remoteName : '',\n });\n if (externalModuleId !== null && externalModuleId !== undefined) {\n moduleIdToRemoteDataMapping[id] = {\n shareScope: shareScope,\n name,\n externalModuleId: externalModuleId as string | number,\n // Preserve the extracted remote name so lazy updates can\n // rebuild idToRemoteMap via updateRemoteOptions.\n remoteName: remoteName,\n };\n }\n });\n }\n }\n }\n const federationGlobal = getFederationGlobalScope(\n RuntimeGlobals || ({} as typeof RuntimeGlobals),\n );\n\n return Template.asString([\n `var chunkMapping = ${JSON.stringify(\n chunkToRemotesMapping,\n null,\n '\\t',\n )};`,\n `var idToExternalAndNameMapping = ${JSON.stringify(\n idToExternalAndNameMapping,\n null,\n '\\t',\n )};`,\n `var idToRemoteMap = ${JSON.stringify(idToRemoteMap, null, '\\t')};`,\n `${federationGlobal}.bundlerRuntimeOptions.remotes.chunkMapping = chunkMapping;`,\n `${federationGlobal}.bundlerRuntimeOptions.remotes.idToExternalAndNameMapping = idToExternalAndNameMapping;`,\n `${federationGlobal}.bundlerRuntimeOptions.remotes.idToRemoteMap = idToRemoteMap;`,\n `${RuntimeGlobals.require}.remotesLoadingData.moduleIdToRemoteDataMapping = ${JSON.stringify(\n moduleIdToRemoteDataMapping,\n null,\n '\\t',\n )};`,\n `${\n RuntimeGlobals.ensureChunkHandlers\n }.remotes = ${runtimeTemplate.basicFunction('chunkId, promises', [\n `${federationGlobal}.bundlerRuntime.remotes({idToRemoteMap,chunkMapping, idToExternalAndNameMapping, chunkId, promises, webpackRequire:${RuntimeGlobals.require}});`,\n ])}`,\n ]);\n }\n}\n\nexport default RemoteRuntimeModule;\n"],"mappings":";;;;;;AAeA,MAAM,sBAAsB,gFACL,uC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AAc,MAAM,EAAE;AACtB,mBAAc,SAAS,iBAAiB;MACtC,IAAI,aAAa;AACjB,UAAI;OACF,MAAM,CAAC,MAAM,QAAQ,oBACnB,aAAa,QACd;AACD,oBAAa;eACN,KAAK;MAGd,MAAM,mBACJ,cACA,gBAEA,WAAW,YAAY,aAAa;AAEtC,oBAAc,IAAI,KAAK;OACrB,cAAc,aAAa;OAC3B,MAAM,aAAa,iBAAiB,WAAW,aAAa;OAC7D,CAAC;AACF,UAAI,qBAAqB,QAAQ,qBAAqB,OACpD,6BAA4B,MAAM;OACpB;OACZ;OACkB;OAGN;OACb;OAEH;;;;EAIR,MAAM,mBAAmBA,6DACvB,kBAAmB,EAAE,CACtB;AAED,SAAO,SAAS,SAAS;GACvB,sBAAsB,KAAK,UACzB,uBACA,MACA,IACD,CAAC;GACF,oCAAoC,KAAK,UACvC,4BACA,MACA,IACD,CAAC;GACF,uBAAuB,KAAK,UAAU,eAAe,MAAM,IAAK,CAAC;GACjE,GAAG,iBAAiB;GACpB,GAAG,iBAAiB;GACpB,GAAG,iBAAiB;GACpB,GAAG,eAAe,QAAQ,oDAAoD,KAAK,UACjF,6BACA,MACA,IACD,CAAC;GACF,GACE,eAAe,oBAChB,aAAa,gBAAgB,cAAc,qBAAqB,CAC/D,GAAG,iBAAiB,qHAAqH,eAAe,QAAQ,KACjK,CAAC;GACH,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
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_container_options = require('../../container/options.js');
|
|
4
3
|
const require_lib_sharing_ConsumeSharedPlugin = require('../ConsumeSharedPlugin.js');
|
|
4
|
+
const require_lib_sharing_SharePlugin = require('../SharePlugin.js');
|
|
5
5
|
const require_lib_sharing_tree_shaking_SharedUsedExportsOptimizerPlugin = require('./SharedUsedExportsOptimizerPlugin.js');
|
|
6
6
|
const require_lib_sharing_tree_shaking_CollectSharedEntryPlugin = require('./CollectSharedEntryPlugin.js');
|
|
7
7
|
const require_lib_sharing_tree_shaking_SharedContainerPlugin_SharedContainerPlugin = require('./SharedContainerPlugin/SharedContainerPlugin.js');
|
|
@@ -44,15 +44,7 @@ var IndependentSharedPlugin = class {
|
|
|
44
44
|
this.manifest = manifest;
|
|
45
45
|
this.injectTreeShakingUsedExports = injectTreeShakingUsedExports ?? true;
|
|
46
46
|
this.library = library;
|
|
47
|
-
this.sharedOptions =
|
|
48
|
-
if (typeof item !== "string") throw new Error(`Unexpected array in shared configuration for key "${key}"`);
|
|
49
|
-
return item === key || !(0, _module_federation_sdk.isRequiredVersion)(item) ? { import: item } : {
|
|
50
|
-
import: key,
|
|
51
|
-
requiredVersion: item
|
|
52
|
-
};
|
|
53
|
-
}, (item) => {
|
|
54
|
-
return item;
|
|
55
|
-
});
|
|
47
|
+
this.sharedOptions = require_lib_sharing_SharePlugin.normalizeSharedOptions(shared);
|
|
56
48
|
}
|
|
57
49
|
static {
|
|
58
50
|
this.IndependentShareBuildAssetsFilename = "independent-share-build-assets.json";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IndependentSharedPlugin.js","names":["parseOptions","CollectSharedEntryPlugin","IndependentSharedRuntimeModule","StatsFileName","SharedContainerPlugin","ConsumeSharedPlugin","SharedUsedExportsOptimizerPlugin"],"sources":["../../../../../src/lib/sharing/tree-shaking/IndependentSharedPlugin.ts"],"sourcesContent":["import * as fs from 'fs';\nimport * as path from 'path';\nimport type {\n WebpackPluginInstance,\n Compiler,\n Configuration,\n WebpackOptionsNormalized,\n} from 'webpack';\nimport type { moduleFederationPlugin, Stats } from '@module-federation/sdk';\nimport {\n encodeName,\n isRequiredVersion,\n StatsFileName,\n} from '@module-federation/sdk';\nimport CollectSharedEntryPlugin, {\n type ShareRequestsMap,\n} from './CollectSharedEntryPlugin';\nimport SharedUsedExportsOptimizerPlugin from './SharedUsedExportsOptimizerPlugin';\nimport SharedContainerPlugin, {\n SharedContainerPluginOptions,\n} from './SharedContainerPlugin/SharedContainerPlugin';\nimport { parseOptions } from '../../container/options';\ntype SharedConfig = moduleFederationPlugin.SharedConfig;\nimport ConsumeSharedPlugin from '../ConsumeSharedPlugin';\nimport { NormalizedSharedOptions } from '../SharePlugin';\nimport IndependentSharedRuntimeModule from './IndependentSharedRuntimeModule';\n\nconst IGNORED_ENTRY = 'ignored-entry';\n\n// { react: [ [ react/19.0.0/index.js , 19.0.0, react_global_name ] ] }\nexport type ShareFallback = Record<string, [string, string, string][]>;\n\nexport type MakeRequired<T, K extends keyof T> = Required<Pick<T, K>> &\n Omit<T, K>;\n\nconst filterPlugin = (\n plugin: WebpackOptionsNormalized['plugins'][0],\n treeShakingSharedExcludePlugins: string[] = [],\n) => {\n if (!plugin) {\n return true;\n }\n const pluginName = plugin['name'] || plugin['constructor']?.name;\n if (!pluginName) {\n return true;\n }\n return ![\n 'IndependentSharedPlugin',\n 'ModuleFederationPlugin',\n 'SharedUsedExportsOptimizerPlugin',\n 'HtmlWebpackPlugin',\n 'TreeShakingSharedPlugin',\n ...treeShakingSharedExcludePlugins,\n ].includes(pluginName);\n};\n\nconst resolveOutputDir = (outputDir: string, shareName?: string) => {\n return shareName ? path.join(outputDir, encodeName(shareName)) : outputDir;\n};\n\nexport interface IndependentSharePluginOptions {\n name: string;\n shared: moduleFederationPlugin.Shared;\n library?: moduleFederationPlugin.LibraryOptions;\n outputDir?: string;\n plugins?: WebpackPluginInstance[];\n treeShaking?: boolean;\n manifest?: moduleFederationPlugin.ModuleFederationPluginOptions['manifest'];\n injectTreeShakingUsedExports?: boolean;\n treeShakingSharedExcludePlugins?: string[];\n}\n\nexport default class IndependentSharedPlugin {\n mfName: string;\n shared: moduleFederationPlugin.Shared;\n library?: moduleFederationPlugin.LibraryOptions;\n sharedOptions: NormalizedSharedOptions;\n outputDir: string;\n plugins: WebpackPluginInstance[];\n treeShaking?: boolean;\n manifest?: moduleFederationPlugin.ModuleFederationPluginOptions['manifest'];\n injectTreeShakingUsedExports?: boolean;\n buildAssets: ShareFallback = {};\n treeShakingSharedExcludePlugins?: string[];\n\n name = 'IndependentSharedPlugin';\n constructor(options: IndependentSharePluginOptions) {\n const {\n outputDir,\n plugins,\n treeShaking,\n shared,\n name,\n manifest,\n injectTreeShakingUsedExports,\n library,\n treeShakingSharedExcludePlugins,\n } = options;\n this.shared = shared;\n this.treeShakingSharedExcludePlugins = treeShakingSharedExcludePlugins;\n this.mfName = name;\n this.outputDir = outputDir || 'independent-packages';\n this.plugins = plugins || [];\n this.treeShaking = treeShaking;\n this.manifest = manifest;\n this.injectTreeShakingUsedExports = injectTreeShakingUsedExports ?? true;\n this.library = library;\n this.sharedOptions = parseOptions(\n shared,\n (item, key) => {\n if (typeof item !== 'string')\n throw new Error(\n `Unexpected array in shared configuration for key \"${key}\"`,\n );\n const config: SharedConfig =\n item === key || !isRequiredVersion(item)\n ? {\n import: item,\n }\n : {\n import: key,\n requiredVersion: item,\n };\n\n return config;\n },\n (item) => {\n return item;\n },\n );\n }\n\n static IndependentShareBuildAssetsFilename =\n 'independent-share-build-assets.json';\n\n apply(compiler: Compiler) {\n const { manifest } = this;\n const collectSharedEntryPlugin = new CollectSharedEntryPlugin({\n sharedOptions: this.sharedOptions,\n });\n collectSharedEntryPlugin.apply(compiler);\n\n compiler.hooks.thisCompilation.tap(\n 'IndependentSharedPlugin',\n (compilation) => {\n compilation.hooks.finishModules.tapPromise(\n {\n name: 'IndependentSharedPlugin',\n stage: 20,\n },\n async () => {\n await this.createIndependentCompilers(\n compiler,\n collectSharedEntryPlugin.getData(),\n );\n },\n );\n compilation.hooks.additionalTreeRuntimeRequirements.tap(\n 'OptimizeDependencyReferencedExportsPlugin',\n (chunk) => {\n compilation.addRuntimeModule(\n chunk,\n new IndependentSharedRuntimeModule(\n this.buildAssets,\n this.library?.type || 'global',\n ),\n );\n },\n );\n // inject buildAssets to stats\n if (!manifest) {\n return;\n }\n compilation.hooks.processAssets.tapPromise(\n {\n name: 'injectReferenceExports',\n stage:\n // biome-ignore lint/suspicious/noExplicitAny: <explanation>\n (compilation.constructor as any)\n .PROCESS_ASSETS_STAGE_OPTIMIZE_TRANSFER,\n },\n async () => {\n const stats = compilation.getAsset(StatsFileName);\n if (!stats) {\n return;\n }\n const statsContent = JSON.parse(\n stats.source.source().toString(),\n ) as Stats;\n\n const { shared } = statsContent;\n Object.entries(this.buildAssets).forEach(([key, item]) => {\n const targetShared = shared.find((s) => s.name === key);\n if (!targetShared) {\n return;\n }\n item.forEach(([entry, version, globalName]) => {\n if (version === targetShared.version) {\n targetShared.fallback = entry;\n targetShared.fallbackName = globalName;\n }\n });\n });\n\n compilation.updateAsset(\n StatsFileName,\n new compiler.webpack.sources.RawSource(\n JSON.stringify(statsContent),\n ),\n );\n },\n );\n },\n );\n }\n\n private createEntry(context: string) {\n const { sharedOptions } = this;\n const entryContent = sharedOptions.reduce((acc, cur, index) => {\n return `${acc}import shared_${index} from '${cur[0]}';\\n`;\n }, '');\n const entryPath = path.resolve(\n context,\n 'node_modules',\n '.federation',\n // name,\n 'shared-entry.js',\n );\n if (!fs.existsSync(path.dirname(entryPath))) {\n fs.mkdirSync(path.dirname(entryPath), { recursive: true });\n }\n fs.writeFileSync(entryPath, entryContent);\n return entryPath;\n }\n\n private async createIndependentCompilers(\n parentCompiler: Compiler,\n shareRequestsMap: ShareRequestsMap,\n ) {\n const { sharedOptions, outputDir } = this;\n this.buildAssets = {};\n\n const hasShareRequests = sharedOptions.some(\n ([shareName, shareConfig]) =>\n Boolean(shareConfig.treeShaking) &&\n Boolean(shareRequestsMap[shareName]?.requests.length),\n );\n if (!hasShareRequests) {\n return;\n }\n\n console.log('Start building shared fallback resources ...');\n\n await Promise.all(\n sharedOptions.map(async ([shareName, shareConfig]) => {\n if (!shareConfig.treeShaking) {\n return;\n }\n const shareRequests = shareRequestsMap[shareName]?.requests ?? [];\n for (let index = 0; index < shareRequests.length; index++) {\n const [request, version] = shareRequests[index];\n const sharedConfig = sharedOptions.find(\n ([name]) => name === shareName,\n )?.[1];\n const [shareFileName, globalName, sharedVersion] =\n await this.createIndependentCompiler(parentCompiler, {\n cleanOutput: index === 0,\n currentShare: {\n shareName,\n version,\n request,\n independentShareFileName: sharedConfig?.treeShaking?.filename,\n },\n });\n if (typeof shareFileName === 'string') {\n this.buildAssets[shareName] ||= [];\n this.buildAssets[shareName].push([\n path.join(resolveOutputDir(outputDir, shareName), shareFileName),\n sharedVersion,\n globalName,\n ]);\n }\n }\n }),\n );\n\n console.log('All shared fallback have been compiled successfully');\n }\n\n private async createIndependentCompiler(\n parentCompiler: Compiler,\n extraOptions: {\n currentShare: Omit<SharedContainerPluginOptions, 'mfName'>;\n cleanOutput: boolean;\n },\n ) {\n const {\n treeShaking,\n plugins,\n outputDir,\n sharedOptions,\n mfName,\n library,\n treeShakingSharedExcludePlugins,\n } = this;\n const outputDirWithShareName = resolveOutputDir(\n outputDir,\n extraOptions.currentShare.shareName,\n );\n\n const parentConfig = parentCompiler.options;\n\n const finalPlugins = [];\n const extraPlugin = new SharedContainerPlugin({\n mfName: `${mfName}_${treeShaking ? 't' : 'f'}`,\n library: library,\n ...extraOptions.currentShare,\n });\n (parentConfig.plugins || []).forEach((plugin) => {\n if (\n plugin !== undefined &&\n typeof plugin !== 'string' &&\n filterPlugin(plugin, treeShakingSharedExcludePlugins)\n ) {\n finalPlugins.push(plugin);\n }\n });\n plugins.forEach((plugin) => {\n finalPlugins.push(plugin);\n });\n finalPlugins.push(\n new ConsumeSharedPlugin({\n consumes: sharedOptions\n .filter(\n ([key, options]) =>\n extraOptions.currentShare.shareName !== (options.shareKey || key),\n )\n .map(([key, options]) => ({\n [key]: {\n import: false,\n shareKey: options.shareKey || key,\n shareScope: options.shareScope,\n requiredVersion: options.requiredVersion,\n strictVersion: options.strictVersion,\n singleton: options.singleton,\n packageName: options.packageName,\n eager: options.eager,\n },\n })),\n }),\n );\n\n if (treeShaking) {\n finalPlugins.push(\n new SharedUsedExportsOptimizerPlugin(\n sharedOptions,\n this.injectTreeShakingUsedExports,\n [IGNORED_ENTRY],\n this.manifest,\n ),\n );\n }\n finalPlugins.push(extraPlugin);\n const fullOutputDir = path.resolve(\n parentCompiler.outputPath,\n outputDirWithShareName,\n );\n // @ts-ignore webpack version is not the same as the one used in the plugin\n const compilerConfig: Configuration = {\n ...parentConfig,\n mode: parentConfig.mode || 'development',\n ignoreWarnings: [],\n entry: {\n [IGNORED_ENTRY]: this.createEntry(parentCompiler.context),\n },\n\n // 输出配置\n output: {\n path: fullOutputDir,\n clean: extraOptions.cleanOutput,\n publicPath: parentConfig.output?.publicPath || 'auto',\n },\n\n // 插件继承\n plugins: finalPlugins,\n\n // 优化配置继承\n optimization: {\n ...parentConfig.optimization,\n splitChunks: false, // 每个包独立,不拆分\n },\n };\n\n // 创建独立的 webpack compiler 实例\n const webpack = parentCompiler.webpack;\n const compiler = webpack.webpack(compilerConfig as any);\n\n // 设置文件系统\n if (parentCompiler.inputFileSystem) {\n compiler.inputFileSystem = parentCompiler.inputFileSystem;\n }\n if (parentCompiler.outputFileSystem) {\n compiler.outputFileSystem = parentCompiler.outputFileSystem;\n }\n if (parentCompiler.intermediateFileSystem) {\n compiler.intermediateFileSystem = parentCompiler.intermediateFileSystem;\n }\n\n const { currentShare } = extraOptions;\n\n return new Promise<any>((resolve, reject) => {\n compiler.run((err: any, stats: any) => {\n const shareName = currentShare?.shareName || 'unknown shared package';\n const hasStatsErrors =\n !!stats &&\n (stats.hasErrors?.() || stats.toJson?.()?.errors?.length > 0);\n if (err || hasStatsErrors) {\n const lines: string[] = [];\n if (err) {\n const errMsg = (err && (err.stack || err.message)) || String(err);\n lines.push(`Compiler error: ${errMsg}`);\n }\n if (stats?.toJson) {\n const json = stats.toJson({\n all: false,\n errors: true,\n warnings: false,\n errorDetails: true,\n moduleTrace: true,\n } as any);\n const errors = (json && json.errors) || [];\n if (errors.length) {\n lines.push(`Webpack errors (${errors.length}):`);\n const max = 5;\n for (let i = 0; i < Math.min(errors.length, max); i++) {\n const e: any = errors[i];\n const where =\n e.moduleName || e.file || e.moduleIdentifier || '';\n const loc = e.loc ? ` @ ${e.loc}` : '';\n const msg = e.message || e.details || String(e);\n lines.push(` [${i + 1}] ${where}${loc}`);\n lines.push(` ${msg}`);\n }\n if (errors.length > max) {\n lines.push(` ... and ${errors.length - max} more errors`);\n }\n }\n }\n console.error(\n `❌ Shared \"${shareName}\" compilation failed\\n${lines.join('\\n')}`,\n );\n reject(err || new Error(`Shared \"${shareName}\" compilation failed`));\n return;\n }\n\n console.log(`Shared \"${shareName}\" compilation succeeded`);\n\n resolve(extraPlugin.getData());\n });\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AA2BA,MAAM,gBAAgB;AAQtB,MAAM,gBACJ,QACA,kCAA4C,EAAE,KAC3C;AACH,KAAI,CAAC,OACH,QAAO;CAET,MAAM,aAAa,OAAO,WAAW,OAAO,gBAAgB;AAC5D,KAAI,CAAC,WACH,QAAO;AAET,QAAO,CAAC;EACN;EACA;EACA;EACA;EACA;EACA,GAAG;EACJ,CAAC,SAAS,WAAW;;AAGxB,MAAM,oBAAoB,WAAmB,cAAuB;AAClE,QAAO,YAAY,KAAK,KAAK,kDAAsB,UAAU,CAAC,GAAG;;AAenE,IAAqB,0BAArB,MAA6C;CAc3C,YAAY,SAAwC;qBAJvB,EAAE;cAGxB;EAEL,MAAM,EACJ,WACA,SACA,aACA,QACA,MACA,UACA,8BACA,SACA,oCACE;AACJ,OAAK,SAAS;AACd,OAAK,kCAAkC;AACvC,OAAK,SAAS;AACd,OAAK,YAAY,aAAa;AAC9B,OAAK,UAAU,WAAW,EAAE;AAC5B,OAAK,cAAc;AACnB,OAAK,WAAW;AAChB,OAAK,+BAA+B,gCAAgC;AACpE,OAAK,UAAU;AACf,OAAK,gBAAgBA,2CACnB,SACC,MAAM,QAAQ;AACb,OAAI,OAAO,SAAS,SAClB,OAAM,IAAI,MACR,qDAAqD,IAAI,G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AI,OAAO,SAAS,IAClB,OAAM,KAAK,aAAa,OAAO,SAAS,IAAI,cAAc;;;AAIhE,aAAQ,MACN,aAAa,UAAU,wBAAwB,MAAM,KAAK,KAAK,GAChE;AACD,YAAO,uBAAO,IAAI,MAAM,WAAW,UAAU,sBAAsB,CAAC;AACpE;;AAGF,YAAQ,IAAI,WAAW,UAAU,yBAAyB;AAE1D,YAAQ,YAAY,SAAS,CAAC;KAC9B;IACF"}
|
|
1
|
+
{"version":3,"file":"IndependentSharedPlugin.js","names":["normalizeSharedOptions","CollectSharedEntryPlugin","IndependentSharedRuntimeModule","StatsFileName","SharedContainerPlugin","ConsumeSharedPlugin","SharedUsedExportsOptimizerPlugin"],"sources":["../../../../../src/lib/sharing/tree-shaking/IndependentSharedPlugin.ts"],"sourcesContent":["import * as fs from 'fs';\nimport * as path from 'path';\nimport type {\n WebpackPluginInstance,\n Compiler,\n Configuration,\n WebpackOptionsNormalized,\n} from 'webpack';\nimport type { moduleFederationPlugin, Stats } from '@module-federation/sdk';\nimport { encodeName, StatsFileName } from '@module-federation/sdk';\nimport CollectSharedEntryPlugin, {\n type ShareRequestsMap,\n} from './CollectSharedEntryPlugin';\nimport SharedUsedExportsOptimizerPlugin from './SharedUsedExportsOptimizerPlugin';\nimport SharedContainerPlugin, {\n SharedContainerPluginOptions,\n} from './SharedContainerPlugin/SharedContainerPlugin';\nimport ConsumeSharedPlugin from '../ConsumeSharedPlugin';\nimport {\n normalizeSharedOptions,\n type NormalizedSharedOptions,\n} from '../SharePlugin';\nimport IndependentSharedRuntimeModule from './IndependentSharedRuntimeModule';\n\nconst IGNORED_ENTRY = 'ignored-entry';\n\n// { react: [ [ react/19.0.0/index.js , 19.0.0, react_global_name ] ] }\nexport type ShareFallback = Record<string, [string, string, string][]>;\n\nexport type MakeRequired<T, K extends keyof T> = Required<Pick<T, K>> &\n Omit<T, K>;\n\nconst filterPlugin = (\n plugin: WebpackOptionsNormalized['plugins'][0],\n treeShakingSharedExcludePlugins: string[] = [],\n) => {\n if (!plugin) {\n return true;\n }\n const pluginName = plugin['name'] || plugin['constructor']?.name;\n if (!pluginName) {\n return true;\n }\n return ![\n 'IndependentSharedPlugin',\n 'ModuleFederationPlugin',\n 'SharedUsedExportsOptimizerPlugin',\n 'HtmlWebpackPlugin',\n 'TreeShakingSharedPlugin',\n ...treeShakingSharedExcludePlugins,\n ].includes(pluginName);\n};\n\nconst resolveOutputDir = (outputDir: string, shareName?: string) => {\n return shareName ? path.join(outputDir, encodeName(shareName)) : outputDir;\n};\n\nexport interface IndependentSharePluginOptions {\n name: string;\n shared: moduleFederationPlugin.Shared;\n library?: moduleFederationPlugin.LibraryOptions;\n outputDir?: string;\n plugins?: WebpackPluginInstance[];\n treeShaking?: boolean;\n manifest?: moduleFederationPlugin.ModuleFederationPluginOptions['manifest'];\n injectTreeShakingUsedExports?: boolean;\n treeShakingSharedExcludePlugins?: string[];\n}\n\nexport default class IndependentSharedPlugin {\n mfName: string;\n shared: moduleFederationPlugin.Shared;\n library?: moduleFederationPlugin.LibraryOptions;\n sharedOptions: NormalizedSharedOptions;\n outputDir: string;\n plugins: WebpackPluginInstance[];\n treeShaking?: boolean;\n manifest?: moduleFederationPlugin.ModuleFederationPluginOptions['manifest'];\n injectTreeShakingUsedExports?: boolean;\n buildAssets: ShareFallback = {};\n treeShakingSharedExcludePlugins?: string[];\n\n name = 'IndependentSharedPlugin';\n constructor(options: IndependentSharePluginOptions) {\n const {\n outputDir,\n plugins,\n treeShaking,\n shared,\n name,\n manifest,\n injectTreeShakingUsedExports,\n library,\n treeShakingSharedExcludePlugins,\n } = options;\n this.shared = shared;\n this.treeShakingSharedExcludePlugins = treeShakingSharedExcludePlugins;\n this.mfName = name;\n this.outputDir = outputDir || 'independent-packages';\n this.plugins = plugins || [];\n this.treeShaking = treeShaking;\n this.manifest = manifest;\n this.injectTreeShakingUsedExports = injectTreeShakingUsedExports ?? true;\n this.library = library;\n this.sharedOptions = normalizeSharedOptions(shared);\n }\n\n static IndependentShareBuildAssetsFilename =\n 'independent-share-build-assets.json';\n\n apply(compiler: Compiler) {\n const { manifest } = this;\n const collectSharedEntryPlugin = new CollectSharedEntryPlugin({\n sharedOptions: this.sharedOptions,\n });\n collectSharedEntryPlugin.apply(compiler);\n\n compiler.hooks.thisCompilation.tap(\n 'IndependentSharedPlugin',\n (compilation) => {\n compilation.hooks.finishModules.tapPromise(\n {\n name: 'IndependentSharedPlugin',\n stage: 20,\n },\n async () => {\n await this.createIndependentCompilers(\n compiler,\n collectSharedEntryPlugin.getData(),\n );\n },\n );\n compilation.hooks.additionalTreeRuntimeRequirements.tap(\n 'OptimizeDependencyReferencedExportsPlugin',\n (chunk) => {\n compilation.addRuntimeModule(\n chunk,\n new IndependentSharedRuntimeModule(\n this.buildAssets,\n this.library?.type || 'global',\n ),\n );\n },\n );\n // inject buildAssets to stats\n if (!manifest) {\n return;\n }\n compilation.hooks.processAssets.tapPromise(\n {\n name: 'injectReferenceExports',\n stage:\n // biome-ignore lint/suspicious/noExplicitAny: <explanation>\n (compilation.constructor as any)\n .PROCESS_ASSETS_STAGE_OPTIMIZE_TRANSFER,\n },\n async () => {\n const stats = compilation.getAsset(StatsFileName);\n if (!stats) {\n return;\n }\n const statsContent = JSON.parse(\n stats.source.source().toString(),\n ) as Stats;\n\n const { shared } = statsContent;\n Object.entries(this.buildAssets).forEach(([key, item]) => {\n const targetShared = shared.find((s) => s.name === key);\n if (!targetShared) {\n return;\n }\n item.forEach(([entry, version, globalName]) => {\n if (version === targetShared.version) {\n targetShared.fallback = entry;\n targetShared.fallbackName = globalName;\n }\n });\n });\n\n compilation.updateAsset(\n StatsFileName,\n new compiler.webpack.sources.RawSource(\n JSON.stringify(statsContent),\n ),\n );\n },\n );\n },\n );\n }\n\n private createEntry(context: string) {\n const { sharedOptions } = this;\n const entryContent = sharedOptions.reduce((acc, cur, index) => {\n return `${acc}import shared_${index} from '${cur[0]}';\\n`;\n }, '');\n const entryPath = path.resolve(\n context,\n 'node_modules',\n '.federation',\n // name,\n 'shared-entry.js',\n );\n if (!fs.existsSync(path.dirname(entryPath))) {\n fs.mkdirSync(path.dirname(entryPath), { recursive: true });\n }\n fs.writeFileSync(entryPath, entryContent);\n return entryPath;\n }\n\n private async createIndependentCompilers(\n parentCompiler: Compiler,\n shareRequestsMap: ShareRequestsMap,\n ) {\n const { sharedOptions, outputDir } = this;\n this.buildAssets = {};\n\n const hasShareRequests = sharedOptions.some(\n ([shareName, shareConfig]) =>\n Boolean(shareConfig.treeShaking) &&\n Boolean(shareRequestsMap[shareName]?.requests.length),\n );\n if (!hasShareRequests) {\n return;\n }\n\n console.log('Start building shared fallback resources ...');\n\n await Promise.all(\n sharedOptions.map(async ([shareName, shareConfig]) => {\n if (!shareConfig.treeShaking) {\n return;\n }\n const shareRequests = shareRequestsMap[shareName]?.requests ?? [];\n for (let index = 0; index < shareRequests.length; index++) {\n const [request, version] = shareRequests[index];\n const sharedConfig = sharedOptions.find(\n ([name]) => name === shareName,\n )?.[1];\n const [shareFileName, globalName, sharedVersion] =\n await this.createIndependentCompiler(parentCompiler, {\n cleanOutput: index === 0,\n currentShare: {\n shareName,\n version,\n request,\n independentShareFileName: sharedConfig?.treeShaking?.filename,\n },\n });\n if (typeof shareFileName === 'string') {\n this.buildAssets[shareName] ||= [];\n this.buildAssets[shareName].push([\n path.join(resolveOutputDir(outputDir, shareName), shareFileName),\n sharedVersion,\n globalName,\n ]);\n }\n }\n }),\n );\n\n console.log('All shared fallback have been compiled successfully');\n }\n\n private async createIndependentCompiler(\n parentCompiler: Compiler,\n extraOptions: {\n currentShare: Omit<SharedContainerPluginOptions, 'mfName'>;\n cleanOutput: boolean;\n },\n ) {\n const {\n treeShaking,\n plugins,\n outputDir,\n sharedOptions,\n mfName,\n library,\n treeShakingSharedExcludePlugins,\n } = this;\n const outputDirWithShareName = resolveOutputDir(\n outputDir,\n extraOptions.currentShare.shareName,\n );\n\n const parentConfig = parentCompiler.options;\n\n const finalPlugins = [];\n const extraPlugin = new SharedContainerPlugin({\n mfName: `${mfName}_${treeShaking ? 't' : 'f'}`,\n library: library,\n ...extraOptions.currentShare,\n });\n (parentConfig.plugins || []).forEach((plugin) => {\n if (\n plugin !== undefined &&\n typeof plugin !== 'string' &&\n filterPlugin(plugin, treeShakingSharedExcludePlugins)\n ) {\n finalPlugins.push(plugin);\n }\n });\n plugins.forEach((plugin) => {\n finalPlugins.push(plugin);\n });\n finalPlugins.push(\n new ConsumeSharedPlugin({\n consumes: sharedOptions\n .filter(\n ([key, options]) =>\n extraOptions.currentShare.shareName !== (options.shareKey || key),\n )\n .map(([key, options]) => ({\n [key]: {\n import: false,\n shareKey: options.shareKey || key,\n shareScope: options.shareScope,\n requiredVersion: options.requiredVersion,\n strictVersion: options.strictVersion,\n singleton: options.singleton,\n packageName: options.packageName,\n eager: options.eager,\n },\n })),\n }),\n );\n\n if (treeShaking) {\n finalPlugins.push(\n new SharedUsedExportsOptimizerPlugin(\n sharedOptions,\n this.injectTreeShakingUsedExports,\n [IGNORED_ENTRY],\n this.manifest,\n ),\n );\n }\n finalPlugins.push(extraPlugin);\n const fullOutputDir = path.resolve(\n parentCompiler.outputPath,\n outputDirWithShareName,\n );\n // @ts-ignore webpack version is not the same as the one used in the plugin\n const compilerConfig: Configuration = {\n ...parentConfig,\n mode: parentConfig.mode || 'development',\n ignoreWarnings: [],\n entry: {\n [IGNORED_ENTRY]: this.createEntry(parentCompiler.context),\n },\n\n // 输出配置\n output: {\n path: fullOutputDir,\n clean: extraOptions.cleanOutput,\n publicPath: parentConfig.output?.publicPath || 'auto',\n },\n\n // 插件继承\n plugins: finalPlugins,\n\n // 优化配置继承\n optimization: {\n ...parentConfig.optimization,\n splitChunks: false, // 每个包独立,不拆分\n },\n };\n\n // 创建独立的 webpack compiler 实例\n const webpack = parentCompiler.webpack;\n const compiler = webpack.webpack(compilerConfig as any);\n\n // 设置文件系统\n if (parentCompiler.inputFileSystem) {\n compiler.inputFileSystem = parentCompiler.inputFileSystem;\n }\n if (parentCompiler.outputFileSystem) {\n compiler.outputFileSystem = parentCompiler.outputFileSystem;\n }\n if (parentCompiler.intermediateFileSystem) {\n compiler.intermediateFileSystem = parentCompiler.intermediateFileSystem;\n }\n\n const { currentShare } = extraOptions;\n\n return new Promise<any>((resolve, reject) => {\n compiler.run((err: any, stats: any) => {\n const shareName = currentShare?.shareName || 'unknown shared package';\n const hasStatsErrors =\n !!stats &&\n (stats.hasErrors?.() || stats.toJson?.()?.errors?.length > 0);\n if (err || hasStatsErrors) {\n const lines: string[] = [];\n if (err) {\n const errMsg = (err && (err.stack || err.message)) || String(err);\n lines.push(`Compiler error: ${errMsg}`);\n }\n if (stats?.toJson) {\n const json = stats.toJson({\n all: false,\n errors: true,\n warnings: false,\n errorDetails: true,\n moduleTrace: true,\n } as any);\n const errors = (json && json.errors) || [];\n if (errors.length) {\n lines.push(`Webpack errors (${errors.length}):`);\n const max = 5;\n for (let i = 0; i < Math.min(errors.length, max); i++) {\n const e: any = errors[i];\n const where =\n e.moduleName || e.file || e.moduleIdentifier || '';\n const loc = e.loc ? ` @ ${e.loc}` : '';\n const msg = e.message || e.details || String(e);\n lines.push(` [${i + 1}] ${where}${loc}`);\n lines.push(` ${msg}`);\n }\n if (errors.length > max) {\n lines.push(` ... and ${errors.length - max} more errors`);\n }\n }\n }\n console.error(\n `❌ Shared \"${shareName}\" compilation failed\\n${lines.join('\\n')}`,\n );\n reject(err || new Error(`Shared \"${shareName}\" compilation failed`));\n return;\n }\n\n console.log(`Shared \"${shareName}\" compilation succeeded`);\n\n resolve(extraPlugin.getData());\n });\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAwBA,MAAM,gBAAgB;AAQtB,MAAM,gBACJ,QACA,kCAA4C,EAAE,KAC3C;AACH,KAAI,CAAC,OACH,QAAO;CAET,MAAM,aAAa,OAAO,WAAW,OAAO,gBAAgB;AAC5D,KAAI,CAAC,WACH,QAAO;AAET,QAAO,CAAC;EACN;EACA;EACA;EACA;EACA;EACA,GAAG;EAC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AAI,IAAI,GAAG,IAAI,KAAK,IAAI,OAAO,QAAQ,IAAI,EAAE,KAAK;QACrD,MAAM,IAAS,OAAO;QACtB,MAAM,QACJ,EAAE,cAAc,EAAE,QAAQ,EAAE,oBAAoB;QAClD,MAAM,MAAM,EAAE,MAAM,MAAM,EAAE,QAAQ;QACpC,MAAM,MAAM,EAAE,WAAW,EAAE,WAAW,OAAO,EAAE;AAC/C,cAAM,KAAK,MAAM,IAAI,EAAE,IAAI,QAAQ,MAAM;AACzC,cAAM,KAAK,SAAS,MAAM;;AAE5B,WAAI,OAAO,SAAS,IAClB,OAAM,KAAK,aAAa,OAAO,SAAS,IAAI,cAAc;;;AAIhE,aAAQ,MACN,aAAa,UAAU,wBAAwB,MAAM,KAAK,KAAK,GAChE;AACD,YAAO,uBAAO,IAAI,MAAM,WAAW,UAAU,sBAAsB,CAAC;AACpE;;AAGF,YAAQ,IAAI,WAAW,UAAU,yBAAyB;AAE1D,YAAQ,YAAY,SAAS,CAAC;KAC9B;IACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@module-federation/enhanced",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.9.0",
|
|
4
4
|
"main": "./dist/src/index.js",
|
|
5
5
|
"types": "./dist/src/index.d.ts",
|
|
6
6
|
"repository": {
|
|
@@ -85,17 +85,17 @@
|
|
|
85
85
|
"dependencies": {
|
|
86
86
|
"schema-utils": "4.3.0",
|
|
87
87
|
"tapable": "2.3.0",
|
|
88
|
-
"@module-federation/webpack-bundler-runtime": "2.
|
|
89
|
-
"@module-federation/bridge-react-webpack-plugin": "2.
|
|
90
|
-
"@module-federation/dts-plugin": "2.
|
|
91
|
-
"@module-federation/error-codes": "2.
|
|
92
|
-
"@module-federation/inject-external-runtime-core-plugin": "2.
|
|
93
|
-
"@module-federation/managers": "2.
|
|
94
|
-
"@module-federation/manifest": "2.
|
|
95
|
-
"@module-federation/rspack": "2.
|
|
96
|
-
"@module-federation/runtime-tools": "2.
|
|
97
|
-
"@module-federation/sdk": "2.
|
|
98
|
-
"@module-federation/cli": "2.
|
|
88
|
+
"@module-federation/webpack-bundler-runtime": "2.9.0",
|
|
89
|
+
"@module-federation/bridge-react-webpack-plugin": "2.9.0",
|
|
90
|
+
"@module-federation/dts-plugin": "2.9.0",
|
|
91
|
+
"@module-federation/error-codes": "2.9.0",
|
|
92
|
+
"@module-federation/inject-external-runtime-core-plugin": "2.9.0",
|
|
93
|
+
"@module-federation/managers": "2.9.0",
|
|
94
|
+
"@module-federation/manifest": "2.9.0",
|
|
95
|
+
"@module-federation/rspack": "2.9.0",
|
|
96
|
+
"@module-federation/runtime-tools": "2.9.0",
|
|
97
|
+
"@module-federation/sdk": "2.9.0",
|
|
98
|
+
"@module-federation/cli": "2.9.0"
|
|
99
99
|
},
|
|
100
100
|
"scripts": {
|
|
101
101
|
"generate:schema": "node src/scripts/compile-schema.js && node src/scripts/generate-sdk-types.js",
|