@module-federation/node 0.0.0-fix-4748-shared-fallback-versions-20260604072020 → 0.0.0-fix-runtime-core-set-shared-lib-20260819111025

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/dist/node_modules/.pnpm/webpack@5.104.1_@swc_core@1.7.26_@swc_helpers@0.5.13__esbuild@0.28.1_webpack-cli@5.1.4/node_modules/webpack/types.d.mts +1 -0
  2. package/dist/node_modules/.pnpm/webpack@5.104.1_@swc_core@1.7.26_@swc_helpers@0.5.13__esbuild@0.28.1_webpack-cli@5.1.4/node_modules/webpack/types.d.ts +1 -0
  3. package/dist/plugins/createBundlerLogger.js +9 -0
  4. package/dist/plugins/createBundlerLogger.js.map +1 -0
  5. package/dist/plugins/createBundlerLogger.mjs +8 -0
  6. package/dist/plugins/createBundlerLogger.mjs.map +1 -0
  7. package/dist/src/plugins/DynamicFilesystemChunkLoadingRuntimeModule.d.mts +2 -4
  8. package/dist/src/plugins/DynamicFilesystemChunkLoadingRuntimeModule.d.ts +2 -4
  9. package/dist/src/plugins/DynamicFilesystemChunkLoadingRuntimeModule.js +2 -3
  10. package/dist/src/plugins/DynamicFilesystemChunkLoadingRuntimeModule.js.map +1 -1
  11. package/dist/src/plugins/DynamicFilesystemChunkLoadingRuntimeModule.mjs +1 -2
  12. package/dist/src/plugins/DynamicFilesystemChunkLoadingRuntimeModule.mjs.map +1 -1
  13. package/dist/src/plugins/NodeFederationPlugin.js +2 -2
  14. package/dist/src/plugins/NodeFederationPlugin.js.map +1 -1
  15. package/dist/src/plugins/NodeFederationPlugin.mjs +2 -2
  16. package/dist/src/plugins/NodeFederationPlugin.mjs.map +1 -1
  17. package/dist/src/plugins/RemotePublicPathRuntimeModule.d.mts +1 -3
  18. package/dist/src/plugins/RemotePublicPathRuntimeModule.d.ts +1 -3
  19. package/dist/src/plugins/StreamingTargetPlugin.js.map +1 -1
  20. package/dist/src/plugins/StreamingTargetPlugin.mjs.map +1 -1
  21. package/dist/src/plugins/webpackChunkUtilities.d.mts +1 -1
  22. package/dist/src/plugins/webpackChunkUtilities.d.ts +1 -1
  23. package/dist/src/utils/flush-chunks.d.mts +4 -2
  24. package/dist/src/utils/flush-chunks.d.ts +4 -2
  25. package/dist/src/utils/flush-chunks.js +116 -74
  26. package/dist/src/utils/flush-chunks.js.map +1 -1
  27. package/dist/src/utils/flush-chunks.mjs +116 -74
  28. package/dist/src/utils/flush-chunks.mjs.map +1 -1
  29. package/package.json +7 -4
@@ -0,0 +1,9 @@
1
+ const require_runtime = require('../_virtual/_rolldown/runtime.js');
2
+ let _module_federation_sdk = require("@module-federation/sdk");
3
+
4
+ //#region src/plugins/createBundlerLogger.ts
5
+ const createBundlerLogger = typeof _module_federation_sdk.createInfrastructureLogger === "function" ? _module_federation_sdk.createInfrastructureLogger : _module_federation_sdk.createLogger;
6
+
7
+ //#endregion
8
+ exports.createBundlerLogger = createBundlerLogger;
9
+ //# sourceMappingURL=createBundlerLogger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createBundlerLogger.js","names":["createInfrastructureLogger","createLogger"],"sources":["../../src/plugins/createBundlerLogger.ts"],"sourcesContent":["import {\n createInfrastructureLogger,\n createLogger,\n} from '@module-federation/sdk';\n\nexport const createBundlerLogger: typeof createLogger =\n typeof createInfrastructureLogger === 'function'\n ? (createInfrastructureLogger as unknown as typeof createLogger)\n : createLogger;\n"],"mappings":";;;;AAKA,MAAa,sBACX,OAAOA,sDAA+B,aACjCA,oDACDC"}
@@ -0,0 +1,8 @@
1
+ import { createInfrastructureLogger, createLogger } from "@module-federation/sdk";
2
+
3
+ //#region src/plugins/createBundlerLogger.ts
4
+ const createBundlerLogger = typeof createInfrastructureLogger === "function" ? createInfrastructureLogger : createLogger;
5
+
6
+ //#endregion
7
+ export { createBundlerLogger };
8
+ //# sourceMappingURL=createBundlerLogger.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createBundlerLogger.mjs","names":[],"sources":["../../src/plugins/createBundlerLogger.ts"],"sourcesContent":["import {\n createInfrastructureLogger,\n createLogger,\n} from '@module-federation/sdk';\n\nexport const createBundlerLogger: typeof createLogger =\n typeof createInfrastructureLogger === 'function'\n ? (createInfrastructureLogger as unknown as typeof createLogger)\n : createLogger;\n"],"mappings":";;;AAKA,MAAa,sBACX,OAAO,+BAA+B,aACjC,6BACD"}
@@ -1,10 +1,8 @@
1
- import * as tapable from "tapable";
2
1
  import { SyncWaterfallHook } from "tapable";
3
- import * as webpack from "webpack";
4
2
  import { Chunk, Compiler } from "webpack";
5
3
 
6
4
  //#region src/plugins/DynamicFilesystemChunkLoadingRuntimeModule.d.ts
7
- declare const RuntimeModule: typeof webpack.RuntimeModule;
5
+ declare const RuntimeModule: typeof undefined;
8
6
  interface DynamicFilesystemChunkLoadingRuntimeModuleOptions {
9
7
  baseURI: Compiler['options']['output']['publicPath'];
10
8
  promiseBaseURI?: string;
@@ -20,7 +18,7 @@ declare class DynamicFilesystemChunkLoadingRuntimeModule extends RuntimeModule {
20
18
  private options;
21
19
  private chunkLoadingContext;
22
20
  hooks: {
23
- strategyCase: SyncWaterfallHook<unknown, unknown, tapable.UnsetAdditionalOptions>;
21
+ strategyCase: SyncWaterfallHook<unknown, unknown, undefined>;
24
22
  };
25
23
  private logger;
26
24
  constructor(runtimeRequirements: Set<string>, options: DynamicFilesystemChunkLoadingRuntimeModuleOptions, chunkLoadingContext: ChunkLoadingContext);
@@ -1,10 +1,8 @@
1
- import * as webpack from "webpack";
2
1
  import { Chunk, Compiler } from "webpack";
3
- import * as tapable from "tapable";
4
2
  import { SyncWaterfallHook } from "tapable";
5
3
 
6
4
  //#region src/plugins/DynamicFilesystemChunkLoadingRuntimeModule.d.ts
7
- declare const RuntimeModule: typeof webpack.RuntimeModule;
5
+ declare const RuntimeModule: typeof undefined;
8
6
  interface DynamicFilesystemChunkLoadingRuntimeModuleOptions {
9
7
  baseURI: Compiler['options']['output']['publicPath'];
10
8
  promiseBaseURI?: string;
@@ -20,7 +18,7 @@ declare class DynamicFilesystemChunkLoadingRuntimeModule extends RuntimeModule {
20
18
  private options;
21
19
  private chunkLoadingContext;
22
20
  hooks: {
23
- strategyCase: SyncWaterfallHook<unknown, unknown, tapable.UnsetAdditionalOptions>;
21
+ strategyCase: SyncWaterfallHook<unknown, unknown, undefined>;
24
22
  };
25
23
  private logger;
26
24
  constructor(runtimeRequirements: Set<string>, options: DynamicFilesystemChunkLoadingRuntimeModuleOptions, chunkLoadingContext: ChunkLoadingContext);
@@ -1,21 +1,20 @@
1
1
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
2
2
  const require_runtime = require('../../_virtual/_rolldown/runtime.js');
3
3
  const require_src_plugins_webpackChunkUtilities = require('./webpackChunkUtilities.js');
4
+ const require_createBundlerLogger = require('../../plugins/createBundlerLogger.js');
4
5
  const require_src_filesystem_stratagies = require('../filesystem/stratagies.js');
5
6
  let _module_federation_sdk_normalize_webpack_path = require("@module-federation/sdk/normalize-webpack-path");
6
7
  let tapable = require("tapable");
7
- let _module_federation_sdk = require("@module-federation/sdk");
8
8
 
9
9
  //#region src/plugins/DynamicFilesystemChunkLoadingRuntimeModule.ts
10
10
  const { RuntimeGlobals, RuntimeModule } = require((0, _module_federation_sdk_normalize_webpack_path.normalizeWebpackPath)("webpack"));
11
11
  const { getUndoPath } = require((0, _module_federation_sdk_normalize_webpack_path.normalizeWebpackPath)("webpack/lib/util/identifier"));
12
12
  const compileBooleanMatcher = require((0, _module_federation_sdk_normalize_webpack_path.normalizeWebpackPath)("webpack/lib/util/compileBooleanMatcher"));
13
- const createBundlerLogger = typeof _module_federation_sdk.createInfrastructureLogger === "function" ? _module_federation_sdk.createInfrastructureLogger : _module_federation_sdk.createLogger;
14
13
  var DynamicFilesystemChunkLoadingRuntimeModule = class extends RuntimeModule {
15
14
  constructor(runtimeRequirements, options, chunkLoadingContext) {
16
15
  super("readFile chunk loading", RuntimeModule.STAGE_ATTACH + 1);
17
16
  this.hooks = { strategyCase: new tapable.SyncWaterfallHook(["source"]) };
18
- this.logger = createBundlerLogger("[ DynamicFilesystemChunkLoadingRuntimeModule ]");
17
+ this.logger = require_createBundlerLogger.createBundlerLogger("[ DynamicFilesystemChunkLoadingRuntimeModule ]");
19
18
  this.runtimeRequirements = runtimeRequirements;
20
19
  this.options = options;
21
20
  this.chunkLoadingContext = chunkLoadingContext;
@@ -1 +1 @@
1
- {"version":3,"file":"DynamicFilesystemChunkLoadingRuntimeModule.js","names":["createInfrastructureLogger","createLogger","SyncWaterfallHook","getInitialChunkIds","fileSystemRunInContextStrategy","httpEvalStrategy","httpVmStrategy","handleOnChunkLoad","generateInstallChunk","generateLoadScript","generateLoadingCode","generateExternalInstallChunkCode","generateHmrCode","generateHmrManifestCode"],"sources":["../../../src/plugins/DynamicFilesystemChunkLoadingRuntimeModule.ts"],"sourcesContent":["/*\n MIT License http://www.opensource.org/licenses/mit-license.php\n*/\nimport type { Chunk, Compiler } from 'webpack';\nimport { normalizeWebpackPath } from '@module-federation/sdk/normalize-webpack-path';\nconst { RuntimeGlobals, RuntimeModule } = require(\n normalizeWebpackPath('webpack'),\n) as typeof import('webpack');\nconst { getUndoPath } = require(\n normalizeWebpackPath('webpack/lib/util/identifier'),\n) as typeof import('webpack/lib/util/identifier');\nimport { SyncWaterfallHook } from 'tapable';\nconst compileBooleanMatcher = require(\n normalizeWebpackPath('webpack/lib/util/compileBooleanMatcher'),\n) as typeof import('webpack/lib/util/compileBooleanMatcher');\nimport {\n generateHmrCode,\n getInitialChunkIds,\n generateLoadingCode,\n generateHmrManifestCode,\n handleOnChunkLoad,\n generateLoadScript,\n generateInstallChunk,\n generateExternalInstallChunkCode,\n} from './webpackChunkUtilities';\nimport {\n createInfrastructureLogger,\n createLogger,\n} from '@module-federation/sdk';\nimport {\n fileSystemRunInContextStrategy,\n httpEvalStrategy,\n httpVmStrategy,\n} from '../filesystem/stratagies';\n\ninterface RemotesByType {\n functional: string[];\n normal: string[];\n}\n\ninterface DynamicFilesystemChunkLoadingRuntimeModuleOptions {\n baseURI: Compiler['options']['output']['publicPath'];\n promiseBaseURI?: string;\n remotes: Record<string, string>;\n name?: string;\n debug?: boolean;\n}\n\ninterface ChunkLoadingContext {\n webpack: Compiler['webpack'];\n}\n\nconst createBundlerLogger: typeof createLogger =\n typeof createInfrastructureLogger === 'function'\n ? (createInfrastructureLogger as unknown as typeof createLogger)\n : createLogger;\n\nclass DynamicFilesystemChunkLoadingRuntimeModule extends RuntimeModule {\n private runtimeRequirements: Set<string>;\n private options: DynamicFilesystemChunkLoadingRuntimeModuleOptions;\n private chunkLoadingContext: ChunkLoadingContext;\n hooks = {\n strategyCase: new SyncWaterfallHook(['source']),\n };\n private logger = createBundlerLogger(\n '[ DynamicFilesystemChunkLoadingRuntimeModule ]',\n );\n\n constructor(\n runtimeRequirements: Set<string>,\n options: DynamicFilesystemChunkLoadingRuntimeModuleOptions,\n chunkLoadingContext: ChunkLoadingContext,\n ) {\n super('readFile chunk loading', RuntimeModule.STAGE_ATTACH + 1);\n this.runtimeRequirements = runtimeRequirements;\n\n this.options = options;\n this.chunkLoadingContext = chunkLoadingContext;\n }\n\n /**\n * @private\n * @param {Chunk} chunk chunk\n * @param {string} rootOutputDir root output directory\n * @returns {string} generated code\n */\n _generateBaseUri(chunk: Chunk, rootOutputDir: string) {\n const options = chunk.getEntryOptions();\n if (options && options.baseUri) {\n return `${RuntimeGlobals.baseURI} = ${JSON.stringify(options.baseUri)};`;\n }\n\n return `${RuntimeGlobals.baseURI} = require(\"url\").pathToFileURL(${\n rootOutputDir\n ? `__dirname + ${JSON.stringify('/' + rootOutputDir)}`\n : '__filename'\n });`;\n }\n\n /**\n * @private\n * @param {unknown[]} items item to log\n */\n _getLogger(...items: unknown[]) {\n if (!this.options.debug) {\n return '';\n }\n\n return `console.log(${items.join(',')});`;\n }\n\n /**\n * @returns {string} runtime code\n */\n override generate() {\n const { remotes = {}, name } = this.options;\n const { webpack } = this.chunkLoadingContext;\n const { chunkGraph, chunk, compilation } = this;\n const { Template } = webpack;\n if (!chunkGraph || !chunk || !compilation) {\n this.logger.warn('Missing required properties. Returning empty string.');\n return '';\n }\n\n const infrastructureLogger = compilation.getLogger?.(\n 'DynamicFilesystemChunkLoadingRuntimeModule',\n );\n if (infrastructureLogger) {\n this.logger.setDelegate(infrastructureLogger as any);\n }\n\n const { runtimeTemplate } = compilation;\n const jsModulePlugin =\n webpack?.javascript?.JavascriptModulesPlugin ||\n require('webpack/lib/javascript/JavascriptModulesPlugin');\n const { chunkHasJs } = jsModulePlugin;\n const fn = RuntimeGlobals.ensureChunkHandlers;\n\n const conditionMap = chunkGraph.getChunkConditionMap(chunk, chunkHasJs);\n const hasJsMatcher = compileBooleanMatcher(conditionMap);\n const initialChunkIds = getInitialChunkIds(chunk, chunkGraph, chunkHasJs);\n\n const outputName = compilation.getPath(\n jsModulePlugin.getChunkFilenameTemplate(chunk, compilation.outputOptions),\n { chunk, contentHashType: 'javascript' },\n );\n const rootOutputDir = getUndoPath(\n outputName,\n compilation.outputOptions.path || '',\n false,\n );\n const stateExpression = this.runtimeRequirements.has(\n RuntimeGlobals.hmrDownloadUpdateHandlers,\n )\n ? `${RuntimeGlobals.hmrRuntimeStatePrefix}_readFileVm`\n : undefined;\n\n const dynamicFilesystemChunkLoadingPluginCode = Template.asString([\n fileSystemRunInContextStrategy.toString(),\n httpEvalStrategy.toString(),\n httpVmStrategy.toString(),\n 'const loadChunkStrategy = async (strategyType,chunkId,rootOutputDir, remotes, callback) => {',\n Template.indent([\n 'switch (strategyType) {',\n Template.indent([\n 'case \"filesystem\": return await fileSystemRunInContextStrategy(chunkId,rootOutputDir, remotes, callback);',\n 'case \"http-eval\": return await httpEvalStrategy(chunkId,rootOutputDir, remotes, callback);',\n 'case \"http-vm\": return await httpVmStrategy(chunkId,rootOutputDir, remotes, callback);',\n this.hooks.strategyCase.call(\n 'default: throw new Error(\"Invalid strategy type\");',\n ) as string,\n ]),\n '}',\n ]),\n '};',\n ]);\n\n return Template.asString([\n dynamicFilesystemChunkLoadingPluginCode,\n this.runtimeRequirements.has(RuntimeGlobals.baseURI)\n ? this._generateBaseUri(chunk, rootOutputDir)\n : '// no baseURI',\n '',\n '// object to store loaded chunks',\n '// \"0\" means \"already loaded\", Promise means loading',\n `var installedChunks = ${\n stateExpression ? `${stateExpression} = ${stateExpression} || ` : ''\n }{`,\n Template.indent(\n Array.from(initialChunkIds, (id) => `${JSON.stringify(id)}: 0`).join(\n ',\\n',\n ),\n ),\n '};',\n '',\n handleOnChunkLoad(\n this.runtimeRequirements.has(RuntimeGlobals.onChunksLoaded),\n runtimeTemplate,\n ),\n '',\n generateInstallChunk(\n runtimeTemplate,\n this.runtimeRequirements.has(RuntimeGlobals.onChunksLoaded),\n ),\n '',\n this.runtimeRequirements.has(RuntimeGlobals.ensureChunkHandlers)\n ? generateLoadScript(runtimeTemplate)\n : '// no remote script loader needed',\n this.runtimeRequirements.has(RuntimeGlobals.ensureChunkHandlers)\n ? generateLoadingCode(\n this.runtimeRequirements.has(RuntimeGlobals.ensureChunkHandlers),\n fn,\n hasJsMatcher,\n rootOutputDir,\n remotes,\n name,\n )\n : '// no chunk loading',\n '',\n generateExternalInstallChunkCode(\n this.runtimeRequirements.has(RuntimeGlobals.externalInstallChunk),\n this.options.debug,\n ),\n '',\n generateHmrCode(\n this.runtimeRequirements.has(RuntimeGlobals.hmrDownloadUpdateHandlers),\n rootOutputDir,\n ),\n '',\n generateHmrManifestCode(\n this.runtimeRequirements.has(RuntimeGlobals.hmrDownloadManifest),\n rootOutputDir,\n ),\n ]);\n }\n}\n\nexport default DynamicFilesystemChunkLoadingRuntimeModule;\n"],"mappings":";;;;;;;;;AAKA,MAAM,EAAE,gBAAgB,kBAAkB,gFACnB,UAAU,CAChC;AACD,MAAM,EAAE,gBAAgB,gFACD,8BAA8B,CACpD;AAED,MAAM,wBAAwB,gFACP,yCAAyC,CAC/D;AAsCD,MAAM,sBACJ,OAAOA,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AAI,eAAe,oBAAoB,EAChE,cACD;GACF,CAAC"}
1
+ {"version":3,"file":"DynamicFilesystemChunkLoadingRuntimeModule.js","names":["SyncWaterfallHook","createBundlerLogger","getInitialChunkIds","fileSystemRunInContextStrategy","httpEvalStrategy","httpVmStrategy","handleOnChunkLoad","generateInstallChunk","generateLoadScript","generateLoadingCode","generateExternalInstallChunkCode","generateHmrCode","generateHmrManifestCode"],"sources":["../../../src/plugins/DynamicFilesystemChunkLoadingRuntimeModule.ts"],"sourcesContent":["/*\n MIT License http://www.opensource.org/licenses/mit-license.php\n*/\nimport type { Chunk, Compiler } from 'webpack';\nimport { normalizeWebpackPath } from '@module-federation/sdk/normalize-webpack-path';\nconst { RuntimeGlobals, RuntimeModule } = require(\n normalizeWebpackPath('webpack'),\n) as typeof import('webpack');\nconst { getUndoPath } = require(\n normalizeWebpackPath('webpack/lib/util/identifier'),\n) as typeof import('webpack/lib/util/identifier');\nimport { SyncWaterfallHook } from 'tapable';\nconst compileBooleanMatcher = require(\n normalizeWebpackPath('webpack/lib/util/compileBooleanMatcher'),\n) as typeof import('webpack/lib/util/compileBooleanMatcher');\nimport {\n generateHmrCode,\n getInitialChunkIds,\n generateLoadingCode,\n generateHmrManifestCode,\n handleOnChunkLoad,\n generateLoadScript,\n generateInstallChunk,\n generateExternalInstallChunkCode,\n} from './webpackChunkUtilities';\nimport { createBundlerLogger } from './createBundlerLogger';\nimport {\n fileSystemRunInContextStrategy,\n httpEvalStrategy,\n httpVmStrategy,\n} from '../filesystem/stratagies';\n\ninterface RemotesByType {\n functional: string[];\n normal: string[];\n}\n\ninterface DynamicFilesystemChunkLoadingRuntimeModuleOptions {\n baseURI: Compiler['options']['output']['publicPath'];\n promiseBaseURI?: string;\n remotes: Record<string, string>;\n name?: string;\n debug?: boolean;\n}\n\ninterface ChunkLoadingContext {\n webpack: Compiler['webpack'];\n}\n\nclass DynamicFilesystemChunkLoadingRuntimeModule extends RuntimeModule {\n private runtimeRequirements: Set<string>;\n private options: DynamicFilesystemChunkLoadingRuntimeModuleOptions;\n private chunkLoadingContext: ChunkLoadingContext;\n hooks = {\n strategyCase: new SyncWaterfallHook(['source']),\n };\n private logger = createBundlerLogger(\n '[ DynamicFilesystemChunkLoadingRuntimeModule ]',\n );\n\n constructor(\n runtimeRequirements: Set<string>,\n options: DynamicFilesystemChunkLoadingRuntimeModuleOptions,\n chunkLoadingContext: ChunkLoadingContext,\n ) {\n super('readFile chunk loading', RuntimeModule.STAGE_ATTACH + 1);\n this.runtimeRequirements = runtimeRequirements;\n\n this.options = options;\n this.chunkLoadingContext = chunkLoadingContext;\n }\n\n /**\n * @private\n * @param {Chunk} chunk chunk\n * @param {string} rootOutputDir root output directory\n * @returns {string} generated code\n */\n _generateBaseUri(chunk: Chunk, rootOutputDir: string) {\n const options = chunk.getEntryOptions();\n if (options && options.baseUri) {\n return `${RuntimeGlobals.baseURI} = ${JSON.stringify(options.baseUri)};`;\n }\n\n return `${RuntimeGlobals.baseURI} = require(\"url\").pathToFileURL(${\n rootOutputDir\n ? `__dirname + ${JSON.stringify('/' + rootOutputDir)}`\n : '__filename'\n });`;\n }\n\n /**\n * @private\n * @param {unknown[]} items item to log\n */\n _getLogger(...items: unknown[]) {\n if (!this.options.debug) {\n return '';\n }\n\n return `console.log(${items.join(',')});`;\n }\n\n /**\n * @returns {string} runtime code\n */\n override generate() {\n const { remotes = {}, name } = this.options;\n const { webpack } = this.chunkLoadingContext;\n const { chunkGraph, chunk, compilation } = this;\n const { Template } = webpack;\n if (!chunkGraph || !chunk || !compilation) {\n this.logger.warn('Missing required properties. Returning empty string.');\n return '';\n }\n\n const infrastructureLogger = compilation.getLogger?.(\n 'DynamicFilesystemChunkLoadingRuntimeModule',\n );\n if (infrastructureLogger) {\n this.logger.setDelegate(infrastructureLogger as any);\n }\n\n const { runtimeTemplate } = compilation;\n const jsModulePlugin =\n webpack?.javascript?.JavascriptModulesPlugin ||\n require('webpack/lib/javascript/JavascriptModulesPlugin');\n const { chunkHasJs } = jsModulePlugin;\n const fn = RuntimeGlobals.ensureChunkHandlers;\n\n const conditionMap = chunkGraph.getChunkConditionMap(chunk, chunkHasJs);\n const hasJsMatcher = compileBooleanMatcher(conditionMap);\n const initialChunkIds = getInitialChunkIds(chunk, chunkGraph, chunkHasJs);\n\n const outputName = compilation.getPath(\n jsModulePlugin.getChunkFilenameTemplate(chunk, compilation.outputOptions),\n { chunk, contentHashType: 'javascript' },\n );\n const rootOutputDir = getUndoPath(\n outputName,\n compilation.outputOptions.path || '',\n false,\n );\n const stateExpression = this.runtimeRequirements.has(\n RuntimeGlobals.hmrDownloadUpdateHandlers,\n )\n ? `${RuntimeGlobals.hmrRuntimeStatePrefix}_readFileVm`\n : undefined;\n\n const dynamicFilesystemChunkLoadingPluginCode = Template.asString([\n fileSystemRunInContextStrategy.toString(),\n httpEvalStrategy.toString(),\n httpVmStrategy.toString(),\n 'const loadChunkStrategy = async (strategyType,chunkId,rootOutputDir, remotes, callback) => {',\n Template.indent([\n 'switch (strategyType) {',\n Template.indent([\n 'case \"filesystem\": return await fileSystemRunInContextStrategy(chunkId,rootOutputDir, remotes, callback);',\n 'case \"http-eval\": return await httpEvalStrategy(chunkId,rootOutputDir, remotes, callback);',\n 'case \"http-vm\": return await httpVmStrategy(chunkId,rootOutputDir, remotes, callback);',\n this.hooks.strategyCase.call(\n 'default: throw new Error(\"Invalid strategy type\");',\n ) as string,\n ]),\n '}',\n ]),\n '};',\n ]);\n\n return Template.asString([\n dynamicFilesystemChunkLoadingPluginCode,\n this.runtimeRequirements.has(RuntimeGlobals.baseURI)\n ? this._generateBaseUri(chunk, rootOutputDir)\n : '// no baseURI',\n '',\n '// object to store loaded chunks',\n '// \"0\" means \"already loaded\", Promise means loading',\n `var installedChunks = ${\n stateExpression ? `${stateExpression} = ${stateExpression} || ` : ''\n }{`,\n Template.indent(\n Array.from(initialChunkIds, (id) => `${JSON.stringify(id)}: 0`).join(\n ',\\n',\n ),\n ),\n '};',\n '',\n handleOnChunkLoad(\n this.runtimeRequirements.has(RuntimeGlobals.onChunksLoaded),\n runtimeTemplate,\n ),\n '',\n generateInstallChunk(\n runtimeTemplate,\n this.runtimeRequirements.has(RuntimeGlobals.onChunksLoaded),\n ),\n '',\n this.runtimeRequirements.has(RuntimeGlobals.ensureChunkHandlers)\n ? generateLoadScript(runtimeTemplate)\n : '// no remote script loader needed',\n this.runtimeRequirements.has(RuntimeGlobals.ensureChunkHandlers)\n ? generateLoadingCode(\n this.runtimeRequirements.has(RuntimeGlobals.ensureChunkHandlers),\n fn,\n hasJsMatcher,\n rootOutputDir,\n remotes,\n name,\n )\n : '// no chunk loading',\n '',\n generateExternalInstallChunkCode(\n this.runtimeRequirements.has(RuntimeGlobals.externalInstallChunk),\n this.options.debug,\n ),\n '',\n generateHmrCode(\n this.runtimeRequirements.has(RuntimeGlobals.hmrDownloadUpdateHandlers),\n rootOutputDir,\n ),\n '',\n generateHmrManifestCode(\n this.runtimeRequirements.has(RuntimeGlobals.hmrDownloadManifest),\n rootOutputDir,\n ),\n ]);\n }\n}\n\nexport default DynamicFilesystemChunkLoadingRuntimeModule;\n"],"mappings":";;;;;;;;;AAKA,MAAM,EAAE,gBAAgB,kBAAkB,gFACnB,UAAU,CAChC;AACD,MAAM,EAAE,gBAAgB,gFACD,8BAA8B,CACpD;AAED,MAAM,wBAAwB,gFACP,yCAAyC,CAC/D;AAmCD,IAAM,6CAAN,cAAyD,cAAc;CAWrE,YACE,qBACA,SACA,qBACA;AACA,QAAM,0BAA0B,cAAc,eAAe,EAAE;eAZzD,EACN,cAAc,IAAIA,0BAAkB,CAAC,SAAS,CAAC,EAChD;gBACgBC,gDACf,iDACD;AAQC,OAAK,sBAAsB;AAE3B,OAAK,UAAU;AACf,OAAK,sBAAsB;;;;;;;;CAS7B,iBAAiB,OAAc,eAAuB;EACpD,MAAM,UAAU,MAAM,iBAAiB;AACvC,MAAI,WAAW,QAAQ,QACrB,QAAO,GAAG,eAAe,QAAQ,KAAK,KAAK,UAAU,QAA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CAAC;IACF;IACD,CAAC;GACF;GACD,CAAC;AAEF,SAAO,SAAS,SAAS;GACvB;GACA,KAAK,oBAAoB,IAAI,eAAe,QAAQ,GAChD,KAAK,iBAAiB,OAAO,cAAc,GAC3C;GACJ;GACA;GACA;GACA,yBACE,kBAAkB,GAAG,gBAAgB,KAAK,gBAAgB,QAAQ,GACnE;GACD,SAAS,OACP,MAAM,KAAK,kBAAkB,OAAO,GAAG,KAAK,UAAU,GAAG,CAAC,KAAK,CAAC,KAC9D,MACD,CACF;GACD;GACA;GACAC,4DACE,KAAK,oBAAoB,IAAI,eAAe,eAAe,EAC3D,gBACD;GACD;GACAC,+DACE,iBACA,KAAK,oBAAoB,IAAI,eAAe,eAAe,CAC5D;GACD;GACA,KAAK,oBAAoB,IAAI,eAAe,oBAAoB,GAC5DC,6DAAmB,gBAAgB,GACnC;GACJ,KAAK,oBAAoB,IAAI,eAAe,oBAAoB,GAC5DC,8DACE,KAAK,oBAAoB,IAAI,eAAe,oBAAoB,EAChE,IACA,cACA,eACA,SACA,KACD,GACD;GACJ;GACAC,2EACE,KAAK,oBAAoB,IAAI,eAAe,qBAAqB,EACjE,KAAK,QAAQ,MACd;GACD;GACAC,0DACE,KAAK,oBAAoB,IAAI,eAAe,0BAA0B,EACtE,cACD;GACD;GACAC,kEACE,KAAK,oBAAoB,IAAI,eAAe,oBAAoB,EAChE,cACD;GACF,CAAC"}
@@ -1,15 +1,14 @@
1
1
  import { __require } from "../../_virtual/_rolldown/runtime.mjs";
2
2
  import { generateExternalInstallChunkCode, generateHmrCode, generateHmrManifestCode, generateInstallChunk, generateLoadScript, generateLoadingCode, getInitialChunkIds, handleOnChunkLoad } from "./webpackChunkUtilities.mjs";
3
+ import { createBundlerLogger } from "../../plugins/createBundlerLogger.mjs";
3
4
  import { fileSystemRunInContextStrategy, httpEvalStrategy, httpVmStrategy } from "../filesystem/stratagies.mjs";
4
5
  import { normalizeWebpackPath } from "@module-federation/sdk/normalize-webpack-path";
5
6
  import { SyncWaterfallHook } from "tapable";
6
- import { createInfrastructureLogger, createLogger } from "@module-federation/sdk";
7
7
 
8
8
  //#region src/plugins/DynamicFilesystemChunkLoadingRuntimeModule.ts
9
9
  const { RuntimeGlobals, RuntimeModule } = __require(normalizeWebpackPath("webpack"));
10
10
  const { getUndoPath } = __require(normalizeWebpackPath("webpack/lib/util/identifier"));
11
11
  const compileBooleanMatcher = __require(normalizeWebpackPath("webpack/lib/util/compileBooleanMatcher"));
12
- const createBundlerLogger = typeof createInfrastructureLogger === "function" ? createInfrastructureLogger : createLogger;
13
12
  var DynamicFilesystemChunkLoadingRuntimeModule = class extends RuntimeModule {
14
13
  constructor(runtimeRequirements, options, chunkLoadingContext) {
15
14
  super("readFile chunk loading", RuntimeModule.STAGE_ATTACH + 1);
@@ -1 +1 @@
1
- {"version":3,"file":"DynamicFilesystemChunkLoadingRuntimeModule.mjs","names":[],"sources":["../../../src/plugins/DynamicFilesystemChunkLoadingRuntimeModule.ts"],"sourcesContent":["/*\n MIT License http://www.opensource.org/licenses/mit-license.php\n*/\nimport type { Chunk, Compiler } from 'webpack';\nimport { normalizeWebpackPath } from '@module-federation/sdk/normalize-webpack-path';\nconst { RuntimeGlobals, RuntimeModule } = require(\n normalizeWebpackPath('webpack'),\n) as typeof import('webpack');\nconst { getUndoPath } = require(\n normalizeWebpackPath('webpack/lib/util/identifier'),\n) as typeof import('webpack/lib/util/identifier');\nimport { SyncWaterfallHook } from 'tapable';\nconst compileBooleanMatcher = require(\n normalizeWebpackPath('webpack/lib/util/compileBooleanMatcher'),\n) as typeof import('webpack/lib/util/compileBooleanMatcher');\nimport {\n generateHmrCode,\n getInitialChunkIds,\n generateLoadingCode,\n generateHmrManifestCode,\n handleOnChunkLoad,\n generateLoadScript,\n generateInstallChunk,\n generateExternalInstallChunkCode,\n} from './webpackChunkUtilities';\nimport {\n createInfrastructureLogger,\n createLogger,\n} from '@module-federation/sdk';\nimport {\n fileSystemRunInContextStrategy,\n httpEvalStrategy,\n httpVmStrategy,\n} from '../filesystem/stratagies';\n\ninterface RemotesByType {\n functional: string[];\n normal: string[];\n}\n\ninterface DynamicFilesystemChunkLoadingRuntimeModuleOptions {\n baseURI: Compiler['options']['output']['publicPath'];\n promiseBaseURI?: string;\n remotes: Record<string, string>;\n name?: string;\n debug?: boolean;\n}\n\ninterface ChunkLoadingContext {\n webpack: Compiler['webpack'];\n}\n\nconst createBundlerLogger: typeof createLogger =\n typeof createInfrastructureLogger === 'function'\n ? (createInfrastructureLogger as unknown as typeof createLogger)\n : createLogger;\n\nclass DynamicFilesystemChunkLoadingRuntimeModule extends RuntimeModule {\n private runtimeRequirements: Set<string>;\n private options: DynamicFilesystemChunkLoadingRuntimeModuleOptions;\n private chunkLoadingContext: ChunkLoadingContext;\n hooks = {\n strategyCase: new SyncWaterfallHook(['source']),\n };\n private logger = createBundlerLogger(\n '[ DynamicFilesystemChunkLoadingRuntimeModule ]',\n );\n\n constructor(\n runtimeRequirements: Set<string>,\n options: DynamicFilesystemChunkLoadingRuntimeModuleOptions,\n chunkLoadingContext: ChunkLoadingContext,\n ) {\n super('readFile chunk loading', RuntimeModule.STAGE_ATTACH + 1);\n this.runtimeRequirements = runtimeRequirements;\n\n this.options = options;\n this.chunkLoadingContext = chunkLoadingContext;\n }\n\n /**\n * @private\n * @param {Chunk} chunk chunk\n * @param {string} rootOutputDir root output directory\n * @returns {string} generated code\n */\n _generateBaseUri(chunk: Chunk, rootOutputDir: string) {\n const options = chunk.getEntryOptions();\n if (options && options.baseUri) {\n return `${RuntimeGlobals.baseURI} = ${JSON.stringify(options.baseUri)};`;\n }\n\n return `${RuntimeGlobals.baseURI} = require(\"url\").pathToFileURL(${\n rootOutputDir\n ? `__dirname + ${JSON.stringify('/' + rootOutputDir)}`\n : '__filename'\n });`;\n }\n\n /**\n * @private\n * @param {unknown[]} items item to log\n */\n _getLogger(...items: unknown[]) {\n if (!this.options.debug) {\n return '';\n }\n\n return `console.log(${items.join(',')});`;\n }\n\n /**\n * @returns {string} runtime code\n */\n override generate() {\n const { remotes = {}, name } = this.options;\n const { webpack } = this.chunkLoadingContext;\n const { chunkGraph, chunk, compilation } = this;\n const { Template } = webpack;\n if (!chunkGraph || !chunk || !compilation) {\n this.logger.warn('Missing required properties. Returning empty string.');\n return '';\n }\n\n const infrastructureLogger = compilation.getLogger?.(\n 'DynamicFilesystemChunkLoadingRuntimeModule',\n );\n if (infrastructureLogger) {\n this.logger.setDelegate(infrastructureLogger as any);\n }\n\n const { runtimeTemplate } = compilation;\n const jsModulePlugin =\n webpack?.javascript?.JavascriptModulesPlugin ||\n require('webpack/lib/javascript/JavascriptModulesPlugin');\n const { chunkHasJs } = jsModulePlugin;\n const fn = RuntimeGlobals.ensureChunkHandlers;\n\n const conditionMap = chunkGraph.getChunkConditionMap(chunk, chunkHasJs);\n const hasJsMatcher = compileBooleanMatcher(conditionMap);\n const initialChunkIds = getInitialChunkIds(chunk, chunkGraph, chunkHasJs);\n\n const outputName = compilation.getPath(\n jsModulePlugin.getChunkFilenameTemplate(chunk, compilation.outputOptions),\n { chunk, contentHashType: 'javascript' },\n );\n const rootOutputDir = getUndoPath(\n outputName,\n compilation.outputOptions.path || '',\n false,\n );\n const stateExpression = this.runtimeRequirements.has(\n RuntimeGlobals.hmrDownloadUpdateHandlers,\n )\n ? `${RuntimeGlobals.hmrRuntimeStatePrefix}_readFileVm`\n : undefined;\n\n const dynamicFilesystemChunkLoadingPluginCode = Template.asString([\n fileSystemRunInContextStrategy.toString(),\n httpEvalStrategy.toString(),\n httpVmStrategy.toString(),\n 'const loadChunkStrategy = async (strategyType,chunkId,rootOutputDir, remotes, callback) => {',\n Template.indent([\n 'switch (strategyType) {',\n Template.indent([\n 'case \"filesystem\": return await fileSystemRunInContextStrategy(chunkId,rootOutputDir, remotes, callback);',\n 'case \"http-eval\": return await httpEvalStrategy(chunkId,rootOutputDir, remotes, callback);',\n 'case \"http-vm\": return await httpVmStrategy(chunkId,rootOutputDir, remotes, callback);',\n this.hooks.strategyCase.call(\n 'default: throw new Error(\"Invalid strategy type\");',\n ) as string,\n ]),\n '}',\n ]),\n '};',\n ]);\n\n return Template.asString([\n dynamicFilesystemChunkLoadingPluginCode,\n this.runtimeRequirements.has(RuntimeGlobals.baseURI)\n ? this._generateBaseUri(chunk, rootOutputDir)\n : '// no baseURI',\n '',\n '// object to store loaded chunks',\n '// \"0\" means \"already loaded\", Promise means loading',\n `var installedChunks = ${\n stateExpression ? `${stateExpression} = ${stateExpression} || ` : ''\n }{`,\n Template.indent(\n Array.from(initialChunkIds, (id) => `${JSON.stringify(id)}: 0`).join(\n ',\\n',\n ),\n ),\n '};',\n '',\n handleOnChunkLoad(\n this.runtimeRequirements.has(RuntimeGlobals.onChunksLoaded),\n runtimeTemplate,\n ),\n '',\n generateInstallChunk(\n runtimeTemplate,\n this.runtimeRequirements.has(RuntimeGlobals.onChunksLoaded),\n ),\n '',\n this.runtimeRequirements.has(RuntimeGlobals.ensureChunkHandlers)\n ? generateLoadScript(runtimeTemplate)\n : '// no remote script loader needed',\n this.runtimeRequirements.has(RuntimeGlobals.ensureChunkHandlers)\n ? generateLoadingCode(\n this.runtimeRequirements.has(RuntimeGlobals.ensureChunkHandlers),\n fn,\n hasJsMatcher,\n rootOutputDir,\n remotes,\n name,\n )\n : '// no chunk loading',\n '',\n generateExternalInstallChunkCode(\n this.runtimeRequirements.has(RuntimeGlobals.externalInstallChunk),\n this.options.debug,\n ),\n '',\n generateHmrCode(\n this.runtimeRequirements.has(RuntimeGlobals.hmrDownloadUpdateHandlers),\n rootOutputDir,\n ),\n '',\n generateHmrManifestCode(\n this.runtimeRequirements.has(RuntimeGlobals.hmrDownloadManifest),\n rootOutputDir,\n ),\n ]);\n }\n}\n\nexport default DynamicFilesystemChunkLoadingRuntimeModule;\n"],"mappings":";;;;;;;;AAKA,MAAM,EAAE,gBAAgB,4BACtB,qBAAqB,UAAU,CAChC;AACD,MAAM,EAAE,0BACN,qBAAqB,8BAA8B,CACpD;AAED,MAAM,kCACJ,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A,wBACE,KAAK,oBAAoB,IAAI,eAAe,oBAAoB,EAChE,cACD;GACF,CAAC"}
1
+ {"version":3,"file":"DynamicFilesystemChunkLoadingRuntimeModule.mjs","names":[],"sources":["../../../src/plugins/DynamicFilesystemChunkLoadingRuntimeModule.ts"],"sourcesContent":["/*\n MIT License http://www.opensource.org/licenses/mit-license.php\n*/\nimport type { Chunk, Compiler } from 'webpack';\nimport { normalizeWebpackPath } from '@module-federation/sdk/normalize-webpack-path';\nconst { RuntimeGlobals, RuntimeModule } = require(\n normalizeWebpackPath('webpack'),\n) as typeof import('webpack');\nconst { getUndoPath } = require(\n normalizeWebpackPath('webpack/lib/util/identifier'),\n) as typeof import('webpack/lib/util/identifier');\nimport { SyncWaterfallHook } from 'tapable';\nconst compileBooleanMatcher = require(\n normalizeWebpackPath('webpack/lib/util/compileBooleanMatcher'),\n) as typeof import('webpack/lib/util/compileBooleanMatcher');\nimport {\n generateHmrCode,\n getInitialChunkIds,\n generateLoadingCode,\n generateHmrManifestCode,\n handleOnChunkLoad,\n generateLoadScript,\n generateInstallChunk,\n generateExternalInstallChunkCode,\n} from './webpackChunkUtilities';\nimport { createBundlerLogger } from './createBundlerLogger';\nimport {\n fileSystemRunInContextStrategy,\n httpEvalStrategy,\n httpVmStrategy,\n} from '../filesystem/stratagies';\n\ninterface RemotesByType {\n functional: string[];\n normal: string[];\n}\n\ninterface DynamicFilesystemChunkLoadingRuntimeModuleOptions {\n baseURI: Compiler['options']['output']['publicPath'];\n promiseBaseURI?: string;\n remotes: Record<string, string>;\n name?: string;\n debug?: boolean;\n}\n\ninterface ChunkLoadingContext {\n webpack: Compiler['webpack'];\n}\n\nclass DynamicFilesystemChunkLoadingRuntimeModule extends RuntimeModule {\n private runtimeRequirements: Set<string>;\n private options: DynamicFilesystemChunkLoadingRuntimeModuleOptions;\n private chunkLoadingContext: ChunkLoadingContext;\n hooks = {\n strategyCase: new SyncWaterfallHook(['source']),\n };\n private logger = createBundlerLogger(\n '[ DynamicFilesystemChunkLoadingRuntimeModule ]',\n );\n\n constructor(\n runtimeRequirements: Set<string>,\n options: DynamicFilesystemChunkLoadingRuntimeModuleOptions,\n chunkLoadingContext: ChunkLoadingContext,\n ) {\n super('readFile chunk loading', RuntimeModule.STAGE_ATTACH + 1);\n this.runtimeRequirements = runtimeRequirements;\n\n this.options = options;\n this.chunkLoadingContext = chunkLoadingContext;\n }\n\n /**\n * @private\n * @param {Chunk} chunk chunk\n * @param {string} rootOutputDir root output directory\n * @returns {string} generated code\n */\n _generateBaseUri(chunk: Chunk, rootOutputDir: string) {\n const options = chunk.getEntryOptions();\n if (options && options.baseUri) {\n return `${RuntimeGlobals.baseURI} = ${JSON.stringify(options.baseUri)};`;\n }\n\n return `${RuntimeGlobals.baseURI} = require(\"url\").pathToFileURL(${\n rootOutputDir\n ? `__dirname + ${JSON.stringify('/' + rootOutputDir)}`\n : '__filename'\n });`;\n }\n\n /**\n * @private\n * @param {unknown[]} items item to log\n */\n _getLogger(...items: unknown[]) {\n if (!this.options.debug) {\n return '';\n }\n\n return `console.log(${items.join(',')});`;\n }\n\n /**\n * @returns {string} runtime code\n */\n override generate() {\n const { remotes = {}, name } = this.options;\n const { webpack } = this.chunkLoadingContext;\n const { chunkGraph, chunk, compilation } = this;\n const { Template } = webpack;\n if (!chunkGraph || !chunk || !compilation) {\n this.logger.warn('Missing required properties. Returning empty string.');\n return '';\n }\n\n const infrastructureLogger = compilation.getLogger?.(\n 'DynamicFilesystemChunkLoadingRuntimeModule',\n );\n if (infrastructureLogger) {\n this.logger.setDelegate(infrastructureLogger as any);\n }\n\n const { runtimeTemplate } = compilation;\n const jsModulePlugin =\n webpack?.javascript?.JavascriptModulesPlugin ||\n require('webpack/lib/javascript/JavascriptModulesPlugin');\n const { chunkHasJs } = jsModulePlugin;\n const fn = RuntimeGlobals.ensureChunkHandlers;\n\n const conditionMap = chunkGraph.getChunkConditionMap(chunk, chunkHasJs);\n const hasJsMatcher = compileBooleanMatcher(conditionMap);\n const initialChunkIds = getInitialChunkIds(chunk, chunkGraph, chunkHasJs);\n\n const outputName = compilation.getPath(\n jsModulePlugin.getChunkFilenameTemplate(chunk, compilation.outputOptions),\n { chunk, contentHashType: 'javascript' },\n );\n const rootOutputDir = getUndoPath(\n outputName,\n compilation.outputOptions.path || '',\n false,\n );\n const stateExpression = this.runtimeRequirements.has(\n RuntimeGlobals.hmrDownloadUpdateHandlers,\n )\n ? `${RuntimeGlobals.hmrRuntimeStatePrefix}_readFileVm`\n : undefined;\n\n const dynamicFilesystemChunkLoadingPluginCode = Template.asString([\n fileSystemRunInContextStrategy.toString(),\n httpEvalStrategy.toString(),\n httpVmStrategy.toString(),\n 'const loadChunkStrategy = async (strategyType,chunkId,rootOutputDir, remotes, callback) => {',\n Template.indent([\n 'switch (strategyType) {',\n Template.indent([\n 'case \"filesystem\": return await fileSystemRunInContextStrategy(chunkId,rootOutputDir, remotes, callback);',\n 'case \"http-eval\": return await httpEvalStrategy(chunkId,rootOutputDir, remotes, callback);',\n 'case \"http-vm\": return await httpVmStrategy(chunkId,rootOutputDir, remotes, callback);',\n this.hooks.strategyCase.call(\n 'default: throw new Error(\"Invalid strategy type\");',\n ) as string,\n ]),\n '}',\n ]),\n '};',\n ]);\n\n return Template.asString([\n dynamicFilesystemChunkLoadingPluginCode,\n this.runtimeRequirements.has(RuntimeGlobals.baseURI)\n ? this._generateBaseUri(chunk, rootOutputDir)\n : '// no baseURI',\n '',\n '// object to store loaded chunks',\n '// \"0\" means \"already loaded\", Promise means loading',\n `var installedChunks = ${\n stateExpression ? `${stateExpression} = ${stateExpression} || ` : ''\n }{`,\n Template.indent(\n Array.from(initialChunkIds, (id) => `${JSON.stringify(id)}: 0`).join(\n ',\\n',\n ),\n ),\n '};',\n '',\n handleOnChunkLoad(\n this.runtimeRequirements.has(RuntimeGlobals.onChunksLoaded),\n runtimeTemplate,\n ),\n '',\n generateInstallChunk(\n runtimeTemplate,\n this.runtimeRequirements.has(RuntimeGlobals.onChunksLoaded),\n ),\n '',\n this.runtimeRequirements.has(RuntimeGlobals.ensureChunkHandlers)\n ? generateLoadScript(runtimeTemplate)\n : '// no remote script loader needed',\n this.runtimeRequirements.has(RuntimeGlobals.ensureChunkHandlers)\n ? generateLoadingCode(\n this.runtimeRequirements.has(RuntimeGlobals.ensureChunkHandlers),\n fn,\n hasJsMatcher,\n rootOutputDir,\n remotes,\n name,\n )\n : '// no chunk loading',\n '',\n generateExternalInstallChunkCode(\n this.runtimeRequirements.has(RuntimeGlobals.externalInstallChunk),\n this.options.debug,\n ),\n '',\n generateHmrCode(\n this.runtimeRequirements.has(RuntimeGlobals.hmrDownloadUpdateHandlers),\n rootOutputDir,\n ),\n '',\n generateHmrManifestCode(\n this.runtimeRequirements.has(RuntimeGlobals.hmrDownloadManifest),\n rootOutputDir,\n ),\n ]);\n }\n}\n\nexport default DynamicFilesystemChunkLoadingRuntimeModule;\n"],"mappings":";;;;;;;;AAKA,MAAM,EAAE,gBAAgB,4BACtB,qBAAqB,UAAU,CAChC;AACD,MAAM,EAAE,0BACN,qBAAqB,8BAA8B,CACpD;AAED,MAAM,kCACJ,qBAAqB,yCAAyC,CAC/D;AAmCD,IAAM,6CAAN,cAAyD,cAAc;CAWrE,YACE,qBACA,SACA,qBACA;AACA,QAAM,0BAA0B,cAAc,eAAe,EAAE;eAZzD,EACN,cAAc,IAAI,kBAAkB,CAAC,SAAS,CAAC,EAChD;gBACgB,oBACf,iDACD;AAQC,OAAK,sBAAsB;AAE3B,OAAK,UAAU;AACf,OAAK,sBAAsB;;;;;;;;CAS7B,iBAAiB,OAAc,eAAuB;EACpD,MAAM,UAAU,MAAM,iBAAiB;AACvC,MAAI,WAAW,QAAQ,QACrB,QAAO,GAAG,eAAe,QAAQ,KAAK,KAAK,UAAU,QAAQ,QAAQ,CAAC;AAGxE,SAAO,GAAG,eAAe,QAAQ,kCAC/B,gBACI,eAAe,KAAK,UAAU,MAAM,cAAc,KAClD,aACL;;;;;;CAOH,WAAW,GAAG,OAAkB;A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GACA;GACA;GACA,yBACE,kBAAkB,GAAG,gBAAgB,KAAK,gBAAgB,QAAQ,GACnE;GACD,SAAS,OACP,MAAM,KAAK,kBAAkB,OAAO,GAAG,KAAK,UAAU,GAAG,CAAC,KAAK,CAAC,KAC9D,MACD,CACF;GACD;GACA;GACA,kBACE,KAAK,oBAAoB,IAAI,eAAe,eAAe,EAC3D,gBACD;GACD;GACA,qBACE,iBACA,KAAK,oBAAoB,IAAI,eAAe,eAAe,CAC5D;GACD;GACA,KAAK,oBAAoB,IAAI,eAAe,oBAAoB,GAC5D,mBAAmB,gBAAgB,GACnC;GACJ,KAAK,oBAAoB,IAAI,eAAe,oBAAoB,GAC5D,oBACE,KAAK,oBAAoB,IAAI,eAAe,oBAAoB,EAChE,IACA,cACA,eACA,SACA,KACD,GACD;GACJ;GACA,iCACE,KAAK,oBAAoB,IAAI,eAAe,qBAAqB,EACjE,KAAK,QAAQ,MACd;GACD;GACA,gBACE,KAAK,oBAAoB,IAAI,eAAe,0BAA0B,EACtE,cACD;GACD;GACA,wBACE,KAAK,oBAAoB,IAAI,eAAe,oBAAoB,EAChE,cACD;GACF,CAAC"}
@@ -2,11 +2,11 @@
2
2
 
3
3
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
4
4
  const require_runtime = require('../../_virtual/_rolldown/runtime.js');
5
+ const require_createBundlerLogger = require('../../plugins/createBundlerLogger.js');
5
6
  const require_src_plugins_EntryChunkTrackerPlugin = require('./EntryChunkTrackerPlugin.js');
6
7
  let _module_federation_sdk = require("@module-federation/sdk");
7
8
 
8
9
  //#region src/plugins/NodeFederationPlugin.ts
9
- const createBundlerLogger = typeof _module_federation_sdk.createInfrastructureLogger === "function" ? _module_federation_sdk.createInfrastructureLogger : _module_federation_sdk.createLogger;
10
10
  function getRuntimePluginPath() {
11
11
  return require.resolve("../runtimePlugin.js");
12
12
  }
@@ -22,7 +22,7 @@ var NodeFederationPlugin = class {
22
22
  * @param {Context} context - The context for the NodeFederationPlugin
23
23
  */
24
24
  constructor({ debug, useRuntimePlugin, ...options }, context) {
25
- this.logger = createBundlerLogger("[ Node Federation Plugin ]");
25
+ this.logger = require_createBundlerLogger.createBundlerLogger("[ Node Federation Plugin ]");
26
26
  this._options = options || {};
27
27
  this.context = context || {};
28
28
  this.useRuntimePlugin = useRuntimePlugin || false;
@@ -1 +1 @@
1
- {"version":3,"file":"NodeFederationPlugin.js","names":["createInfrastructureLogger","createLogger","EntryChunkTrackerPlugin"],"sources":["../../../src/plugins/NodeFederationPlugin.ts"],"sourcesContent":["'use strict';\n\nimport type { Compiler, container } from 'webpack';\nimport type { ModuleFederationPluginOptions } from '../types';\nimport EntryChunkTrackerPlugin from './EntryChunkTrackerPlugin';\nimport {\n bindLoggerToCompiler,\n createInfrastructureLogger,\n createLogger,\n} from '@module-federation/sdk';\n/**\n * Interface for NodeFederationOptions which extends ModuleFederationPluginOptions\n * @interface\n * @property {boolean} debug - Optional debug flag\n */\ninterface NodeFederationOptions extends ModuleFederationPluginOptions {\n debug?: boolean;\n useRuntimePlugin?: boolean;\n}\n\n/**\n * Interface for Context\n * @interface\n * @property {typeof container.ModuleFederationPlugin} ModuleFederationPlugin - Optional ModuleFederationPlugin\n */\ninterface Context {\n ModuleFederationPlugin?: typeof container.ModuleFederationPlugin;\n}\n\nconst createBundlerLogger: typeof createLogger =\n typeof createInfrastructureLogger === 'function'\n ? (createInfrastructureLogger as unknown as typeof createLogger)\n : createLogger;\n\nfunction getRuntimePluginPath(): string {\n return require.resolve(\n process.env.IS_ESM_BUILD === 'true'\n ? '../runtimePlugin.mjs'\n : '../runtimePlugin.js',\n );\n}\n\n/**\n * Class representing a NodeFederationPlugin.\n * @class\n */\nclass NodeFederationPlugin {\n private _options: ModuleFederationPluginOptions;\n private context: Context;\n private useRuntimePlugin?: boolean;\n private logger = createBundlerLogger('[ Node Federation Plugin ]');\n\n /**\n * Create a NodeFederationPlugin.\n * @constructor\n * @param {NodeFederationOptions} options - The options for the NodeFederationPlugin\n * @param {Context} context - The context for the NodeFederationPlugin\n */\n constructor(\n { debug, useRuntimePlugin, ...options }: NodeFederationOptions,\n context: Context,\n ) {\n this._options = options || ({} as ModuleFederationPluginOptions);\n this.context = context || ({} as Context);\n this.useRuntimePlugin = useRuntimePlugin || false;\n }\n\n /**\n * Apply method for the NodeFederationPlugin class.\n * @method\n * @param {Compiler} compiler - The webpack compiler.\n */\n apply(compiler: Compiler) {\n bindLoggerToCompiler(this.logger, compiler, 'NodeFederationPlugin');\n const { webpack } = compiler;\n const pluginOptions = this.preparePluginOptions();\n this.updateCompilerOptions(compiler);\n const ModuleFederationPlugin = this.getModuleFederationPlugin(\n compiler,\n webpack,\n );\n new ModuleFederationPlugin(pluginOptions).apply(compiler);\n new EntryChunkTrackerPlugin({}).apply(compiler);\n }\n\n private preparePluginOptions(): ModuleFederationPluginOptions {\n this._options.runtimePlugins = [\n ...(this.useRuntimePlugin ? [getRuntimePluginPath()] : []),\n ...(this._options.runtimePlugins || []),\n ];\n\n return {\n ...this._options,\n remotes: this._options.remotes || {},\n runtimePlugins: this._options.runtimePlugins,\n // enable dts in browser by default\n dts: this._options.dts ?? false,\n };\n }\n\n private updateCompilerOptions(compiler: Compiler): void {\n const chunkFileName = compiler.options?.output?.chunkFilename;\n const uniqueName =\n compiler?.options?.output?.uniqueName || this._options.name;\n if (\n typeof chunkFileName === 'string' &&\n uniqueName &&\n !chunkFileName.includes(uniqueName)\n ) {\n const suffix = `-[contenthash].js`;\n compiler.options.output.chunkFilename = chunkFileName.replace(\n '.js',\n suffix,\n );\n }\n }\n\n private getModuleFederationPlugin(compiler: Compiler, webpack: any): any {\n let ModuleFederationPlugin;\n try {\n return require('@module-federation/enhanced').ModuleFederationPlugin;\n } catch (e) {\n this.logger.error(\n \"Can't find @module-federation/enhanced, falling back to webpack ModuleFederationPlugin, this may not work\",\n );\n if (this.context.ModuleFederationPlugin) {\n ModuleFederationPlugin = this.context.ModuleFederationPlugin;\n } else if (\n webpack &&\n webpack.container &&\n webpack.container.ModuleFederationPlugin\n ) {\n ModuleFederationPlugin = webpack.container.ModuleFederationPlugin;\n } else {\n ModuleFederationPlugin = require('webpack/lib/container/ModuleFederationPlugin');\n }\n return ModuleFederationPlugin;\n }\n }\n}\n\nexport default NodeFederationPlugin;\n"],"mappings":";;;;;;;;AA6BA,MAAM,sBACJ,OAAOA,sDAA+B,aACjCA,oDACDC;AAEN,SAAS,uBAA+B;AACtC,QAAO,QAAQ,QAGT,sBACL;;;;;;AAOH,IAAM,uBAAN,MAA2B;;;;;;;CAYzB,YACE,EAAE,OAAO,kBAAkB,GAAG,WAC9B,SACA;gBAXe,oBAAoB,6BAA6B;AAYhE,OAAK,WAAW,WAAY,EAAE;AAC9B,OAAK,UAAU,WAAY,EAAE;AAC7B,OAAK,mBAAmB,oBAAoB;;;;;;;CAQ9C,MAAM,UAAoB;AACxB,mDAAqB,KAAK,QAAQ,UAAU,uBAAuB;EACnE,MAAM,EAAE,YAAY;EACpB,MAAM,gBAAgB,KAAK,sBAAsB;AACjD,OAAK,sBAAsB,SAAS;AAKpC,OAJ+B,KAAK,0BAClC,UACA,QACD,EAC0B,cAAc,CAAC,MAAM,SAAS;AACzD,MAAIC,oDAAwB,EAAE,CAAC,CAAC,MAAM,SAAS;;CAGjD,AAAQ,uBAAsD;AAC5D,OAAK,SAAS,iBAAiB,CAC7B,GAAI,KAAK,mBAAmB,CAAC,sBAAsB,CAAC,GAAG,EAAE,EACzD,GAAI,KAAK,SAAS,kBAAkB,EAAE,CACvC;AAED,SAAO;GACL,GAAG,KAAK;GACR,SAAS,KAAK,SAAS,WAAW,EAAE;GACpC,gBAAgB,KAAK,SAAS;GAE9B,KAAK,KAAK,SAAS,OAAO;GAC3B;;CAGH,AAAQ,sBAAsB,UAA0B;EACtD,MAAM,gBAAgB,SAAS,SAAS,QAAQ;EAChD,MAAM,aACJ,UAAU,SAAS,QAAQ,cAAc,KAAK,SAAS;AACzD,MACE,OAAO,kBAAkB,YACzB,cACA,CAAC,cAAc,SAAS,WAAW,EACnC;GACA,MAAM,SAAS;AACf,YAAS,QAAQ,OAAO,gBAAgB,cAAc,QACpD,OACA,OACD;;;CAIL,AAAQ,0BAA0B,UAAoB,SAAmB;EACvE,IAAI;AACJ,MAAI;AACF,UAAO,QAAQ,8BAA8B,CAAC;WACvC,GAAG;AACV,QAAK,OAAO,MACV,4GACD;AACD,OAAI,KAAK,QAAQ,uBACf,0BAAyB,KAAK,QAAQ;YAEtC,WACA,QAAQ,aACR,QAAQ,UAAU,uBAElB,0BAAyB,QAAQ,UAAU;OAE3C,0BAAyB,QAAQ,+CAA+C;AAElF,UAAO"}
1
+ {"version":3,"file":"NodeFederationPlugin.js","names":["createBundlerLogger","EntryChunkTrackerPlugin"],"sources":["../../../src/plugins/NodeFederationPlugin.ts"],"sourcesContent":["'use strict';\n\nimport type { Compiler, container } from 'webpack';\nimport type { ModuleFederationPluginOptions } from '../types';\nimport EntryChunkTrackerPlugin from './EntryChunkTrackerPlugin';\nimport { bindLoggerToCompiler } from '@module-federation/sdk';\nimport { createBundlerLogger } from './createBundlerLogger';\n/**\n * Interface for NodeFederationOptions which extends ModuleFederationPluginOptions\n * @interface\n * @property {boolean} debug - Optional debug flag\n */\ninterface NodeFederationOptions extends ModuleFederationPluginOptions {\n debug?: boolean;\n useRuntimePlugin?: boolean;\n}\n\n/**\n * Interface for Context\n * @interface\n * @property {typeof container.ModuleFederationPlugin} ModuleFederationPlugin - Optional ModuleFederationPlugin\n */\ninterface Context {\n ModuleFederationPlugin?: typeof container.ModuleFederationPlugin;\n}\n\nfunction getRuntimePluginPath(): string {\n return require.resolve(\n process.env.IS_ESM_BUILD === 'true'\n ? '../runtimePlugin.mjs'\n : '../runtimePlugin.js',\n );\n}\n\n/**\n * Class representing a NodeFederationPlugin.\n * @class\n */\nclass NodeFederationPlugin {\n private _options: ModuleFederationPluginOptions;\n private context: Context;\n private useRuntimePlugin?: boolean;\n private logger = createBundlerLogger('[ Node Federation Plugin ]');\n\n /**\n * Create a NodeFederationPlugin.\n * @constructor\n * @param {NodeFederationOptions} options - The options for the NodeFederationPlugin\n * @param {Context} context - The context for the NodeFederationPlugin\n */\n constructor(\n { debug, useRuntimePlugin, ...options }: NodeFederationOptions,\n context: Context,\n ) {\n this._options = options || ({} as ModuleFederationPluginOptions);\n this.context = context || ({} as Context);\n this.useRuntimePlugin = useRuntimePlugin || false;\n }\n\n /**\n * Apply method for the NodeFederationPlugin class.\n * @method\n * @param {Compiler} compiler - The webpack compiler.\n */\n apply(compiler: Compiler) {\n bindLoggerToCompiler(this.logger, compiler, 'NodeFederationPlugin');\n const { webpack } = compiler;\n const pluginOptions = this.preparePluginOptions();\n this.updateCompilerOptions(compiler);\n const ModuleFederationPlugin = this.getModuleFederationPlugin(\n compiler,\n webpack,\n );\n new ModuleFederationPlugin(pluginOptions).apply(compiler);\n new EntryChunkTrackerPlugin({}).apply(compiler);\n }\n\n private preparePluginOptions(): ModuleFederationPluginOptions {\n this._options.runtimePlugins = [\n ...(this.useRuntimePlugin ? [getRuntimePluginPath()] : []),\n ...(this._options.runtimePlugins || []),\n ];\n\n return {\n ...this._options,\n remotes: this._options.remotes || {},\n runtimePlugins: this._options.runtimePlugins,\n // enable dts in browser by default\n dts: this._options.dts ?? false,\n };\n }\n\n private updateCompilerOptions(compiler: Compiler): void {\n const chunkFileName = compiler.options?.output?.chunkFilename;\n const uniqueName =\n compiler?.options?.output?.uniqueName || this._options.name;\n if (\n typeof chunkFileName === 'string' &&\n uniqueName &&\n !chunkFileName.includes(uniqueName)\n ) {\n const suffix = `-[contenthash].js`;\n compiler.options.output.chunkFilename = chunkFileName.replace(\n '.js',\n suffix,\n );\n }\n }\n\n private getModuleFederationPlugin(compiler: Compiler, webpack: any): any {\n let ModuleFederationPlugin;\n try {\n return require('@module-federation/enhanced').ModuleFederationPlugin;\n } catch (e) {\n this.logger.error(\n \"Can't find @module-federation/enhanced, falling back to webpack ModuleFederationPlugin, this may not work\",\n );\n if (this.context.ModuleFederationPlugin) {\n ModuleFederationPlugin = this.context.ModuleFederationPlugin;\n } else if (\n webpack &&\n webpack.container &&\n webpack.container.ModuleFederationPlugin\n ) {\n ModuleFederationPlugin = webpack.container.ModuleFederationPlugin;\n } else {\n ModuleFederationPlugin = require('webpack/lib/container/ModuleFederationPlugin');\n }\n return ModuleFederationPlugin;\n }\n }\n}\n\nexport default NodeFederationPlugin;\n"],"mappings":";;;;;;;;;AA0BA,SAAS,uBAA+B;AACtC,QAAO,QAAQ,QAGT,sBACL;;;;;;AAOH,IAAM,uBAAN,MAA2B;;;;;;;CAYzB,YACE,EAAE,OAAO,kBAAkB,GAAG,WAC9B,SACA;gBAXeA,gDAAoB,6BAA6B;AAYhE,OAAK,WAAW,WAAY,EAAE;AAC9B,OAAK,UAAU,WAAY,EAAE;AAC7B,OAAK,mBAAmB,oBAAoB;;;;;;;CAQ9C,MAAM,UAAoB;AACxB,mDAAqB,KAAK,QAAQ,UAAU,uBAAuB;EACnE,MAAM,EAAE,YAAY;EACpB,MAAM,gBAAgB,KAAK,sBAAsB;AACjD,OAAK,sBAAsB,SAAS;AAKpC,OAJ+B,KAAK,0BAClC,UACA,QACD,EAC0B,cAAc,CAAC,MAAM,SAAS;AACzD,MAAIC,oDAAwB,EAAE,CAAC,CAAC,MAAM,SAAS;;CAGjD,AAAQ,uBAAsD;AAC5D,OAAK,SAAS,iBAAiB,CAC7B,GAAI,KAAK,mBAAmB,CAAC,sBAAsB,CAAC,GAAG,EAAE,EACzD,GAAI,KAAK,SAAS,kBAAkB,EAAE,CACvC;AAED,SAAO;GACL,GAAG,KAAK;GACR,SAAS,KAAK,SAAS,WAAW,EAAE;GACpC,gBAAgB,KAAK,SAAS;GAE9B,KAAK,KAAK,SAAS,OAAO;GAC3B;;CAGH,AAAQ,sBAAsB,UAA0B;EACtD,MAAM,gBAAgB,SAAS,SAAS,QAAQ;EAChD,MAAM,aACJ,UAAU,SAAS,QAAQ,cAAc,KAAK,SAAS;AACzD,MACE,OAAO,kBAAkB,YACzB,cACA,CAAC,cAAc,SAAS,WAAW,EACnC;GACA,MAAM,SAAS;AACf,YAAS,QAAQ,OAAO,gBAAgB,cAAc,QACpD,OACA,OACD;;;CAIL,AAAQ,0BAA0B,UAAoB,SAAmB;EACvE,IAAI;AACJ,MAAI;AACF,UAAO,QAAQ,8BAA8B,CAAC;WACvC,GAAG;AACV,QAAK,OAAO,MACV,4GACD;AACD,OAAI,KAAK,QAAQ,uBACf,0BAAyB,KAAK,QAAQ;YAEtC,WACA,QAAQ,aACR,QAAQ,UAAU,uBAElB,0BAAyB,QAAQ,UAAU;OAE3C,0BAAyB,QAAQ,+CAA+C;AAElF,UAAO"}
@@ -1,9 +1,9 @@
1
1
  import { __require } from "../../_virtual/_rolldown/runtime.mjs";
2
+ import { createBundlerLogger } from "../../plugins/createBundlerLogger.mjs";
2
3
  import EntryChunkTrackerPlugin from "./EntryChunkTrackerPlugin.mjs";
3
- import { bindLoggerToCompiler, createInfrastructureLogger, createLogger } from "@module-federation/sdk";
4
+ import { bindLoggerToCompiler } from "@module-federation/sdk";
4
5
 
5
6
  //#region src/plugins/NodeFederationPlugin.ts
6
- const createBundlerLogger = typeof createInfrastructureLogger === "function" ? createInfrastructureLogger : createLogger;
7
7
  function getRuntimePluginPath() {
8
8
  return __require.resolve("../runtimePlugin.mjs");
9
9
  }
@@ -1 +1 @@
1
- {"version":3,"file":"NodeFederationPlugin.mjs","names":[],"sources":["../../../src/plugins/NodeFederationPlugin.ts"],"sourcesContent":["'use strict';\n\nimport type { Compiler, container } from 'webpack';\nimport type { ModuleFederationPluginOptions } from '../types';\nimport EntryChunkTrackerPlugin from './EntryChunkTrackerPlugin';\nimport {\n bindLoggerToCompiler,\n createInfrastructureLogger,\n createLogger,\n} from '@module-federation/sdk';\n/**\n * Interface for NodeFederationOptions which extends ModuleFederationPluginOptions\n * @interface\n * @property {boolean} debug - Optional debug flag\n */\ninterface NodeFederationOptions extends ModuleFederationPluginOptions {\n debug?: boolean;\n useRuntimePlugin?: boolean;\n}\n\n/**\n * Interface for Context\n * @interface\n * @property {typeof container.ModuleFederationPlugin} ModuleFederationPlugin - Optional ModuleFederationPlugin\n */\ninterface Context {\n ModuleFederationPlugin?: typeof container.ModuleFederationPlugin;\n}\n\nconst createBundlerLogger: typeof createLogger =\n typeof createInfrastructureLogger === 'function'\n ? (createInfrastructureLogger as unknown as typeof createLogger)\n : createLogger;\n\nfunction getRuntimePluginPath(): string {\n return require.resolve(\n process.env.IS_ESM_BUILD === 'true'\n ? '../runtimePlugin.mjs'\n : '../runtimePlugin.js',\n );\n}\n\n/**\n * Class representing a NodeFederationPlugin.\n * @class\n */\nclass NodeFederationPlugin {\n private _options: ModuleFederationPluginOptions;\n private context: Context;\n private useRuntimePlugin?: boolean;\n private logger = createBundlerLogger('[ Node Federation Plugin ]');\n\n /**\n * Create a NodeFederationPlugin.\n * @constructor\n * @param {NodeFederationOptions} options - The options for the NodeFederationPlugin\n * @param {Context} context - The context for the NodeFederationPlugin\n */\n constructor(\n { debug, useRuntimePlugin, ...options }: NodeFederationOptions,\n context: Context,\n ) {\n this._options = options || ({} as ModuleFederationPluginOptions);\n this.context = context || ({} as Context);\n this.useRuntimePlugin = useRuntimePlugin || false;\n }\n\n /**\n * Apply method for the NodeFederationPlugin class.\n * @method\n * @param {Compiler} compiler - The webpack compiler.\n */\n apply(compiler: Compiler) {\n bindLoggerToCompiler(this.logger, compiler, 'NodeFederationPlugin');\n const { webpack } = compiler;\n const pluginOptions = this.preparePluginOptions();\n this.updateCompilerOptions(compiler);\n const ModuleFederationPlugin = this.getModuleFederationPlugin(\n compiler,\n webpack,\n );\n new ModuleFederationPlugin(pluginOptions).apply(compiler);\n new EntryChunkTrackerPlugin({}).apply(compiler);\n }\n\n private preparePluginOptions(): ModuleFederationPluginOptions {\n this._options.runtimePlugins = [\n ...(this.useRuntimePlugin ? [getRuntimePluginPath()] : []),\n ...(this._options.runtimePlugins || []),\n ];\n\n return {\n ...this._options,\n remotes: this._options.remotes || {},\n runtimePlugins: this._options.runtimePlugins,\n // enable dts in browser by default\n dts: this._options.dts ?? false,\n };\n }\n\n private updateCompilerOptions(compiler: Compiler): void {\n const chunkFileName = compiler.options?.output?.chunkFilename;\n const uniqueName =\n compiler?.options?.output?.uniqueName || this._options.name;\n if (\n typeof chunkFileName === 'string' &&\n uniqueName &&\n !chunkFileName.includes(uniqueName)\n ) {\n const suffix = `-[contenthash].js`;\n compiler.options.output.chunkFilename = chunkFileName.replace(\n '.js',\n suffix,\n );\n }\n }\n\n private getModuleFederationPlugin(compiler: Compiler, webpack: any): any {\n let ModuleFederationPlugin;\n try {\n return require('@module-federation/enhanced').ModuleFederationPlugin;\n } catch (e) {\n this.logger.error(\n \"Can't find @module-federation/enhanced, falling back to webpack ModuleFederationPlugin, this may not work\",\n );\n if (this.context.ModuleFederationPlugin) {\n ModuleFederationPlugin = this.context.ModuleFederationPlugin;\n } else if (\n webpack &&\n webpack.container &&\n webpack.container.ModuleFederationPlugin\n ) {\n ModuleFederationPlugin = webpack.container.ModuleFederationPlugin;\n } else {\n ModuleFederationPlugin = require('webpack/lib/container/ModuleFederationPlugin');\n }\n return ModuleFederationPlugin;\n }\n }\n}\n\nexport default NodeFederationPlugin;\n"],"mappings":";;;;;AA6BA,MAAM,sBACJ,OAAO,+BAA+B,aACjC,6BACD;AAEN,SAAS,uBAA+B;AACtC,kBAAe,QAET,uBAEL;;;;;;AAOH,IAAM,uBAAN,MAA2B;;;;;;;CAYzB,YACE,EAAE,OAAO,kBAAkB,GAAG,WAC9B,SACA;gBAXe,oBAAoB,6BAA6B;AAYhE,OAAK,WAAW,WAAY,EAAE;AAC9B,OAAK,UAAU,WAAY,EAAE;AAC7B,OAAK,mBAAmB,oBAAoB;;;;;;;CAQ9C,MAAM,UAAoB;AACxB,uBAAqB,KAAK,QAAQ,UAAU,uBAAuB;EACnE,MAAM,EAAE,YAAY;EACpB,MAAM,gBAAgB,KAAK,sBAAsB;AACjD,OAAK,sBAAsB,SAAS;AAKpC,OAJ+B,KAAK,0BAClC,UACA,QACD,EAC0B,cAAc,CAAC,MAAM,SAAS;AACzD,MAAI,wBAAwB,EAAE,CAAC,CAAC,MAAM,SAAS;;CAGjD,AAAQ,uBAAsD;AAC5D,OAAK,SAAS,iBAAiB,CAC7B,GAAI,KAAK,mBAAmB,CAAC,sBAAsB,CAAC,GAAG,EAAE,EACzD,GAAI,KAAK,SAAS,kBAAkB,EAAE,CACvC;AAED,SAAO;GACL,GAAG,KAAK;GACR,SAAS,KAAK,SAAS,WAAW,EAAE;GACpC,gBAAgB,KAAK,SAAS;GAE9B,KAAK,KAAK,SAAS,OAAO;GAC3B;;CAGH,AAAQ,sBAAsB,UAA0B;EACtD,MAAM,gBAAgB,SAAS,SAAS,QAAQ;EAChD,MAAM,aACJ,UAAU,SAAS,QAAQ,cAAc,KAAK,SAAS;AACzD,MACE,OAAO,kBAAkB,YACzB,cACA,CAAC,cAAc,SAAS,WAAW,EACnC;GACA,MAAM,SAAS;AACf,YAAS,QAAQ,OAAO,gBAAgB,cAAc,QACpD,OACA,OACD;;;CAIL,AAAQ,0BAA0B,UAAoB,SAAmB;EACvE,IAAI;AACJ,MAAI;AACF,oBAAe,8BAA8B,CAAC;WACvC,GAAG;AACV,QAAK,OAAO,MACV,4GACD;AACD,OAAI,KAAK,QAAQ,uBACf,0BAAyB,KAAK,QAAQ;YAEtC,WACA,QAAQ,aACR,QAAQ,UAAU,uBAElB,0BAAyB,QAAQ,UAAU;OAE3C,oCAAiC,+CAA+C;AAElF,UAAO"}
1
+ {"version":3,"file":"NodeFederationPlugin.mjs","names":[],"sources":["../../../src/plugins/NodeFederationPlugin.ts"],"sourcesContent":["'use strict';\n\nimport type { Compiler, container } from 'webpack';\nimport type { ModuleFederationPluginOptions } from '../types';\nimport EntryChunkTrackerPlugin from './EntryChunkTrackerPlugin';\nimport { bindLoggerToCompiler } from '@module-federation/sdk';\nimport { createBundlerLogger } from './createBundlerLogger';\n/**\n * Interface for NodeFederationOptions which extends ModuleFederationPluginOptions\n * @interface\n * @property {boolean} debug - Optional debug flag\n */\ninterface NodeFederationOptions extends ModuleFederationPluginOptions {\n debug?: boolean;\n useRuntimePlugin?: boolean;\n}\n\n/**\n * Interface for Context\n * @interface\n * @property {typeof container.ModuleFederationPlugin} ModuleFederationPlugin - Optional ModuleFederationPlugin\n */\ninterface Context {\n ModuleFederationPlugin?: typeof container.ModuleFederationPlugin;\n}\n\nfunction getRuntimePluginPath(): string {\n return require.resolve(\n process.env.IS_ESM_BUILD === 'true'\n ? '../runtimePlugin.mjs'\n : '../runtimePlugin.js',\n );\n}\n\n/**\n * Class representing a NodeFederationPlugin.\n * @class\n */\nclass NodeFederationPlugin {\n private _options: ModuleFederationPluginOptions;\n private context: Context;\n private useRuntimePlugin?: boolean;\n private logger = createBundlerLogger('[ Node Federation Plugin ]');\n\n /**\n * Create a NodeFederationPlugin.\n * @constructor\n * @param {NodeFederationOptions} options - The options for the NodeFederationPlugin\n * @param {Context} context - The context for the NodeFederationPlugin\n */\n constructor(\n { debug, useRuntimePlugin, ...options }: NodeFederationOptions,\n context: Context,\n ) {\n this._options = options || ({} as ModuleFederationPluginOptions);\n this.context = context || ({} as Context);\n this.useRuntimePlugin = useRuntimePlugin || false;\n }\n\n /**\n * Apply method for the NodeFederationPlugin class.\n * @method\n * @param {Compiler} compiler - The webpack compiler.\n */\n apply(compiler: Compiler) {\n bindLoggerToCompiler(this.logger, compiler, 'NodeFederationPlugin');\n const { webpack } = compiler;\n const pluginOptions = this.preparePluginOptions();\n this.updateCompilerOptions(compiler);\n const ModuleFederationPlugin = this.getModuleFederationPlugin(\n compiler,\n webpack,\n );\n new ModuleFederationPlugin(pluginOptions).apply(compiler);\n new EntryChunkTrackerPlugin({}).apply(compiler);\n }\n\n private preparePluginOptions(): ModuleFederationPluginOptions {\n this._options.runtimePlugins = [\n ...(this.useRuntimePlugin ? [getRuntimePluginPath()] : []),\n ...(this._options.runtimePlugins || []),\n ];\n\n return {\n ...this._options,\n remotes: this._options.remotes || {},\n runtimePlugins: this._options.runtimePlugins,\n // enable dts in browser by default\n dts: this._options.dts ?? false,\n };\n }\n\n private updateCompilerOptions(compiler: Compiler): void {\n const chunkFileName = compiler.options?.output?.chunkFilename;\n const uniqueName =\n compiler?.options?.output?.uniqueName || this._options.name;\n if (\n typeof chunkFileName === 'string' &&\n uniqueName &&\n !chunkFileName.includes(uniqueName)\n ) {\n const suffix = `-[contenthash].js`;\n compiler.options.output.chunkFilename = chunkFileName.replace(\n '.js',\n suffix,\n );\n }\n }\n\n private getModuleFederationPlugin(compiler: Compiler, webpack: any): any {\n let ModuleFederationPlugin;\n try {\n return require('@module-federation/enhanced').ModuleFederationPlugin;\n } catch (e) {\n this.logger.error(\n \"Can't find @module-federation/enhanced, falling back to webpack ModuleFederationPlugin, this may not work\",\n );\n if (this.context.ModuleFederationPlugin) {\n ModuleFederationPlugin = this.context.ModuleFederationPlugin;\n } else if (\n webpack &&\n webpack.container &&\n webpack.container.ModuleFederationPlugin\n ) {\n ModuleFederationPlugin = webpack.container.ModuleFederationPlugin;\n } else {\n ModuleFederationPlugin = require('webpack/lib/container/ModuleFederationPlugin');\n }\n return ModuleFederationPlugin;\n }\n }\n}\n\nexport default NodeFederationPlugin;\n"],"mappings":";;;;;;AA0BA,SAAS,uBAA+B;AACtC,kBAAe,QAET,uBAEL;;;;;;AAOH,IAAM,uBAAN,MAA2B;;;;;;;CAYzB,YACE,EAAE,OAAO,kBAAkB,GAAG,WAC9B,SACA;gBAXe,oBAAoB,6BAA6B;AAYhE,OAAK,WAAW,WAAY,EAAE;AAC9B,OAAK,UAAU,WAAY,EAAE;AAC7B,OAAK,mBAAmB,oBAAoB;;;;;;;CAQ9C,MAAM,UAAoB;AACxB,uBAAqB,KAAK,QAAQ,UAAU,uBAAuB;EACnE,MAAM,EAAE,YAAY;EACpB,MAAM,gBAAgB,KAAK,sBAAsB;AACjD,OAAK,sBAAsB,SAAS;AAKpC,OAJ+B,KAAK,0BAClC,UACA,QACD,EAC0B,cAAc,CAAC,MAAM,SAAS;AACzD,MAAI,wBAAwB,EAAE,CAAC,CAAC,MAAM,SAAS;;CAGjD,AAAQ,uBAAsD;AAC5D,OAAK,SAAS,iBAAiB,CAC7B,GAAI,KAAK,mBAAmB,CAAC,sBAAsB,CAAC,GAAG,EAAE,EACzD,GAAI,KAAK,SAAS,kBAAkB,EAAE,CACvC;AAED,SAAO;GACL,GAAG,KAAK;GACR,SAAS,KAAK,SAAS,WAAW,EAAE;GACpC,gBAAgB,KAAK,SAAS;GAE9B,KAAK,KAAK,SAAS,OAAO;GAC3B;;CAGH,AAAQ,sBAAsB,UAA0B;EACtD,MAAM,gBAAgB,SAAS,SAAS,QAAQ;EAChD,MAAM,aACJ,UAAU,SAAS,QAAQ,cAAc,KAAK,SAAS;AACzD,MACE,OAAO,kBAAkB,YACzB,cACA,CAAC,cAAc,SAAS,WAAW,EACnC;GACA,MAAM,SAAS;AACf,YAAS,QAAQ,OAAO,gBAAgB,cAAc,QACpD,OACA,OACD;;;CAIL,AAAQ,0BAA0B,UAAoB,SAAmB;EACvE,IAAI;AACJ,MAAI;AACF,oBAAe,8BAA8B,CAAC;WACvC,GAAG;AACV,QAAK,OAAO,MACV,4GACD;AACD,OAAI,KAAK,QAAQ,uBACf,0BAAyB,KAAK,QAAQ;YAEtC,WACA,QAAQ,aACR,QAAQ,UAAU,uBAElB,0BAAyB,QAAQ,UAAU;OAE3C,oCAAiC,+CAA+C;AAElF,UAAO"}
@@ -1,7 +1,5 @@
1
- import * as webpack from "webpack";
2
-
3
1
  //#region src/plugins/RemotePublicPathRuntimeModule.d.ts
4
- declare const RuntimeModule: typeof webpack.RuntimeModule;
2
+ declare const RuntimeModule: typeof undefined;
5
3
  declare class AutoPublicPathRuntimeModule extends RuntimeModule {
6
4
  private options;
7
5
  constructor(options: any);
@@ -1,7 +1,5 @@
1
- import * as webpack from "webpack";
2
-
3
1
  //#region src/plugins/RemotePublicPathRuntimeModule.d.ts
4
- declare const RuntimeModule: typeof webpack.RuntimeModule;
2
+ declare const RuntimeModule: typeof undefined;
5
3
  declare class AutoPublicPathRuntimeModule extends RuntimeModule {
6
4
  private options;
7
5
  constructor(options: any);
@@ -1 +1 @@
1
- {"version":3,"file":"StreamingTargetPlugin.js","names":["CommonJsChunkLoadingPlugin"],"sources":["../../../src/plugins/StreamingTargetPlugin.ts"],"sourcesContent":["import type { Compiler, WebpackPluginInstance } from 'webpack';\nimport type { ModuleFederationPluginOptions } from '../types';\n\nimport CommonJsChunkLoadingPlugin from './CommonJsChunkLoadingPlugin';\n\n/**\n * Interface for StreamingTargetOptions which extends ModuleFederationPluginOptions\n * @property {string} promiseBaseURI - The base URI for the promise\n * @property {boolean} debug - Flag to enable/disable debug mode\n */\ninterface StreamingTargetOptions extends ModuleFederationPluginOptions {\n promiseBaseURI?: string;\n debug?: boolean;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-empty-interface\n/**\n * Interface for StreamingTargetContext\n */\ninterface StreamingTargetContext {}\n\n/**\n * Class representing a StreamingTargetPlugin\n */\nclass StreamingTargetPlugin implements WebpackPluginInstance {\n private options: StreamingTargetOptions;\n\n /**\n * Create a StreamingTargetPlugin\n * @param {StreamingTargetOptions} options - The options for the plugin\n */\n constructor(options: StreamingTargetOptions) {\n this.options = options || {};\n }\n\n /**\n * Apply the plugin to the compiler\n * @param {Compiler} compiler - The webpack compiler\n */\n apply(compiler: Compiler) {\n // When used with Next.js, context is needed to use Next.js webpack\n const { webpack } = compiler;\n\n compiler.options.output.chunkFormat = 'commonjs';\n if (compiler.options.output.enabledLibraryTypes === undefined) {\n compiler.options.output.enabledLibraryTypes = ['commonjs-module'];\n } else {\n compiler.options.output.enabledLibraryTypes.push('commonjs-module');\n }\n\n compiler.options.output.chunkLoading = 'async-node';\n\n // Disable default config\n // FIXME: enabledChunkLoadingTypes is of type 'string[] | undefined'\n // Can't use the 'false' value as it isn't the right format,\n // Emptying it out ensures theres no other readFileVm added to webpack runtime\n compiler.options.output.enabledChunkLoadingTypes = [];\n compiler.options.output.environment = {\n ...compiler.options.output.environment,\n dynamicImport: true,\n };\n\n new (\n webpack?.node?.NodeEnvironmentPlugin ||\n require('webpack/lib/node/NodeEnvironmentPlugin')\n )({\n infrastructureLogging: compiler.options.infrastructureLogging,\n }).apply(compiler);\n\n new (\n webpack?.node?.NodeTargetPlugin ||\n require('webpack/lib/node/NodeTargetPlugin')\n )().apply(compiler);\n new CommonJsChunkLoadingPlugin({\n asyncChunkLoading: true,\n name: this.options.name,\n remotes: this.options.remotes as Record<string, string>,\n baseURI: compiler.options.output.publicPath,\n promiseBaseURI: this.options.promiseBaseURI,\n debug: this.options.debug,\n }).apply(compiler);\n }\n}\n\nexport default StreamingTargetPlugin;\n"],"mappings":";;;;;;;AAwBA,IAAM,wBAAN,MAA6D;;;;;CAO3D,YAAY,SAAiC;AAC3C,OAAK,UAAU,WAAW,EAAE;;;;;;CAO9B,MAAM,UAAoB;EAExB,MAAM,EAAE,YAAY;AAEpB,WAAS,QAAQ,OAAO,cAAc;AACtC,MAAI,SAAS,QAAQ,OAAO,wBAAwB,OAClD,UAAS,QAAQ,OAAO,sBAAsB,CAAC,kBAAkB;MAEjE,UAAS,QAAQ,OAAO,oBAAoB,KAAK,kBAAkB;AAGrE,WAAS,QAAQ,OAAO,eAAe;AAMvC,WAAS,QAAQ,OAAO,2BAA2B,EAAE;AACrD,WAAS,QAAQ,OAAO,cAAc;GACpC,GAAG,SAAS,QAAQ,OAAO;GAC3B,eAAe;GAChB;AAED,OACE,SAAS,MAAM,0BACf,QAAQ,yCAAyC,GACjD,EACA,uBAAuB,SAAS,QAAQ,uBACzC,CAAC,CAAC,MAAM,SAAS;AAElB,OACE,SAAS,MAAM,qBACf,QAAQ,oCAAoC,IAC3C,CAAC,MAAM,SAAS;AACnB,MAAIA,uDAA2B;GAC7B,mBAAmB;GACnB,MAAM,KAAK,QAAQ;GACnB,SAAS,KAAK,QAAQ;GACtB,SAAS,SAAS,QAAQ,OAAO;GACjC,gBAAgB,KAAK,QAAQ;GAC7B,OAAO,KAAK,QAAQ;GACrB,CAAC,CAAC,MAAM,SAAS"}
1
+ {"version":3,"file":"StreamingTargetPlugin.js","names":["CommonJsChunkLoadingPlugin"],"sources":["../../../src/plugins/StreamingTargetPlugin.ts"],"sourcesContent":["import type { Compiler, WebpackPluginInstance } from 'webpack';\nimport type { ModuleFederationPluginOptions } from '../types';\n\nimport CommonJsChunkLoadingPlugin from './CommonJsChunkLoadingPlugin';\n\n/**\n * Interface for StreamingTargetOptions which extends ModuleFederationPluginOptions\n * @property {string} promiseBaseURI - The base URI for the promise\n * @property {boolean} debug - Flag to enable/disable debug mode\n */\ninterface StreamingTargetOptions extends ModuleFederationPluginOptions {\n promiseBaseURI?: string;\n debug?: boolean;\n}\n\n/**\n * Class representing a StreamingTargetPlugin\n */\nclass StreamingTargetPlugin implements WebpackPluginInstance {\n private options: StreamingTargetOptions;\n\n /**\n * Create a StreamingTargetPlugin\n * @param {StreamingTargetOptions} options - The options for the plugin\n */\n constructor(options: StreamingTargetOptions) {\n this.options = options || {};\n }\n\n /**\n * Apply the plugin to the compiler\n * @param {Compiler} compiler - The webpack compiler\n */\n apply(compiler: Compiler) {\n // When used with Next.js, context is needed to use Next.js webpack\n const { webpack } = compiler;\n\n compiler.options.output.chunkFormat = 'commonjs';\n if (compiler.options.output.enabledLibraryTypes === undefined) {\n compiler.options.output.enabledLibraryTypes = ['commonjs-module'];\n } else {\n compiler.options.output.enabledLibraryTypes.push('commonjs-module');\n }\n\n compiler.options.output.chunkLoading = 'async-node';\n\n // Disable default config\n // FIXME: enabledChunkLoadingTypes is of type 'string[] | undefined'\n // Can't use the 'false' value as it isn't the right format,\n // Emptying it out ensures theres no other readFileVm added to webpack runtime\n compiler.options.output.enabledChunkLoadingTypes = [];\n compiler.options.output.environment = {\n ...compiler.options.output.environment,\n dynamicImport: true,\n };\n\n new (\n webpack?.node?.NodeEnvironmentPlugin ||\n require('webpack/lib/node/NodeEnvironmentPlugin')\n )({\n infrastructureLogging: compiler.options.infrastructureLogging,\n }).apply(compiler);\n\n new (\n webpack?.node?.NodeTargetPlugin ||\n require('webpack/lib/node/NodeTargetPlugin')\n )().apply(compiler);\n new CommonJsChunkLoadingPlugin({\n asyncChunkLoading: true,\n name: this.options.name,\n remotes: this.options.remotes as Record<string, string>,\n baseURI: compiler.options.output.publicPath,\n promiseBaseURI: this.options.promiseBaseURI,\n debug: this.options.debug,\n }).apply(compiler);\n }\n}\n\nexport default StreamingTargetPlugin;\n"],"mappings":";;;;;;;AAkBA,IAAM,wBAAN,MAA6D;;;;;CAO3D,YAAY,SAAiC;AAC3C,OAAK,UAAU,WAAW,EAAE;;;;;;CAO9B,MAAM,UAAoB;EAExB,MAAM,EAAE,YAAY;AAEpB,WAAS,QAAQ,OAAO,cAAc;AACtC,MAAI,SAAS,QAAQ,OAAO,wBAAwB,OAClD,UAAS,QAAQ,OAAO,sBAAsB,CAAC,kBAAkB;MAEjE,UAAS,QAAQ,OAAO,oBAAoB,KAAK,kBAAkB;AAGrE,WAAS,QAAQ,OAAO,eAAe;AAMvC,WAAS,QAAQ,OAAO,2BAA2B,EAAE;AACrD,WAAS,QAAQ,OAAO,cAAc;GACpC,GAAG,SAAS,QAAQ,OAAO;GAC3B,eAAe;GAChB;AAED,OACE,SAAS,MAAM,0BACf,QAAQ,yCAAyC,GACjD,EACA,uBAAuB,SAAS,QAAQ,uBACzC,CAAC,CAAC,MAAM,SAAS;AAElB,OACE,SAAS,MAAM,qBACf,QAAQ,oCAAoC,IAC3C,CAAC,MAAM,SAAS;AACnB,MAAIA,uDAA2B;GAC7B,mBAAmB;GACnB,MAAM,KAAK,QAAQ;GACnB,SAAS,KAAK,QAAQ;GACtB,SAAS,SAAS,QAAQ,OAAO;GACjC,gBAAgB,KAAK,QAAQ;GAC7B,OAAO,KAAK,QAAQ;GACrB,CAAC,CAAC,MAAM,SAAS"}
@@ -1 +1 @@
1
- {"version":3,"file":"StreamingTargetPlugin.mjs","names":["CommonJsChunkLoadingPlugin"],"sources":["../../../src/plugins/StreamingTargetPlugin.ts"],"sourcesContent":["import type { Compiler, WebpackPluginInstance } from 'webpack';\nimport type { ModuleFederationPluginOptions } from '../types';\n\nimport CommonJsChunkLoadingPlugin from './CommonJsChunkLoadingPlugin';\n\n/**\n * Interface for StreamingTargetOptions which extends ModuleFederationPluginOptions\n * @property {string} promiseBaseURI - The base URI for the promise\n * @property {boolean} debug - Flag to enable/disable debug mode\n */\ninterface StreamingTargetOptions extends ModuleFederationPluginOptions {\n promiseBaseURI?: string;\n debug?: boolean;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-empty-interface\n/**\n * Interface for StreamingTargetContext\n */\ninterface StreamingTargetContext {}\n\n/**\n * Class representing a StreamingTargetPlugin\n */\nclass StreamingTargetPlugin implements WebpackPluginInstance {\n private options: StreamingTargetOptions;\n\n /**\n * Create a StreamingTargetPlugin\n * @param {StreamingTargetOptions} options - The options for the plugin\n */\n constructor(options: StreamingTargetOptions) {\n this.options = options || {};\n }\n\n /**\n * Apply the plugin to the compiler\n * @param {Compiler} compiler - The webpack compiler\n */\n apply(compiler: Compiler) {\n // When used with Next.js, context is needed to use Next.js webpack\n const { webpack } = compiler;\n\n compiler.options.output.chunkFormat = 'commonjs';\n if (compiler.options.output.enabledLibraryTypes === undefined) {\n compiler.options.output.enabledLibraryTypes = ['commonjs-module'];\n } else {\n compiler.options.output.enabledLibraryTypes.push('commonjs-module');\n }\n\n compiler.options.output.chunkLoading = 'async-node';\n\n // Disable default config\n // FIXME: enabledChunkLoadingTypes is of type 'string[] | undefined'\n // Can't use the 'false' value as it isn't the right format,\n // Emptying it out ensures theres no other readFileVm added to webpack runtime\n compiler.options.output.enabledChunkLoadingTypes = [];\n compiler.options.output.environment = {\n ...compiler.options.output.environment,\n dynamicImport: true,\n };\n\n new (\n webpack?.node?.NodeEnvironmentPlugin ||\n require('webpack/lib/node/NodeEnvironmentPlugin')\n )({\n infrastructureLogging: compiler.options.infrastructureLogging,\n }).apply(compiler);\n\n new (\n webpack?.node?.NodeTargetPlugin ||\n require('webpack/lib/node/NodeTargetPlugin')\n )().apply(compiler);\n new CommonJsChunkLoadingPlugin({\n asyncChunkLoading: true,\n name: this.options.name,\n remotes: this.options.remotes as Record<string, string>,\n baseURI: compiler.options.output.publicPath,\n promiseBaseURI: this.options.promiseBaseURI,\n debug: this.options.debug,\n }).apply(compiler);\n }\n}\n\nexport default StreamingTargetPlugin;\n"],"mappings":";;;;;;;AAwBA,IAAM,wBAAN,MAA6D;;;;;CAO3D,YAAY,SAAiC;AAC3C,OAAK,UAAU,WAAW,EAAE;;;;;;CAO9B,MAAM,UAAoB;EAExB,MAAM,EAAE,YAAY;AAEpB,WAAS,QAAQ,OAAO,cAAc;AACtC,MAAI,SAAS,QAAQ,OAAO,wBAAwB,OAClD,UAAS,QAAQ,OAAO,sBAAsB,CAAC,kBAAkB;MAEjE,UAAS,QAAQ,OAAO,oBAAoB,KAAK,kBAAkB;AAGrE,WAAS,QAAQ,OAAO,eAAe;AAMvC,WAAS,QAAQ,OAAO,2BAA2B,EAAE;AACrD,WAAS,QAAQ,OAAO,cAAc;GACpC,GAAG,SAAS,QAAQ,OAAO;GAC3B,eAAe;GAChB;AAED,OACE,SAAS,MAAM,oCACP,yCAAyC,GACjD,EACA,uBAAuB,SAAS,QAAQ,uBACzC,CAAC,CAAC,MAAM,SAAS;AAElB,OACE,SAAS,MAAM,+BACP,oCAAoC,IAC3C,CAAC,MAAM,SAAS;AACnB,MAAIA,oCAA2B;GAC7B,mBAAmB;GACnB,MAAM,KAAK,QAAQ;GACnB,SAAS,KAAK,QAAQ;GACtB,SAAS,SAAS,QAAQ,OAAO;GACjC,gBAAgB,KAAK,QAAQ;GAC7B,OAAO,KAAK,QAAQ;GACrB,CAAC,CAAC,MAAM,SAAS"}
1
+ {"version":3,"file":"StreamingTargetPlugin.mjs","names":["CommonJsChunkLoadingPlugin"],"sources":["../../../src/plugins/StreamingTargetPlugin.ts"],"sourcesContent":["import type { Compiler, WebpackPluginInstance } from 'webpack';\nimport type { ModuleFederationPluginOptions } from '../types';\n\nimport CommonJsChunkLoadingPlugin from './CommonJsChunkLoadingPlugin';\n\n/**\n * Interface for StreamingTargetOptions which extends ModuleFederationPluginOptions\n * @property {string} promiseBaseURI - The base URI for the promise\n * @property {boolean} debug - Flag to enable/disable debug mode\n */\ninterface StreamingTargetOptions extends ModuleFederationPluginOptions {\n promiseBaseURI?: string;\n debug?: boolean;\n}\n\n/**\n * Class representing a StreamingTargetPlugin\n */\nclass StreamingTargetPlugin implements WebpackPluginInstance {\n private options: StreamingTargetOptions;\n\n /**\n * Create a StreamingTargetPlugin\n * @param {StreamingTargetOptions} options - The options for the plugin\n */\n constructor(options: StreamingTargetOptions) {\n this.options = options || {};\n }\n\n /**\n * Apply the plugin to the compiler\n * @param {Compiler} compiler - The webpack compiler\n */\n apply(compiler: Compiler) {\n // When used with Next.js, context is needed to use Next.js webpack\n const { webpack } = compiler;\n\n compiler.options.output.chunkFormat = 'commonjs';\n if (compiler.options.output.enabledLibraryTypes === undefined) {\n compiler.options.output.enabledLibraryTypes = ['commonjs-module'];\n } else {\n compiler.options.output.enabledLibraryTypes.push('commonjs-module');\n }\n\n compiler.options.output.chunkLoading = 'async-node';\n\n // Disable default config\n // FIXME: enabledChunkLoadingTypes is of type 'string[] | undefined'\n // Can't use the 'false' value as it isn't the right format,\n // Emptying it out ensures theres no other readFileVm added to webpack runtime\n compiler.options.output.enabledChunkLoadingTypes = [];\n compiler.options.output.environment = {\n ...compiler.options.output.environment,\n dynamicImport: true,\n };\n\n new (\n webpack?.node?.NodeEnvironmentPlugin ||\n require('webpack/lib/node/NodeEnvironmentPlugin')\n )({\n infrastructureLogging: compiler.options.infrastructureLogging,\n }).apply(compiler);\n\n new (\n webpack?.node?.NodeTargetPlugin ||\n require('webpack/lib/node/NodeTargetPlugin')\n )().apply(compiler);\n new CommonJsChunkLoadingPlugin({\n asyncChunkLoading: true,\n name: this.options.name,\n remotes: this.options.remotes as Record<string, string>,\n baseURI: compiler.options.output.publicPath,\n promiseBaseURI: this.options.promiseBaseURI,\n debug: this.options.debug,\n }).apply(compiler);\n }\n}\n\nexport default StreamingTargetPlugin;\n"],"mappings":";;;;;;;AAkBA,IAAM,wBAAN,MAA6D;;;;;CAO3D,YAAY,SAAiC;AAC3C,OAAK,UAAU,WAAW,EAAE;;;;;;CAO9B,MAAM,UAAoB;EAExB,MAAM,EAAE,YAAY;AAEpB,WAAS,QAAQ,OAAO,cAAc;AACtC,MAAI,SAAS,QAAQ,OAAO,wBAAwB,OAClD,UAAS,QAAQ,OAAO,sBAAsB,CAAC,kBAAkB;MAEjE,UAAS,QAAQ,OAAO,oBAAoB,KAAK,kBAAkB;AAGrE,WAAS,QAAQ,OAAO,eAAe;AAMvC,WAAS,QAAQ,OAAO,2BAA2B,EAAE;AACrD,WAAS,QAAQ,OAAO,cAAc;GACpC,GAAG,SAAS,QAAQ,OAAO;GAC3B,eAAe;GAChB;AAED,OACE,SAAS,MAAM,oCACP,yCAAyC,GACjD,EACA,uBAAuB,SAAS,QAAQ,uBACzC,CAAC,CAAC,MAAM,SAAS;AAElB,OACE,SAAS,MAAM,+BACP,oCAAoC,IAC3C,CAAC,MAAM,SAAS;AACnB,MAAIA,oCAA2B;GAC7B,mBAAmB;GACnB,MAAM,KAAK,QAAQ;GACnB,SAAS,KAAK,QAAQ;GACtB,SAAS,SAAS,QAAQ,OAAO;GACjC,gBAAgB,KAAK,QAAQ;GAC7B,OAAO,KAAK,QAAQ;GACrB,CAAC,CAAC,MAAM,SAAS"}
@@ -15,7 +15,7 @@ declare function generateHmrCode(withHmr: boolean, rootOutputDir: string): strin
15
15
  * @param {any} chunkHasJs - Function to check if a chunk has JavaScript.
16
16
  * @returns {Set} - The set of initial chunk IDs.
17
17
  */
18
- declare function getInitialChunkIds(chunk: Chunk, chunkGraph: ChunkGraph, chunkHasJs: any): Set<Chunk.ChunkId>;
18
+ declare function getInitialChunkIds(chunk: Chunk, chunkGraph: ChunkGraph, chunkHasJs: any): Set<string | number>;
19
19
  /**
20
20
  * Generates the loading code for chunks.
21
21
  * @param {boolean} withLoading - Flag indicating whether chunk loading is enabled.
@@ -15,7 +15,7 @@ declare function generateHmrCode(withHmr: boolean, rootOutputDir: string): strin
15
15
  * @param {any} chunkHasJs - Function to check if a chunk has JavaScript.
16
16
  * @returns {Set} - The set of initial chunk IDs.
17
17
  */
18
- declare function getInitialChunkIds(chunk: Chunk, chunkGraph: ChunkGraph, chunkHasJs: any): Set<Chunk.ChunkId>;
18
+ declare function getInitialChunkIds(chunk: Chunk, chunkGraph: ChunkGraph, chunkHasJs: any): Set<string | number>;
19
19
  /**
20
20
  * Generates the loading code for chunks.
21
21
  * @param {boolean} withLoading - Flag indicating whether chunk loading is enabled.
@@ -1,15 +1,17 @@
1
+ import { RemoteInfo } from "@module-federation/runtime/types";
2
+
1
3
  //#region src/utils/flush-chunks.d.ts
2
4
  /**
3
5
  * Initialize usedChunks and share it globally.
4
6
  * @type {Set}
5
7
  */
6
8
  declare const usedChunks: any;
7
- declare const getAllKnownRemotes: () => {};
9
+ declare const getAllKnownRemotes: () => Record<string, RemoteInfo>;
8
10
  /**
9
11
  * Flush the chunks and return a deduplicated array of chunks.
10
12
  * @returns {Promise<Array>} A promise that resolves to an array of deduplicated chunks.
11
13
  */
12
- declare const flushChunks: () => Promise<unknown[]>;
14
+ declare const flushChunks: () => Promise<string[]>;
13
15
  //#endregion
14
16
  export { flushChunks, getAllKnownRemotes, usedChunks };
15
17
  //# sourceMappingURL=flush-chunks.d.mts.map
@@ -1,15 +1,17 @@
1
+ import { RemoteInfo } from "@module-federation/runtime/types";
2
+
1
3
  //#region src/utils/flush-chunks.d.ts
2
4
  /**
3
5
  * Initialize usedChunks and share it globally.
4
6
  * @type {Set}
5
7
  */
6
8
  declare const usedChunks: any;
7
- declare const getAllKnownRemotes: () => {};
9
+ declare const getAllKnownRemotes: () => Record<string, RemoteInfo>;
8
10
  /**
9
11
  * Flush the chunks and return a deduplicated array of chunks.
10
12
  * @returns {Promise<Array>} A promise that resolves to an array of deduplicated chunks.
11
13
  */
12
- declare const flushChunks: () => Promise<unknown[]>;
14
+ declare const flushChunks: () => Promise<string[]>;
13
15
  //#endregion
14
16
  export { flushChunks, getAllKnownRemotes, usedChunks };
15
17
  //# sourceMappingURL=flush-chunks.d.ts.map
@@ -1,4 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('../../_virtual/_rolldown/runtime.js');
3
+ let _module_federation_sdk = require("@module-federation/sdk");
2
4
 
3
5
  //#region src/utils/flush-chunks.ts
4
6
  if (!globalThis.usedChunks) globalThis.usedChunks = /* @__PURE__ */ new Set();
@@ -7,83 +9,107 @@ if (!globalThis.usedChunks) globalThis.usedChunks = /* @__PURE__ */ new Set();
7
9
  * @type {Set}
8
10
  */
9
11
  const { usedChunks } = globalThis;
10
- /**
11
- * Load hostStats from the JSON file.
12
- * @returns {object} hostStats - An object containing host stats data.
13
- */
14
- const loadHostStats = () => {
15
- try {
16
- return __non_webpack_require__("../federated-stats.json");
17
- } catch (e) {
18
- return {};
19
- }
20
- };
12
+ const getFederationController = () => new Function("return globalThis")().__FEDERATION__;
21
13
  const getAllKnownRemotes = function() {
22
- const federationController = new Function("return globalThis")().__FEDERATION__;
14
+ const federationController = getFederationController();
23
15
  if (!federationController || !federationController.__INSTANCES__) return {};
24
- var collected = {};
25
- for (const instance of federationController.__INSTANCES__) for (const [key, cacheModule] of instance.moduleCache) if (cacheModule.remoteInfo) collected[cacheModule.remoteInfo.name] = cacheModule.remoteInfo;
16
+ const collected = {};
17
+ for (const instance of federationController.__INSTANCES__) for (const [, cacheModule] of instance.moduleCache) if (cacheModule.remoteInfo) {
18
+ const remoteInfo = cacheModule.remoteInfo;
19
+ collected[remoteInfo.name] = remoteInfo;
20
+ if (remoteInfo.alias) collected[remoteInfo.alias] = remoteInfo;
21
+ }
26
22
  return collected;
27
23
  };
28
- /**
29
- * Create a shareMap based on the loaded modules.
30
- * @returns {object} shareMap - An object containing the shareMap data.
31
- */
32
- const createShareMap = () => {
33
- if (__webpack_share_scopes__?.default) return Object.keys(__webpack_share_scopes__.default).reduce((acc, key) => {
34
- const shareMap = __webpack_share_scopes__.default[key];
35
- if (!shareMap || typeof shareMap !== "object") return acc;
36
- const loadedModules = Object.values(shareMap).filter((sharedModule) => sharedModule.loaded).map((sharedModule) => sharedModule.from);
37
- if (loadedModules.length > 0) acc[key] = loadedModules;
38
- return acc;
39
- }, {});
40
- return {};
24
+ const getConfiguredManifestUrls = () => {
25
+ const manifestUrls = /* @__PURE__ */ new Map();
26
+ const federationController = getFederationController();
27
+ for (const instance of federationController?.__INSTANCES__ || []) for (const configuredRemote of instance.options?.remotes || []) {
28
+ if (!("entry" in configuredRemote)) continue;
29
+ try {
30
+ if (!new URL(configuredRemote.entry).pathname.endsWith(".json")) continue;
31
+ } catch {
32
+ continue;
33
+ }
34
+ manifestUrls.set(configuredRemote.name, configuredRemote.entry);
35
+ if (configuredRemote.alias) manifestUrls.set(configuredRemote.alias, configuredRemote.entry);
36
+ }
37
+ return manifestUrls;
41
38
  };
42
- /**
43
- * Process a single chunk and return an array of updated chunks.
44
- * @param {string} chunk - A chunk string containing remote and request data.
45
- * @param {object} shareMap - An object containing the shareMap data.
46
- * @param {object} hostStats - An object containing host stats data.
47
- * @returns {Promise<Array>} A promise that resolves to an array of updated chunks.
48
- */
49
- const processChunk = async (chunk, shareMap, hostStats) => {
39
+ const parseUsedChunk = (chunk, remoteNames) => {
40
+ const normalizedChunk = chunk.replace("->", "/");
41
+ const remote = remoteNames.find((name) => normalizedChunk === name || normalizedChunk.startsWith(`${name}/`)) || normalizedChunk.split("/", 1)[0];
42
+ const request = normalizedChunk.slice(remote.length).replace(/^\//, "");
43
+ return [remote, request.startsWith("./") ? request : `./${request}`];
44
+ };
45
+ const getMetadataUrl = (entry, filename) => {
46
+ const url = new URL(entry);
47
+ url.pathname = `${url.pathname.slice(0, url.pathname.lastIndexOf("/") + 1)}${filename}`;
48
+ url.pathname = url.pathname.replace("/ssr/", "/chunks/");
49
+ return url.href;
50
+ };
51
+ const getManifestUrl = (remoteInfo, configuredManifestUrl) => {
52
+ if (configuredManifestUrl) return configuredManifestUrl;
53
+ return getMetadataUrl(remoteInfo.entry, "mf-manifest.json");
54
+ };
55
+ const getAssetBaseUrl = (metadataUrl) => {
56
+ const baseUrl = new URL(metadataUrl);
57
+ const staticPathIndex = baseUrl.pathname.indexOf("/static/");
58
+ baseUrl.pathname = staticPathIndex === -1 ? baseUrl.pathname.slice(0, baseUrl.pathname.lastIndexOf("/") + 1) : baseUrl.pathname.slice(0, staticPathIndex + 1);
59
+ baseUrl.search = "";
60
+ baseUrl.hash = "";
61
+ return baseUrl;
62
+ };
63
+ const fetchJson = async (url) => {
64
+ const response = await fetch(url);
65
+ if (!response.ok) throw new Error(`Request failed with status ${response.status}`);
66
+ return response.json();
67
+ };
68
+ const collectManifestAssets = (manifest, manifestUrl, requests) => {
50
69
  const chunks = /* @__PURE__ */ new Set();
51
- const normalizedChunk = chunk.includes("->") ? chunk.replace("->", "/") : chunk;
52
- const remoteSeparatorIndex = normalizedChunk.indexOf("/");
53
- const remote = remoteSeparatorIndex === -1 ? normalizedChunk : normalizedChunk.slice(0, remoteSeparatorIndex);
54
- const req = remoteSeparatorIndex === -1 ? "" : normalizedChunk.slice(remoteSeparatorIndex + 1);
55
- const request = req?.startsWith("./") ? req : "./" + req;
56
- const knownRemotes = getAllKnownRemotes();
57
- if (!knownRemotes[remote]) {
58
- console.error(`flush chunks: Remote ${remote} is not defined in the global config`);
59
- return;
70
+ const missingRequests = new Set(requests);
71
+ let assetBaseUrl = getAssetBaseUrl(manifestUrl);
72
+ const resourceBasePath = (0, _module_federation_sdk.getResourceUrl)(manifest.metaData, "");
73
+ if (resourceBasePath !== "auto") {
74
+ const normalizedBasePath = resourceBasePath && !resourceBasePath.endsWith("/") ? `${resourceBasePath}/` : resourceBasePath || "./";
75
+ assetBaseUrl = new URL(normalizedBasePath, manifestUrl);
60
76
  }
77
+ const resolveAssetUrl = (file) => new URL(file, assetBaseUrl).href;
78
+ for (const expose of manifest.exposes) {
79
+ const request = expose.path || `./${expose.name}`;
80
+ if (!requests.has(request)) continue;
81
+ if (expose.assets.js.sync.length > 0 || expose.assets.css.sync.length > 0) missingRequests.delete(request);
82
+ for (const file of expose.assets.js.sync) chunks.add(resolveAssetUrl(file));
83
+ for (const file of expose.assets.css.sync) chunks.add(resolveAssetUrl(file));
84
+ }
85
+ return {
86
+ chunks: Array.from(chunks),
87
+ missingRequests
88
+ };
89
+ };
90
+ const collectLegacyAssets = (stats, statsUrl, requests) => {
91
+ const chunks = /* @__PURE__ */ new Set();
92
+ const assetBaseUrl = getAssetBaseUrl(statsUrl);
93
+ for (const federatedModule of stats.federatedModules || []) for (const request of requests) for (const file of federatedModule.exposes?.[request] || []) chunks.add(new URL(file, assetBaseUrl).href);
94
+ return Array.from(chunks);
95
+ };
96
+ const processRemote = async (remoteInfo, requests, configuredManifestUrl) => {
97
+ const manifestUrl = getManifestUrl(remoteInfo, configuredManifestUrl);
98
+ let manifestChunks = [];
99
+ let legacyRequests = requests;
61
100
  try {
62
- const remoteName = new URL(knownRemotes[remote].entry).pathname.split("/").pop();
63
- const statsFile = knownRemotes[remote].entry.replace(remoteName, "federated-stats.json").replace("ssr", "chunks");
64
- let stats = {};
65
- try {
66
- stats = await fetch(statsFile).then((res) => res.json());
67
- } catch (e) {
68
- console.error("flush error", e);
69
- }
70
- const [prefix] = knownRemotes[remote].entry.split("static/");
71
- if (stats.federatedModules) stats.federatedModules.forEach((modules) => {
72
- if (modules.exposes?.[request]) modules.exposes[request].forEach((chunk) => {
73
- chunks.add([prefix, chunk].join(""));
74
- Object.values(chunk).forEach((chunk) => {
75
- if (chunk.files) chunk.files.forEach((file) => {
76
- chunks.add(prefix + file);
77
- });
78
- if (chunk.requiredModules) chunk.requiredModules.forEach((module) => {
79
- if (shareMap[module]) {}
80
- });
81
- });
82
- });
83
- });
84
- return Array.from(chunks);
85
- } catch (e) {
86
- console.error("flush error:", e);
101
+ const { chunks, missingRequests } = collectManifestAssets(await fetchJson(manifestUrl), manifestUrl, requests);
102
+ manifestChunks = chunks;
103
+ if (!missingRequests.size) return chunks;
104
+ legacyRequests = missingRequests;
105
+ } catch {}
106
+ const statsUrl = getMetadataUrl(remoteInfo.entry, "federated-stats.json");
107
+ try {
108
+ const stats = await fetchJson(statsUrl);
109
+ return Array.from(new Set([...manifestChunks, ...collectLegacyAssets(stats, statsUrl, legacyRequests)]));
110
+ } catch (error) {
111
+ if (!manifestChunks.length) console.error("flush error:", error);
112
+ return manifestChunks;
87
113
  }
88
114
  };
89
115
  /**
@@ -91,12 +117,28 @@ const processChunk = async (chunk, shareMap, hostStats) => {
91
117
  * @returns {Promise<Array>} A promise that resolves to an array of deduplicated chunks.
92
118
  */
93
119
  const flushChunks = async () => {
94
- const hostStats = loadHostStats();
95
- const shareMap = createShareMap();
96
- const allFlushed = await Promise.all(Array.from(usedChunks).map(async (chunk) => processChunk(chunk, shareMap, hostStats)));
97
- const dedupe = Array.from(new Set([...allFlushed.flat()]));
120
+ const knownRemotes = getAllKnownRemotes();
121
+ const configuredManifestUrls = getConfiguredManifestUrls();
122
+ const remoteNames = Object.keys(knownRemotes).sort((left, right) => right.length - left.length);
123
+ const requestsByRemote = /* @__PURE__ */ new Map();
124
+ for (const chunk of usedChunks) {
125
+ const [remote, request] = parseUsedChunk(chunk, remoteNames);
126
+ const remoteInfo = knownRemotes[remote];
127
+ if (!remoteInfo) {
128
+ console.error(`flush chunks: Remote ${remote} is not defined in the global config`);
129
+ continue;
130
+ }
131
+ const remoteRequests = requestsByRemote.get(remoteInfo.name) || {
132
+ remoteInfo,
133
+ manifestUrl: configuredManifestUrls.get(remote) || configuredManifestUrls.get(remoteInfo.name),
134
+ requests: /* @__PURE__ */ new Set()
135
+ };
136
+ remoteRequests.requests.add(request);
137
+ requestsByRemote.set(remoteInfo.name, remoteRequests);
138
+ }
98
139
  usedChunks.clear();
99
- return dedupe.filter(Boolean);
140
+ const allFlushed = await Promise.all(Array.from(requestsByRemote.values(), ({ remoteInfo, requests, manifestUrl }) => processRemote(remoteInfo, requests, manifestUrl)));
141
+ return Array.from(new Set(allFlushed.flat()));
100
142
  };
101
143
 
102
144
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"flush-chunks.js","names":[],"sources":["../../../src/utils/flush-chunks.ts"],"sourcesContent":["/* eslint-disable no-undef */\n\n// @ts-ignore\nif (!globalThis.usedChunks) {\n // @ts-ignore\n globalThis.usedChunks = new Set();\n}\n/**\n * Initialize usedChunks and share it globally.\n * @type {Set}\n */\n// @ts-ignore\nexport const { usedChunks } = globalThis;\n/**\n * Load hostStats from the JSON file.\n * @returns {object} hostStats - An object containing host stats data.\n */\nconst loadHostStats = () => {\n try {\n //@ts-ignore\n return __non_webpack_require__('../federated-stats.json');\n } catch (e) {\n return {};\n }\n};\n\nexport const getAllKnownRemotes = function () {\n // Attempt to access the global federation controller safely\n const federationController = new Function('return globalThis')()\n .__FEDERATION__;\n if (!federationController || !federationController.__INSTANCES__) {\n // If the federation controller or instances are not defined, return an empty object\n return {};\n }\n\n var collected = {};\n // Use a for...of loop to iterate over all federation instances\n for (const instance of federationController.__INSTANCES__) {\n // Use another for...of loop to iterate over the module cache Map entries\n for (const [key, cacheModule] of instance.moduleCache) {\n // Check if the cacheModule has remoteInfo and use it to collect remote names\n if (cacheModule.remoteInfo) {\n //@ts-ignore\n collected[cacheModule.remoteInfo.name] = cacheModule.remoteInfo;\n }\n }\n }\n return collected;\n};\n\n/**\n * Create a shareMap based on the loaded modules.\n * @returns {object} shareMap - An object containing the shareMap data.\n */\nconst createShareMap = () => {\n // Check if __webpack_share_scopes__ is defined and has a default property\n // @ts-ignore\n if (__webpack_share_scopes__?.default) {\n // Reduce the keys of the default property to create the share map\n // @ts-ignore\n return Object.keys(__webpack_share_scopes__.default).reduce((acc, key) => {\n // @ts-ignore\n const shareMap = __webpack_share_scopes__.default[key];\n // shareScope may equal undefined or null if it has unexpected value\n if (!shareMap || typeof shareMap !== 'object') {\n return acc;\n }\n // Get the loaded modules for the current key\n const loadedModules = Object.values(shareMap)\n // Filter out the modules that are not loaded\n // @ts-ignore\n .filter((sharedModule) => sharedModule.loaded)\n // Map the filtered modules to their 'from' properties\n // @ts-ignore\n .map((sharedModule) => sharedModule.from);\n\n // If there are any loaded modules, add them to the accumulator object\n if (loadedModules.length > 0) {\n // @ts-ignore\n acc[key] = loadedModules;\n }\n // Return the accumulator object for the next iteration\n return acc;\n }, {});\n }\n // If __webpack_share_scopes__ is not defined or doesn't have a default property, return an empty object\n return {};\n};\n\n/**\n * Process a single chunk and return an array of updated chunks.\n * @param {string} chunk - A chunk string containing remote and request data.\n * @param {object} shareMap - An object containing the shareMap data.\n * @param {object} hostStats - An object containing host stats data.\n * @returns {Promise<Array>} A promise that resolves to an array of updated chunks.\n */\n// @ts-ignore\nconst processChunk = async (chunk, shareMap, hostStats) => {\n const chunks = new Set();\n const normalizedChunk = chunk.includes('->')\n ? chunk.replace('->', '/')\n : chunk;\n const remoteSeparatorIndex = normalizedChunk.indexOf('/');\n const remote =\n remoteSeparatorIndex === -1\n ? normalizedChunk\n : normalizedChunk.slice(0, remoteSeparatorIndex);\n const req =\n remoteSeparatorIndex === -1\n ? ''\n : normalizedChunk.slice(remoteSeparatorIndex + 1);\n const request = req?.startsWith('./') ? req : './' + req;\n const knownRemotes = getAllKnownRemotes();\n //@ts-ignore\n if (!knownRemotes[remote]) {\n console.error(\n `flush chunks: Remote ${remote} is not defined in the global config`,\n );\n return;\n }\n\n try {\n //@ts-ignore\n const remoteName = new URL(knownRemotes[remote].entry).pathname\n .split('/')\n .pop();\n //@ts-ignore\n\n const statsFile = knownRemotes[remote].entry\n .replace(remoteName, 'federated-stats.json')\n .replace('ssr', 'chunks');\n let stats = {};\n\n try {\n stats = await fetch(statsFile).then((res) => res.json());\n } catch (e) {\n console.error('flush error', e);\n }\n //@ts-ignore\n\n const [prefix] = knownRemotes[remote].entry.split('static/');\n //@ts-ignore\n\n if (stats.federatedModules) {\n //@ts-ignore\n\n stats.federatedModules.forEach((modules) => {\n if (modules.exposes?.[request]) {\n //@ts-ignore\n\n modules.exposes[request].forEach((chunk) => {\n chunks.add([prefix, chunk].join(''));\n\n Object.values(chunk).forEach((chunk) => {\n //@ts-ignore\n\n if (chunk.files) {\n //@ts-ignore\n\n chunk.files.forEach((file) => {\n chunks.add(prefix + file);\n });\n }\n //@ts-ignore\n\n if (chunk.requiredModules) {\n //@ts-ignore\n\n chunk.requiredModules.forEach((module) => {\n if (shareMap[module]) {\n // If the module is from the host, log the host stats\n }\n });\n }\n });\n });\n }\n });\n }\n\n return Array.from(chunks);\n } catch (e) {\n console.error('flush error:', e);\n }\n};\n\n/**\n * Flush the chunks and return a deduplicated array of chunks.\n * @returns {Promise<Array>} A promise that resolves to an array of deduplicated chunks.\n */\nexport const flushChunks = async () => {\n const hostStats = loadHostStats();\n const shareMap = createShareMap();\n\n const allFlushed = await Promise.all(\n Array.from(usedChunks).map(async (chunk) =>\n processChunk(chunk, shareMap, hostStats),\n ),\n );\n\n // Deduplicate the chunks array\n const dedupe = Array.from(new Set([...allFlushed.flat()]));\n\n // Clear usedChunks\n usedChunks.clear();\n // Filter out any undefined or null values\n return dedupe.filter(Boolean);\n};\n"],"mappings":";;;AAGA,IAAI,CAAC,WAAW,WAEd,YAAW,6BAAa,IAAI,KAAK;;;;;AAOnC,MAAa,EAAE,eAAe;;;;;AAK9B,MAAM,sBAAsB;AAC1B,KAAI;AAEF,SAAO,wBAAwB,0BAA0B;UAClD,GAAG;AACV,SAAO,EAAE;;;AAIb,MAAa,qBAAqB,WAAY;CAE5C,MAAM,uBAAuB,IAAI,SAAS,oBAAoB,EAAE,CAC7D;AACH,KAAI,CAAC,wBAAwB,CAAC,qBAAqB,cAEjD,QAAO,EAAE;CAGX,IAAI,YAAY,EAAE;AAElB,MAAK,MAA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,MAAI;AACF,WAAQ,MAAM,MAAM,UAAU,CAAC,MAAM,QAAQ,IAAI,MAAM,CAAC;WACjD,GAAG;AACV,WAAQ,MAAM,eAAe,EAAE;;EAIjC,MAAM,CAAC,UAAU,aAAa,QAAQ,MAAM,MAAM,UAAU;AAG5D,MAAI,MAAM,iBAGR,OAAM,iBAAiB,SAAS,YAAY;AAC1C,OAAI,QAAQ,UAAU,SAGpB,SAAQ,QAAQ,SAAS,SAAS,UAAU;AAC1C,WAAO,IAAI,CAAC,QAAQ,MAAM,CAAC,KAAK,GAAG,CAAC;AAEpC,WAAO,OAAO,MAAM,CAAC,SAAS,UAAU;AAGtC,SAAI,MAAM,MAGR,OAAM,MAAM,SAAS,SAAS;AAC5B,aAAO,IAAI,SAAS,KAAK;OACzB;AAIJ,SAAI,MAAM,gBAGR,OAAM,gBAAgB,SAAS,WAAW;AACxC,UAAI,SAAS,SAAS;OAGtB;MAEJ;KACF;IAEJ;AAGJ,SAAO,MAAM,KAAK,OAAO;UAClB,GAAG;AACV,UAAQ,MAAM,gBAAgB,EAAE;;;;;;;AAQpC,MAAa,cAAc,YAAY;CACrC,MAAM,YAAY,eAAe;CACjC,MAAM,WAAW,gBAAgB;CAEjC,MAAM,aAAa,MAAM,QAAQ,IAC/B,MAAM,KAAK,WAAW,CAAC,IAAI,OAAO,UAChC,aAAa,OAAO,UAAU,UAAU,CACzC,CACF;CAGD,MAAM,SAAS,MAAM,KAAK,IAAI,IAAI,CAAC,GAAG,WAAW,MAAM,CAAC,CAAC,CAAC;AAG1D,YAAW,OAAO;AAElB,QAAO,OAAO,OAAO,QAAQ"}
1
+ {"version":3,"file":"flush-chunks.js","names":[],"sources":["../../../src/utils/flush-chunks.ts"],"sourcesContent":["/* eslint-disable no-undef */\n\nimport { getResourceUrl, type Manifest } from '@module-federation/sdk';\nimport type { RemoteInfo } from '@module-federation/runtime/types';\n\ntype LegacyFederatedStats = {\n federatedModules?: Array<{\n exposes?: Record<string, string[]>;\n }>;\n};\n\ntype RemoteRequests = {\n remoteInfo: RemoteInfo;\n manifestUrl?: string;\n requests: Set<string>;\n};\n\n// @ts-ignore\nif (!globalThis.usedChunks) {\n // @ts-ignore\n globalThis.usedChunks = new Set();\n}\n/**\n * Initialize usedChunks and share it globally.\n * @type {Set}\n */\n// @ts-ignore\nexport const { usedChunks } = globalThis;\nconst getFederationController = () =>\n new Function('return globalThis')().__FEDERATION__;\n\nexport const getAllKnownRemotes = function (): Record<string, RemoteInfo> {\n const federationController = getFederationController();\n if (!federationController || !federationController.__INSTANCES__) {\n return {};\n }\n\n const collected: Record<string, RemoteInfo> = {};\n for (const instance of federationController.__INSTANCES__) {\n for (const [, cacheModule] of instance.moduleCache) {\n if (cacheModule.remoteInfo) {\n const remoteInfo = cacheModule.remoteInfo as RemoteInfo;\n collected[remoteInfo.name] = remoteInfo;\n if (remoteInfo.alias) collected[remoteInfo.alias] = remoteInfo;\n }\n }\n }\n return collected;\n};\n\nconst getConfiguredManifestUrls = (): Map<string, string> => {\n const manifestUrls = new Map<string, string>();\n const federationController = getFederationController();\n\n for (const instance of federationController?.__INSTANCES__ || []) {\n for (const configuredRemote of instance.options?.remotes || []) {\n if (!('entry' in configuredRemote)) continue;\n try {\n if (!new URL(configuredRemote.entry).pathname.endsWith('.json')) {\n continue;\n }\n } catch {\n continue;\n }\n manifestUrls.set(configuredRemote.name, configuredRemote.entry);\n if (configuredRemote.alias) {\n manifestUrls.set(configuredRemote.alias, configuredRemote.entry);\n }\n }\n }\n\n return manifestUrls;\n};\n\nconst parseUsedChunk = (\n chunk: string,\n remoteNames: string[],\n): [remote: string, request: string] => {\n const normalizedChunk = chunk.replace('->', '/');\n const remote =\n remoteNames.find(\n (name) =>\n normalizedChunk === name || normalizedChunk.startsWith(`${name}/`),\n ) || normalizedChunk.split('/', 1)[0];\n const request = normalizedChunk.slice(remote.length).replace(/^\\//, '');\n return [remote, request.startsWith('./') ? request : `./${request}`];\n};\n\nconst getMetadataUrl = (entry: string, filename: string): string => {\n const url = new URL(entry);\n url.pathname = `${url.pathname.slice(0, url.pathname.lastIndexOf('/') + 1)}${filename}`;\n url.pathname = url.pathname.replace('/ssr/', '/chunks/');\n return url.href;\n};\n\nconst getManifestUrl = (\n remoteInfo: RemoteInfo,\n configuredManifestUrl?: string,\n): string => {\n if (configuredManifestUrl) return configuredManifestUrl;\n return getMetadataUrl(remoteInfo.entry, 'mf-manifest.json');\n};\n\nconst getAssetBaseUrl = (metadataUrl: string): URL => {\n const baseUrl = new URL(metadataUrl);\n const staticPathIndex = baseUrl.pathname.indexOf('/static/');\n baseUrl.pathname =\n staticPathIndex === -1\n ? baseUrl.pathname.slice(0, baseUrl.pathname.lastIndexOf('/') + 1)\n : baseUrl.pathname.slice(0, staticPathIndex + 1);\n baseUrl.search = '';\n baseUrl.hash = '';\n return baseUrl;\n};\n\nconst fetchJson = async <T>(url: string): Promise<T> => {\n const response = await fetch(url);\n if (!response.ok) {\n throw new Error(`Request failed with status ${response.status}`);\n }\n return response.json() as Promise<T>;\n};\n\nconst collectManifestAssets = (\n manifest: Manifest,\n manifestUrl: string,\n requests: Set<string>,\n): { chunks: string[]; missingRequests: Set<string> } => {\n const chunks = new Set<string>();\n const missingRequests = new Set(requests);\n let assetBaseUrl = getAssetBaseUrl(manifestUrl);\n const resourceBasePath = getResourceUrl(manifest.metaData, '');\n\n if (resourceBasePath !== 'auto') {\n const normalizedBasePath =\n resourceBasePath && !resourceBasePath.endsWith('/')\n ? `${resourceBasePath}/`\n : resourceBasePath || './';\n assetBaseUrl = new URL(normalizedBasePath, manifestUrl);\n }\n\n const resolveAssetUrl = (file: string) => new URL(file, assetBaseUrl).href;\n\n for (const expose of manifest.exposes) {\n const request = expose.path || `./${expose.name}`;\n if (!requests.has(request)) continue;\n\n const hasSyncAssets =\n expose.assets.js.sync.length > 0 || expose.assets.css.sync.length > 0;\n if (hasSyncAssets) missingRequests.delete(request);\n\n for (const file of expose.assets.js.sync) {\n chunks.add(resolveAssetUrl(file));\n }\n for (const file of expose.assets.css.sync) {\n chunks.add(resolveAssetUrl(file));\n }\n }\n\n return { chunks: Array.from(chunks), missingRequests };\n};\n\nconst collectLegacyAssets = (\n stats: LegacyFederatedStats,\n statsUrl: string,\n requests: Set<string>,\n): string[] => {\n const chunks = new Set<string>();\n const assetBaseUrl = getAssetBaseUrl(statsUrl);\n\n for (const federatedModule of stats.federatedModules || []) {\n for (const request of requests) {\n for (const file of federatedModule.exposes?.[request] || []) {\n chunks.add(new URL(file, assetBaseUrl).href);\n }\n }\n }\n\n return Array.from(chunks);\n};\n\nconst processRemote = async (\n remoteInfo: RemoteInfo,\n requests: Set<string>,\n configuredManifestUrl?: string,\n): Promise<string[]> => {\n const manifestUrl = getManifestUrl(remoteInfo, configuredManifestUrl);\n let manifestChunks: string[] = [];\n let legacyRequests = requests;\n\n try {\n const manifest = await fetchJson<Manifest>(manifestUrl);\n const { chunks, missingRequests } = collectManifestAssets(\n manifest,\n manifestUrl,\n requests,\n );\n manifestChunks = chunks;\n if (!missingRequests.size) return chunks;\n legacyRequests = missingRequests;\n } catch {\n // Older remotes may only expose federated-stats.json.\n }\n\n const statsUrl = getMetadataUrl(remoteInfo.entry, 'federated-stats.json');\n try {\n const stats = await fetchJson<LegacyFederatedStats>(statsUrl);\n return Array.from(\n new Set([\n ...manifestChunks,\n ...collectLegacyAssets(stats, statsUrl, legacyRequests),\n ]),\n );\n } catch (error) {\n if (!manifestChunks.length) console.error('flush error:', error);\n return manifestChunks;\n }\n};\n\n/**\n * Flush the chunks and return a deduplicated array of chunks.\n * @returns {Promise<Array>} A promise that resolves to an array of deduplicated chunks.\n */\nexport const flushChunks = async (): Promise<string[]> => {\n const knownRemotes = getAllKnownRemotes();\n const configuredManifestUrls = getConfiguredManifestUrls();\n const remoteNames = Object.keys(knownRemotes).sort(\n (left, right) => right.length - left.length,\n );\n const requestsByRemote = new Map<string, RemoteRequests>();\n\n for (const chunk of usedChunks) {\n const [remote, request] = parseUsedChunk(chunk, remoteNames);\n const remoteInfo = knownRemotes[remote];\n if (!remoteInfo) {\n console.error(\n `flush chunks: Remote ${remote} is not defined in the global config`,\n );\n continue;\n }\n\n const remoteRequests = requestsByRemote.get(remoteInfo.name) || {\n remoteInfo,\n manifestUrl:\n configuredManifestUrls.get(remote) ||\n configuredManifestUrls.get(remoteInfo.name),\n requests: new Set<string>(),\n };\n remoteRequests.requests.add(request);\n requestsByRemote.set(remoteInfo.name, remoteRequests);\n }\n usedChunks.clear();\n\n const allFlushed = await Promise.all(\n Array.from(\n requestsByRemote.values(),\n ({ remoteInfo, requests, manifestUrl }) =>\n processRemote(remoteInfo, requests, manifestUrl),\n ),\n );\n\n return Array.from(new Set(allFlushed.flat()));\n};\n"],"mappings":";;;;;AAkBA,IAAI,CAAC,WAAW,WAEd,YAAW,6BAAa,IAAI,KAAK;;;;;AAOnC,MAAa,EAAE,eAAe;AAC9B,MAAM,gCACJ,IAAI,SAAS,oBAAoB,EAAE,CAAC;AAEtC,MAAa,qBAAqB,WAAwC;CACxE,MAAM,uBAAuB,yBAAyB;AACtD,KAAI,CAAC,wBAAwB,CAAC,qBAAqB,cACjD,QAAO,EAAE;CAGX,MAAM,YAAwC,EAAE;AAChD,MAAK,MAAM,YAAY,qBAAqB,cAC1C,MAAK,MAAM,GAAG,gBAAgB,SAAS,YACrC,KAAI,YAAY,YAAY;EAC1B,MAAM,aAAa,YAAY;AAC/B,YAAU,WAAW,QAAQ;AAC7B,MAAI,WAAW,MAAO,WAAU,WAAW,SAAS;;AAI1D,QAAO;;AAGT,MAAM,kCAAuD;CAC3D,MAAM,+BAAe,IAAI,KAAqB;CAC9C,MAAM,uBAAuB,yBAAyB;AAEtD,MAAK,MAAM,YAAY,sBAAsB,iBAAiB,EAAE,CAC9D,MAAK,MAAM,oBAAoB,SAAS,SAAS,WAAW,EAAE,EAAE;AAC9D,MAAI,EAAE,WAAW,kBAAmB;AACpC,MAAI;AACF,OAAI,CAAC,IAAI,IAAI,iBAAiB,MAAM,CAAC,SAAS,SAA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AAM,KACJ,iBAAiB,QAAQ,GACxB,EAAE,YAAY,UAAU,kBACvB,cAAc,YAAY,UAAU,YAAY,CACnD,CACF;AAED,QAAO,MAAM,KAAK,IAAI,IAAI,WAAW,MAAM,CAAC,CAAC"}
@@ -1,3 +1,5 @@
1
+ import { getResourceUrl } from "@module-federation/sdk";
2
+
1
3
  //#region src/utils/flush-chunks.ts
2
4
  if (!globalThis.usedChunks) globalThis.usedChunks = /* @__PURE__ */ new Set();
3
5
  /**
@@ -5,83 +7,107 @@ if (!globalThis.usedChunks) globalThis.usedChunks = /* @__PURE__ */ new Set();
5
7
  * @type {Set}
6
8
  */
7
9
  const { usedChunks } = globalThis;
8
- /**
9
- * Load hostStats from the JSON file.
10
- * @returns {object} hostStats - An object containing host stats data.
11
- */
12
- const loadHostStats = () => {
13
- try {
14
- return __non_webpack_require__("../federated-stats.json");
15
- } catch (e) {
16
- return {};
17
- }
18
- };
10
+ const getFederationController = () => new Function("return globalThis")().__FEDERATION__;
19
11
  const getAllKnownRemotes = function() {
20
- const federationController = new Function("return globalThis")().__FEDERATION__;
12
+ const federationController = getFederationController();
21
13
  if (!federationController || !federationController.__INSTANCES__) return {};
22
- var collected = {};
23
- for (const instance of federationController.__INSTANCES__) for (const [key, cacheModule] of instance.moduleCache) if (cacheModule.remoteInfo) collected[cacheModule.remoteInfo.name] = cacheModule.remoteInfo;
14
+ const collected = {};
15
+ for (const instance of federationController.__INSTANCES__) for (const [, cacheModule] of instance.moduleCache) if (cacheModule.remoteInfo) {
16
+ const remoteInfo = cacheModule.remoteInfo;
17
+ collected[remoteInfo.name] = remoteInfo;
18
+ if (remoteInfo.alias) collected[remoteInfo.alias] = remoteInfo;
19
+ }
24
20
  return collected;
25
21
  };
26
- /**
27
- * Create a shareMap based on the loaded modules.
28
- * @returns {object} shareMap - An object containing the shareMap data.
29
- */
30
- const createShareMap = () => {
31
- if (__webpack_share_scopes__?.default) return Object.keys(__webpack_share_scopes__.default).reduce((acc, key) => {
32
- const shareMap = __webpack_share_scopes__.default[key];
33
- if (!shareMap || typeof shareMap !== "object") return acc;
34
- const loadedModules = Object.values(shareMap).filter((sharedModule) => sharedModule.loaded).map((sharedModule) => sharedModule.from);
35
- if (loadedModules.length > 0) acc[key] = loadedModules;
36
- return acc;
37
- }, {});
38
- return {};
22
+ const getConfiguredManifestUrls = () => {
23
+ const manifestUrls = /* @__PURE__ */ new Map();
24
+ const federationController = getFederationController();
25
+ for (const instance of federationController?.__INSTANCES__ || []) for (const configuredRemote of instance.options?.remotes || []) {
26
+ if (!("entry" in configuredRemote)) continue;
27
+ try {
28
+ if (!new URL(configuredRemote.entry).pathname.endsWith(".json")) continue;
29
+ } catch {
30
+ continue;
31
+ }
32
+ manifestUrls.set(configuredRemote.name, configuredRemote.entry);
33
+ if (configuredRemote.alias) manifestUrls.set(configuredRemote.alias, configuredRemote.entry);
34
+ }
35
+ return manifestUrls;
39
36
  };
40
- /**
41
- * Process a single chunk and return an array of updated chunks.
42
- * @param {string} chunk - A chunk string containing remote and request data.
43
- * @param {object} shareMap - An object containing the shareMap data.
44
- * @param {object} hostStats - An object containing host stats data.
45
- * @returns {Promise<Array>} A promise that resolves to an array of updated chunks.
46
- */
47
- const processChunk = async (chunk, shareMap, hostStats) => {
37
+ const parseUsedChunk = (chunk, remoteNames) => {
38
+ const normalizedChunk = chunk.replace("->", "/");
39
+ const remote = remoteNames.find((name) => normalizedChunk === name || normalizedChunk.startsWith(`${name}/`)) || normalizedChunk.split("/", 1)[0];
40
+ const request = normalizedChunk.slice(remote.length).replace(/^\//, "");
41
+ return [remote, request.startsWith("./") ? request : `./${request}`];
42
+ };
43
+ const getMetadataUrl = (entry, filename) => {
44
+ const url = new URL(entry);
45
+ url.pathname = `${url.pathname.slice(0, url.pathname.lastIndexOf("/") + 1)}${filename}`;
46
+ url.pathname = url.pathname.replace("/ssr/", "/chunks/");
47
+ return url.href;
48
+ };
49
+ const getManifestUrl = (remoteInfo, configuredManifestUrl) => {
50
+ if (configuredManifestUrl) return configuredManifestUrl;
51
+ return getMetadataUrl(remoteInfo.entry, "mf-manifest.json");
52
+ };
53
+ const getAssetBaseUrl = (metadataUrl) => {
54
+ const baseUrl = new URL(metadataUrl);
55
+ const staticPathIndex = baseUrl.pathname.indexOf("/static/");
56
+ baseUrl.pathname = staticPathIndex === -1 ? baseUrl.pathname.slice(0, baseUrl.pathname.lastIndexOf("/") + 1) : baseUrl.pathname.slice(0, staticPathIndex + 1);
57
+ baseUrl.search = "";
58
+ baseUrl.hash = "";
59
+ return baseUrl;
60
+ };
61
+ const fetchJson = async (url) => {
62
+ const response = await fetch(url);
63
+ if (!response.ok) throw new Error(`Request failed with status ${response.status}`);
64
+ return response.json();
65
+ };
66
+ const collectManifestAssets = (manifest, manifestUrl, requests) => {
48
67
  const chunks = /* @__PURE__ */ new Set();
49
- const normalizedChunk = chunk.includes("->") ? chunk.replace("->", "/") : chunk;
50
- const remoteSeparatorIndex = normalizedChunk.indexOf("/");
51
- const remote = remoteSeparatorIndex === -1 ? normalizedChunk : normalizedChunk.slice(0, remoteSeparatorIndex);
52
- const req = remoteSeparatorIndex === -1 ? "" : normalizedChunk.slice(remoteSeparatorIndex + 1);
53
- const request = req?.startsWith("./") ? req : "./" + req;
54
- const knownRemotes = getAllKnownRemotes();
55
- if (!knownRemotes[remote]) {
56
- console.error(`flush chunks: Remote ${remote} is not defined in the global config`);
57
- return;
68
+ const missingRequests = new Set(requests);
69
+ let assetBaseUrl = getAssetBaseUrl(manifestUrl);
70
+ const resourceBasePath = getResourceUrl(manifest.metaData, "");
71
+ if (resourceBasePath !== "auto") {
72
+ const normalizedBasePath = resourceBasePath && !resourceBasePath.endsWith("/") ? `${resourceBasePath}/` : resourceBasePath || "./";
73
+ assetBaseUrl = new URL(normalizedBasePath, manifestUrl);
74
+ }
75
+ const resolveAssetUrl = (file) => new URL(file, assetBaseUrl).href;
76
+ for (const expose of manifest.exposes) {
77
+ const request = expose.path || `./${expose.name}`;
78
+ if (!requests.has(request)) continue;
79
+ if (expose.assets.js.sync.length > 0 || expose.assets.css.sync.length > 0) missingRequests.delete(request);
80
+ for (const file of expose.assets.js.sync) chunks.add(resolveAssetUrl(file));
81
+ for (const file of expose.assets.css.sync) chunks.add(resolveAssetUrl(file));
58
82
  }
83
+ return {
84
+ chunks: Array.from(chunks),
85
+ missingRequests
86
+ };
87
+ };
88
+ const collectLegacyAssets = (stats, statsUrl, requests) => {
89
+ const chunks = /* @__PURE__ */ new Set();
90
+ const assetBaseUrl = getAssetBaseUrl(statsUrl);
91
+ for (const federatedModule of stats.federatedModules || []) for (const request of requests) for (const file of federatedModule.exposes?.[request] || []) chunks.add(new URL(file, assetBaseUrl).href);
92
+ return Array.from(chunks);
93
+ };
94
+ const processRemote = async (remoteInfo, requests, configuredManifestUrl) => {
95
+ const manifestUrl = getManifestUrl(remoteInfo, configuredManifestUrl);
96
+ let manifestChunks = [];
97
+ let legacyRequests = requests;
59
98
  try {
60
- const remoteName = new URL(knownRemotes[remote].entry).pathname.split("/").pop();
61
- const statsFile = knownRemotes[remote].entry.replace(remoteName, "federated-stats.json").replace("ssr", "chunks");
62
- let stats = {};
63
- try {
64
- stats = await fetch(statsFile).then((res) => res.json());
65
- } catch (e) {
66
- console.error("flush error", e);
67
- }
68
- const [prefix] = knownRemotes[remote].entry.split("static/");
69
- if (stats.federatedModules) stats.federatedModules.forEach((modules) => {
70
- if (modules.exposes?.[request]) modules.exposes[request].forEach((chunk) => {
71
- chunks.add([prefix, chunk].join(""));
72
- Object.values(chunk).forEach((chunk) => {
73
- if (chunk.files) chunk.files.forEach((file) => {
74
- chunks.add(prefix + file);
75
- });
76
- if (chunk.requiredModules) chunk.requiredModules.forEach((module) => {
77
- if (shareMap[module]) {}
78
- });
79
- });
80
- });
81
- });
82
- return Array.from(chunks);
83
- } catch (e) {
84
- console.error("flush error:", e);
99
+ const { chunks, missingRequests } = collectManifestAssets(await fetchJson(manifestUrl), manifestUrl, requests);
100
+ manifestChunks = chunks;
101
+ if (!missingRequests.size) return chunks;
102
+ legacyRequests = missingRequests;
103
+ } catch {}
104
+ const statsUrl = getMetadataUrl(remoteInfo.entry, "federated-stats.json");
105
+ try {
106
+ const stats = await fetchJson(statsUrl);
107
+ return Array.from(new Set([...manifestChunks, ...collectLegacyAssets(stats, statsUrl, legacyRequests)]));
108
+ } catch (error) {
109
+ if (!manifestChunks.length) console.error("flush error:", error);
110
+ return manifestChunks;
85
111
  }
86
112
  };
87
113
  /**
@@ -89,12 +115,28 @@ const processChunk = async (chunk, shareMap, hostStats) => {
89
115
  * @returns {Promise<Array>} A promise that resolves to an array of deduplicated chunks.
90
116
  */
91
117
  const flushChunks = async () => {
92
- const hostStats = loadHostStats();
93
- const shareMap = createShareMap();
94
- const allFlushed = await Promise.all(Array.from(usedChunks).map(async (chunk) => processChunk(chunk, shareMap, hostStats)));
95
- const dedupe = Array.from(new Set([...allFlushed.flat()]));
118
+ const knownRemotes = getAllKnownRemotes();
119
+ const configuredManifestUrls = getConfiguredManifestUrls();
120
+ const remoteNames = Object.keys(knownRemotes).sort((left, right) => right.length - left.length);
121
+ const requestsByRemote = /* @__PURE__ */ new Map();
122
+ for (const chunk of usedChunks) {
123
+ const [remote, request] = parseUsedChunk(chunk, remoteNames);
124
+ const remoteInfo = knownRemotes[remote];
125
+ if (!remoteInfo) {
126
+ console.error(`flush chunks: Remote ${remote} is not defined in the global config`);
127
+ continue;
128
+ }
129
+ const remoteRequests = requestsByRemote.get(remoteInfo.name) || {
130
+ remoteInfo,
131
+ manifestUrl: configuredManifestUrls.get(remote) || configuredManifestUrls.get(remoteInfo.name),
132
+ requests: /* @__PURE__ */ new Set()
133
+ };
134
+ remoteRequests.requests.add(request);
135
+ requestsByRemote.set(remoteInfo.name, remoteRequests);
136
+ }
96
137
  usedChunks.clear();
97
- return dedupe.filter(Boolean);
138
+ const allFlushed = await Promise.all(Array.from(requestsByRemote.values(), ({ remoteInfo, requests, manifestUrl }) => processRemote(remoteInfo, requests, manifestUrl)));
139
+ return Array.from(new Set(allFlushed.flat()));
98
140
  };
99
141
 
100
142
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"flush-chunks.mjs","names":[],"sources":["../../../src/utils/flush-chunks.ts"],"sourcesContent":["/* eslint-disable no-undef */\n\n// @ts-ignore\nif (!globalThis.usedChunks) {\n // @ts-ignore\n globalThis.usedChunks = new Set();\n}\n/**\n * Initialize usedChunks and share it globally.\n * @type {Set}\n */\n// @ts-ignore\nexport const { usedChunks } = globalThis;\n/**\n * Load hostStats from the JSON file.\n * @returns {object} hostStats - An object containing host stats data.\n */\nconst loadHostStats = () => {\n try {\n //@ts-ignore\n return __non_webpack_require__('../federated-stats.json');\n } catch (e) {\n return {};\n }\n};\n\nexport const getAllKnownRemotes = function () {\n // Attempt to access the global federation controller safely\n const federationController = new Function('return globalThis')()\n .__FEDERATION__;\n if (!federationController || !federationController.__INSTANCES__) {\n // If the federation controller or instances are not defined, return an empty object\n return {};\n }\n\n var collected = {};\n // Use a for...of loop to iterate over all federation instances\n for (const instance of federationController.__INSTANCES__) {\n // Use another for...of loop to iterate over the module cache Map entries\n for (const [key, cacheModule] of instance.moduleCache) {\n // Check if the cacheModule has remoteInfo and use it to collect remote names\n if (cacheModule.remoteInfo) {\n //@ts-ignore\n collected[cacheModule.remoteInfo.name] = cacheModule.remoteInfo;\n }\n }\n }\n return collected;\n};\n\n/**\n * Create a shareMap based on the loaded modules.\n * @returns {object} shareMap - An object containing the shareMap data.\n */\nconst createShareMap = () => {\n // Check if __webpack_share_scopes__ is defined and has a default property\n // @ts-ignore\n if (__webpack_share_scopes__?.default) {\n // Reduce the keys of the default property to create the share map\n // @ts-ignore\n return Object.keys(__webpack_share_scopes__.default).reduce((acc, key) => {\n // @ts-ignore\n const shareMap = __webpack_share_scopes__.default[key];\n // shareScope may equal undefined or null if it has unexpected value\n if (!shareMap || typeof shareMap !== 'object') {\n return acc;\n }\n // Get the loaded modules for the current key\n const loadedModules = Object.values(shareMap)\n // Filter out the modules that are not loaded\n // @ts-ignore\n .filter((sharedModule) => sharedModule.loaded)\n // Map the filtered modules to their 'from' properties\n // @ts-ignore\n .map((sharedModule) => sharedModule.from);\n\n // If there are any loaded modules, add them to the accumulator object\n if (loadedModules.length > 0) {\n // @ts-ignore\n acc[key] = loadedModules;\n }\n // Return the accumulator object for the next iteration\n return acc;\n }, {});\n }\n // If __webpack_share_scopes__ is not defined or doesn't have a default property, return an empty object\n return {};\n};\n\n/**\n * Process a single chunk and return an array of updated chunks.\n * @param {string} chunk - A chunk string containing remote and request data.\n * @param {object} shareMap - An object containing the shareMap data.\n * @param {object} hostStats - An object containing host stats data.\n * @returns {Promise<Array>} A promise that resolves to an array of updated chunks.\n */\n// @ts-ignore\nconst processChunk = async (chunk, shareMap, hostStats) => {\n const chunks = new Set();\n const normalizedChunk = chunk.includes('->')\n ? chunk.replace('->', '/')\n : chunk;\n const remoteSeparatorIndex = normalizedChunk.indexOf('/');\n const remote =\n remoteSeparatorIndex === -1\n ? normalizedChunk\n : normalizedChunk.slice(0, remoteSeparatorIndex);\n const req =\n remoteSeparatorIndex === -1\n ? ''\n : normalizedChunk.slice(remoteSeparatorIndex + 1);\n const request = req?.startsWith('./') ? req : './' + req;\n const knownRemotes = getAllKnownRemotes();\n //@ts-ignore\n if (!knownRemotes[remote]) {\n console.error(\n `flush chunks: Remote ${remote} is not defined in the global config`,\n );\n return;\n }\n\n try {\n //@ts-ignore\n const remoteName = new URL(knownRemotes[remote].entry).pathname\n .split('/')\n .pop();\n //@ts-ignore\n\n const statsFile = knownRemotes[remote].entry\n .replace(remoteName, 'federated-stats.json')\n .replace('ssr', 'chunks');\n let stats = {};\n\n try {\n stats = await fetch(statsFile).then((res) => res.json());\n } catch (e) {\n console.error('flush error', e);\n }\n //@ts-ignore\n\n const [prefix] = knownRemotes[remote].entry.split('static/');\n //@ts-ignore\n\n if (stats.federatedModules) {\n //@ts-ignore\n\n stats.federatedModules.forEach((modules) => {\n if (modules.exposes?.[request]) {\n //@ts-ignore\n\n modules.exposes[request].forEach((chunk) => {\n chunks.add([prefix, chunk].join(''));\n\n Object.values(chunk).forEach((chunk) => {\n //@ts-ignore\n\n if (chunk.files) {\n //@ts-ignore\n\n chunk.files.forEach((file) => {\n chunks.add(prefix + file);\n });\n }\n //@ts-ignore\n\n if (chunk.requiredModules) {\n //@ts-ignore\n\n chunk.requiredModules.forEach((module) => {\n if (shareMap[module]) {\n // If the module is from the host, log the host stats\n }\n });\n }\n });\n });\n }\n });\n }\n\n return Array.from(chunks);\n } catch (e) {\n console.error('flush error:', e);\n }\n};\n\n/**\n * Flush the chunks and return a deduplicated array of chunks.\n * @returns {Promise<Array>} A promise that resolves to an array of deduplicated chunks.\n */\nexport const flushChunks = async () => {\n const hostStats = loadHostStats();\n const shareMap = createShareMap();\n\n const allFlushed = await Promise.all(\n Array.from(usedChunks).map(async (chunk) =>\n processChunk(chunk, shareMap, hostStats),\n ),\n );\n\n // Deduplicate the chunks array\n const dedupe = Array.from(new Set([...allFlushed.flat()]));\n\n // Clear usedChunks\n usedChunks.clear();\n // Filter out any undefined or null values\n return dedupe.filter(Boolean);\n};\n"],"mappings":";AAGA,IAAI,CAAC,WAAW,WAEd,YAAW,6BAAa,IAAI,KAAK;;;;;AAOnC,MAAa,EAAE,eAAe;;;;;AAK9B,MAAM,sBAAsB;AAC1B,KAAI;AAEF,SAAO,wBAAwB,0BAA0B;UAClD,GAAG;AACV,SAAO,EAAE;;;AAIb,MAAa,qBAAqB,WAAY;CAE5C,MAAM,uBAAuB,IAAI,SAAS,oBAAoB,EAAE,CAC7D;AACH,KAAI,CAAC,wBAAwB,CAAC,qBAAqB,cAEjD,QAAO,EAAE;CAGX,IAAI,YAAY,EAAE;AAElB,MAAK,MAAM,YAAY,qBAAqB,cAE1C,MAAK,MAAM,CAAC,KAAK,gBAAgB,SAAS,YAExC,KAAI,YAAY,WAEd,WAAU,YAAY,WAAW,QAAQ,YAAY;AAI3D,QAAO;;;;;;AAOT,MAAM,uBAAuB;AAG3B,KAAI,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AU;AAG5D,MAAI,MAAM,iBAGR,OAAM,iBAAiB,SAAS,YAAY;AAC1C,OAAI,QAAQ,UAAU,SAGpB,SAAQ,QAAQ,SAAS,SAAS,UAAU;AAC1C,WAAO,IAAI,CAAC,QAAQ,MAAM,CAAC,KAAK,GAAG,CAAC;AAEpC,WAAO,OAAO,MAAM,CAAC,SAAS,UAAU;AAGtC,SAAI,MAAM,MAGR,OAAM,MAAM,SAAS,SAAS;AAC5B,aAAO,IAAI,SAAS,KAAK;OACzB;AAIJ,SAAI,MAAM,gBAGR,OAAM,gBAAgB,SAAS,WAAW;AACxC,UAAI,SAAS,SAAS;OAGtB;MAEJ;KACF;IAEJ;AAGJ,SAAO,MAAM,KAAK,OAAO;UAClB,GAAG;AACV,UAAQ,MAAM,gBAAgB,EAAE;;;;;;;AAQpC,MAAa,cAAc,YAAY;CACrC,MAAM,YAAY,eAAe;CACjC,MAAM,WAAW,gBAAgB;CAEjC,MAAM,aAAa,MAAM,QAAQ,IAC/B,MAAM,KAAK,WAAW,CAAC,IAAI,OAAO,UAChC,aAAa,OAAO,UAAU,UAAU,CACzC,CACF;CAGD,MAAM,SAAS,MAAM,KAAK,IAAI,IAAI,CAAC,GAAG,WAAW,MAAM,CAAC,CAAC,CAAC;AAG1D,YAAW,OAAO;AAElB,QAAO,OAAO,OAAO,QAAQ"}
1
+ {"version":3,"file":"flush-chunks.mjs","names":[],"sources":["../../../src/utils/flush-chunks.ts"],"sourcesContent":["/* eslint-disable no-undef */\n\nimport { getResourceUrl, type Manifest } from '@module-federation/sdk';\nimport type { RemoteInfo } from '@module-federation/runtime/types';\n\ntype LegacyFederatedStats = {\n federatedModules?: Array<{\n exposes?: Record<string, string[]>;\n }>;\n};\n\ntype RemoteRequests = {\n remoteInfo: RemoteInfo;\n manifestUrl?: string;\n requests: Set<string>;\n};\n\n// @ts-ignore\nif (!globalThis.usedChunks) {\n // @ts-ignore\n globalThis.usedChunks = new Set();\n}\n/**\n * Initialize usedChunks and share it globally.\n * @type {Set}\n */\n// @ts-ignore\nexport const { usedChunks } = globalThis;\nconst getFederationController = () =>\n new Function('return globalThis')().__FEDERATION__;\n\nexport const getAllKnownRemotes = function (): Record<string, RemoteInfo> {\n const federationController = getFederationController();\n if (!federationController || !federationController.__INSTANCES__) {\n return {};\n }\n\n const collected: Record<string, RemoteInfo> = {};\n for (const instance of federationController.__INSTANCES__) {\n for (const [, cacheModule] of instance.moduleCache) {\n if (cacheModule.remoteInfo) {\n const remoteInfo = cacheModule.remoteInfo as RemoteInfo;\n collected[remoteInfo.name] = remoteInfo;\n if (remoteInfo.alias) collected[remoteInfo.alias] = remoteInfo;\n }\n }\n }\n return collected;\n};\n\nconst getConfiguredManifestUrls = (): Map<string, string> => {\n const manifestUrls = new Map<string, string>();\n const federationController = getFederationController();\n\n for (const instance of federationController?.__INSTANCES__ || []) {\n for (const configuredRemote of instance.options?.remotes || []) {\n if (!('entry' in configuredRemote)) continue;\n try {\n if (!new URL(configuredRemote.entry).pathname.endsWith('.json')) {\n continue;\n }\n } catch {\n continue;\n }\n manifestUrls.set(configuredRemote.name, configuredRemote.entry);\n if (configuredRemote.alias) {\n manifestUrls.set(configuredRemote.alias, configuredRemote.entry);\n }\n }\n }\n\n return manifestUrls;\n};\n\nconst parseUsedChunk = (\n chunk: string,\n remoteNames: string[],\n): [remote: string, request: string] => {\n const normalizedChunk = chunk.replace('->', '/');\n const remote =\n remoteNames.find(\n (name) =>\n normalizedChunk === name || normalizedChunk.startsWith(`${name}/`),\n ) || normalizedChunk.split('/', 1)[0];\n const request = normalizedChunk.slice(remote.length).replace(/^\\//, '');\n return [remote, request.startsWith('./') ? request : `./${request}`];\n};\n\nconst getMetadataUrl = (entry: string, filename: string): string => {\n const url = new URL(entry);\n url.pathname = `${url.pathname.slice(0, url.pathname.lastIndexOf('/') + 1)}${filename}`;\n url.pathname = url.pathname.replace('/ssr/', '/chunks/');\n return url.href;\n};\n\nconst getManifestUrl = (\n remoteInfo: RemoteInfo,\n configuredManifestUrl?: string,\n): string => {\n if (configuredManifestUrl) return configuredManifestUrl;\n return getMetadataUrl(remoteInfo.entry, 'mf-manifest.json');\n};\n\nconst getAssetBaseUrl = (metadataUrl: string): URL => {\n const baseUrl = new URL(metadataUrl);\n const staticPathIndex = baseUrl.pathname.indexOf('/static/');\n baseUrl.pathname =\n staticPathIndex === -1\n ? baseUrl.pathname.slice(0, baseUrl.pathname.lastIndexOf('/') + 1)\n : baseUrl.pathname.slice(0, staticPathIndex + 1);\n baseUrl.search = '';\n baseUrl.hash = '';\n return baseUrl;\n};\n\nconst fetchJson = async <T>(url: string): Promise<T> => {\n const response = await fetch(url);\n if (!response.ok) {\n throw new Error(`Request failed with status ${response.status}`);\n }\n return response.json() as Promise<T>;\n};\n\nconst collectManifestAssets = (\n manifest: Manifest,\n manifestUrl: string,\n requests: Set<string>,\n): { chunks: string[]; missingRequests: Set<string> } => {\n const chunks = new Set<string>();\n const missingRequests = new Set(requests);\n let assetBaseUrl = getAssetBaseUrl(manifestUrl);\n const resourceBasePath = getResourceUrl(manifest.metaData, '');\n\n if (resourceBasePath !== 'auto') {\n const normalizedBasePath =\n resourceBasePath && !resourceBasePath.endsWith('/')\n ? `${resourceBasePath}/`\n : resourceBasePath || './';\n assetBaseUrl = new URL(normalizedBasePath, manifestUrl);\n }\n\n const resolveAssetUrl = (file: string) => new URL(file, assetBaseUrl).href;\n\n for (const expose of manifest.exposes) {\n const request = expose.path || `./${expose.name}`;\n if (!requests.has(request)) continue;\n\n const hasSyncAssets =\n expose.assets.js.sync.length > 0 || expose.assets.css.sync.length > 0;\n if (hasSyncAssets) missingRequests.delete(request);\n\n for (const file of expose.assets.js.sync) {\n chunks.add(resolveAssetUrl(file));\n }\n for (const file of expose.assets.css.sync) {\n chunks.add(resolveAssetUrl(file));\n }\n }\n\n return { chunks: Array.from(chunks), missingRequests };\n};\n\nconst collectLegacyAssets = (\n stats: LegacyFederatedStats,\n statsUrl: string,\n requests: Set<string>,\n): string[] => {\n const chunks = new Set<string>();\n const assetBaseUrl = getAssetBaseUrl(statsUrl);\n\n for (const federatedModule of stats.federatedModules || []) {\n for (const request of requests) {\n for (const file of federatedModule.exposes?.[request] || []) {\n chunks.add(new URL(file, assetBaseUrl).href);\n }\n }\n }\n\n return Array.from(chunks);\n};\n\nconst processRemote = async (\n remoteInfo: RemoteInfo,\n requests: Set<string>,\n configuredManifestUrl?: string,\n): Promise<string[]> => {\n const manifestUrl = getManifestUrl(remoteInfo, configuredManifestUrl);\n let manifestChunks: string[] = [];\n let legacyRequests = requests;\n\n try {\n const manifest = await fetchJson<Manifest>(manifestUrl);\n const { chunks, missingRequests } = collectManifestAssets(\n manifest,\n manifestUrl,\n requests,\n );\n manifestChunks = chunks;\n if (!missingRequests.size) return chunks;\n legacyRequests = missingRequests;\n } catch {\n // Older remotes may only expose federated-stats.json.\n }\n\n const statsUrl = getMetadataUrl(remoteInfo.entry, 'federated-stats.json');\n try {\n const stats = await fetchJson<LegacyFederatedStats>(statsUrl);\n return Array.from(\n new Set([\n ...manifestChunks,\n ...collectLegacyAssets(stats, statsUrl, legacyRequests),\n ]),\n );\n } catch (error) {\n if (!manifestChunks.length) console.error('flush error:', error);\n return manifestChunks;\n }\n};\n\n/**\n * Flush the chunks and return a deduplicated array of chunks.\n * @returns {Promise<Array>} A promise that resolves to an array of deduplicated chunks.\n */\nexport const flushChunks = async (): Promise<string[]> => {\n const knownRemotes = getAllKnownRemotes();\n const configuredManifestUrls = getConfiguredManifestUrls();\n const remoteNames = Object.keys(knownRemotes).sort(\n (left, right) => right.length - left.length,\n );\n const requestsByRemote = new Map<string, RemoteRequests>();\n\n for (const chunk of usedChunks) {\n const [remote, request] = parseUsedChunk(chunk, remoteNames);\n const remoteInfo = knownRemotes[remote];\n if (!remoteInfo) {\n console.error(\n `flush chunks: Remote ${remote} is not defined in the global config`,\n );\n continue;\n }\n\n const remoteRequests = requestsByRemote.get(remoteInfo.name) || {\n remoteInfo,\n manifestUrl:\n configuredManifestUrls.get(remote) ||\n configuredManifestUrls.get(remoteInfo.name),\n requests: new Set<string>(),\n };\n remoteRequests.requests.add(request);\n requestsByRemote.set(remoteInfo.name, remoteRequests);\n }\n usedChunks.clear();\n\n const allFlushed = await Promise.all(\n Array.from(\n requestsByRemote.values(),\n ({ remoteInfo, requests, manifestUrl }) =>\n processRemote(remoteInfo, requests, manifestUrl),\n ),\n );\n\n return Array.from(new Set(allFlushed.flat()));\n};\n"],"mappings":";;;AAkBA,IAAI,CAAC,WAAW,WAEd,YAAW,6BAAa,IAAI,KAAK;;;;;AAOnC,MAAa,EAAE,eAAe;AAC9B,MAAM,gCACJ,IAAI,SAAS,oBAAoB,EAAE,CAAC;AAEtC,MAAa,qBAAqB,WAAwC;CACxE,MAAM,uBAAuB,yBAAyB;AACtD,KAAI,CAAC,wBAAwB,CAAC,qBAAqB,cACjD,QAAO,EAAE;CAGX,MAAM,YAAwC,EAAE;AAChD,MAAK,MAAM,YAAY,qBAAqB,cAC1C,MAAK,MAAM,GAAG,gBAAgB,SAAS,YACrC,KAAI,YAAY,YAAY;EAC1B,MAAM,aAAa,YAAY;AAC/B,YAAU,WAAW,QAAQ;AAC7B,MAAI,WAAW,MAAO,WAAU,WAAW,SAAS;;AAI1D,QAAO;;AAGT,MAAM,kCAAuD;CAC3D,MAAM,+BAAe,IAAI,KAAqB;CAC9C,MAAM,uBAAuB,yBAAyB;AAEtD,MAAK,MAAM,YAAY,sBAAsB,iBAAiB,EAAE,CAC9D,MAAK,MAAM,oBAAoB,SAAS,SAAS,WAAW,EAAE,EAAE;AAC9D,MAAI,EAAE,WAAW,kBAAmB;AACpC,MAAI;AACF,OAAI,CAAC,IAAI,IAAI,iBAAiB,MAAM,CAAC,SAAS,SAAS,QAAQ,CAC7D;UAEI;AACN;;AAEF,eAAa,IAAI,iBAAiB,MAAM,iBAAiB,MAAM;AAC/D,MAAI,iBAAiB,MACnB,cAAa,IAAI,iBAAiB,OAAO,iBAAiB,MAAM;;AAKtE,QAAO;;AAGT,MAAM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ED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "public": true,
3
3
  "name": "@module-federation/node",
4
- "version": "0.0.0-fix-4748-shared-fallback-versions-20260604072020",
4
+ "version": "0.0.0-fix-runtime-core-set-shared-lib-20260819111025",
5
5
  "type": "commonjs",
6
6
  "main": "./dist/src/index.js",
7
7
  "module": "./dist/src/index.mjs",
@@ -111,9 +111,9 @@
111
111
  "encoding": "0.1.13",
112
112
  "node-fetch": "2.7.0",
113
113
  "tapable": "2.3.0",
114
- "@module-federation/sdk": "0.0.0-fix-4748-shared-fallback-versions-20260604072020",
115
- "@module-federation/enhanced": "0.0.0-fix-4748-shared-fallback-versions-20260604072020",
116
- "@module-federation/runtime": "0.0.0-fix-4748-shared-fallback-versions-20260604072020"
114
+ "@module-federation/enhanced": "0.0.0-fix-runtime-core-set-shared-lib-20260819111025",
115
+ "@module-federation/runtime": "0.0.0-fix-runtime-core-set-shared-lib-20260819111025",
116
+ "@module-federation/sdk": "0.0.0-fix-runtime-core-set-shared-lib-20260819111025"
117
117
  },
118
118
  "peerDependencies": {
119
119
  "webpack": "^5.40.0"
@@ -123,6 +123,9 @@
123
123
  "optional": true
124
124
  }
125
125
  },
126
+ "devDependencies": {
127
+ "typescript": "7.0.2"
128
+ },
126
129
  "scripts": {
127
130
  "build": "tsdown --config tsdown.config.mts",
128
131
  "lint": "ESLINT_USE_FLAT_CONFIG=false pnpm exec eslint --ignore-pattern node_modules \"**/*.js\" \"**/*.ts\"",