@module-federation/node 2.7.33 → 2.7.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/plugins/CommonJsChunkLoadingPlugin.js.map +1 -1
- package/dist/src/plugins/CommonJsChunkLoadingPlugin.mjs.map +1 -1
- package/dist/src/plugins/DynamicFilesystemChunkLoadingRuntimeModule.d.mts +1 -1
- package/dist/src/plugins/DynamicFilesystemChunkLoadingRuntimeModule.d.ts +1 -1
- package/dist/src/plugins/NodeFederationPlugin.js +4 -1
- package/dist/src/plugins/NodeFederationPlugin.js.map +1 -1
- package/dist/src/plugins/NodeFederationPlugin.mjs +4 -1
- package/dist/src/plugins/NodeFederationPlugin.mjs.map +1 -1
- package/dist/src/plugins/StreamingTargetPlugin.js.map +1 -1
- package/dist/src/plugins/StreamingTargetPlugin.mjs.map +1 -1
- package/dist/src/plugins/UniversalFederationPlugin.js +5 -1
- package/dist/src/plugins/UniversalFederationPlugin.js.map +1 -1
- package/dist/src/plugins/UniversalFederationPlugin.mjs +5 -1
- package/dist/src/plugins/UniversalFederationPlugin.mjs.map +1 -1
- package/dist/src/utils/flush-chunks.js +5 -2
- package/dist/src/utils/flush-chunks.js.map +1 -1
- package/dist/src/utils/flush-chunks.mjs +5 -2
- package/dist/src/utils/flush-chunks.mjs.map +1 -1
- package/dist/src/utils/hot-reload.js +1 -0
- package/dist/src/utils/hot-reload.js.map +1 -1
- package/dist/src/utils/hot-reload.mjs +1 -0
- package/dist/src/utils/hot-reload.mjs.map +1 -1
- package/package.json +11 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommonJsChunkLoadingPlugin.js","names":["ChunkLoadingRuntimeModule","AutoPublicPathRuntimeModule"],"sources":["../../../src/plugins/CommonJsChunkLoadingPlugin.ts"],"sourcesContent":["import type { Chunk, Compiler, Compilation, ChunkGraph } from 'webpack';\nimport { normalizeWebpackPath } from '@module-federation/sdk/normalize-webpack-path';\nimport type { ModuleFederationPluginOptions } from '../types';\nconst StartupChunkDependenciesPlugin = require(\n normalizeWebpackPath('webpack/lib/runtime/StartupChunkDependenciesPlugin'),\n) as typeof import('webpack/lib/runtime/StartupChunkDependenciesPlugin');\nimport ChunkLoadingRuntimeModule from './DynamicFilesystemChunkLoadingRuntimeModule';\nimport AutoPublicPathRuntimeModule from './RemotePublicPathRuntimeModule';\n\ninterface DynamicFilesystemChunkLoadingOptions
|
|
1
|
+
{"version":3,"file":"CommonJsChunkLoadingPlugin.js","names":["ChunkLoadingRuntimeModule","AutoPublicPathRuntimeModule"],"sources":["../../../src/plugins/CommonJsChunkLoadingPlugin.ts"],"sourcesContent":["import type { Chunk, Compiler, Compilation, ChunkGraph } from 'webpack';\nimport { normalizeWebpackPath } from '@module-federation/sdk/normalize-webpack-path';\nimport type { ModuleFederationPluginOptions } from '../types';\nconst StartupChunkDependenciesPlugin = require(\n normalizeWebpackPath('webpack/lib/runtime/StartupChunkDependenciesPlugin'),\n) as typeof import('webpack/lib/runtime/StartupChunkDependenciesPlugin');\nimport ChunkLoadingRuntimeModule from './DynamicFilesystemChunkLoadingRuntimeModule';\nimport AutoPublicPathRuntimeModule from './RemotePublicPathRuntimeModule';\n\ninterface DynamicFilesystemChunkLoadingOptions extends ModuleFederationPluginOptions {\n baseURI: Compiler['options']['output']['publicPath'];\n promiseBaseURI?: string;\n remotes: Record<string, string>;\n name?: string;\n asyncChunkLoading: boolean;\n debug?: boolean;\n}\n\nclass DynamicFilesystemChunkLoadingPlugin {\n private options: DynamicFilesystemChunkLoadingOptions;\n private _asyncChunkLoading: boolean;\n\n constructor(options: DynamicFilesystemChunkLoadingOptions) {\n this.options = options || ({} as DynamicFilesystemChunkLoadingOptions);\n this._asyncChunkLoading = this.options.asyncChunkLoading;\n }\n\n apply(compiler: Compiler) {\n const { RuntimeGlobals } = compiler.webpack;\n const chunkLoadingValue = this._asyncChunkLoading\n ? 'async-node'\n : 'require';\n\n new StartupChunkDependenciesPlugin({\n chunkLoading: chunkLoadingValue,\n asyncChunkLoading: this._asyncChunkLoading,\n //@ts-ignore\n }).apply(compiler);\n\n compiler.hooks.thisCompilation.tap(\n 'DynamicFilesystemChunkLoadingPlugin',\n (compilation: Compilation) => {\n // Always enabled\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const isEnabledForChunk = (_: Chunk) => true;\n const onceForChunkSet = new WeakSet();\n\n const handler = (chunk: Chunk, set: Set<string>) => {\n if (onceForChunkSet.has(chunk)) {\n return;\n }\n\n onceForChunkSet.add(chunk);\n if (!isEnabledForChunk(chunk)) {\n return;\n }\n set.add(RuntimeGlobals.moduleFactoriesAddOnly);\n set.add(RuntimeGlobals.hasOwnProperty);\n\n set.add(RuntimeGlobals.publicPath); // this breaks things\n compilation.addRuntimeModule(\n chunk,\n new ChunkLoadingRuntimeModule(set, this.options, {\n webpack: compiler.webpack,\n }),\n );\n };\n compilation.hooks.runtimeRequirementInTree\n .for(RuntimeGlobals.ensureChunkHandlers)\n .tap('DynamicFilesystemChunkLoadingPlugin', handler);\n compilation.hooks.runtimeRequirementInTree\n .for(RuntimeGlobals.hmrDownloadUpdateHandlers)\n .tap('DynamicFilesystemChunkLoadingPlugin', handler);\n compilation.hooks.runtimeRequirementInTree\n .for(RuntimeGlobals.hmrDownloadManifest)\n .tap('DynamicFilesystemChunkLoadingPlugin', handler);\n compilation.hooks.runtimeRequirementInTree\n .for(RuntimeGlobals.baseURI)\n .tap('DynamicFilesystemChunkLoadingPlugin', handler);\n compilation.hooks.runtimeRequirementInTree\n .for(RuntimeGlobals.externalInstallChunk)\n .tap('DynamicFilesystemChunkLoadingPlugin', handler);\n compilation.hooks.runtimeRequirementInTree\n .for(RuntimeGlobals.onChunksLoaded)\n .tap('DynamicFilesystemChunkLoadingPlugin', handler);\n compilation.hooks.runtimeRequirementInTree\n .for(RuntimeGlobals.ensureChunkHandlers)\n .tap(\n 'DynamicFilesystemChunkLoadingPlugin',\n (chunk: Chunk, set: Set<string>) => {\n if (!isEnabledForChunk(chunk)) {\n return;\n }\n set.add(RuntimeGlobals.getChunkScriptFilename);\n },\n );\n compilation.hooks.runtimeRequirementInTree\n .for(RuntimeGlobals.hmrDownloadUpdateHandlers)\n .tap(\n 'DynamicFilesystemChunkLoadingPlugin',\n (chunk: Chunk, set: Set<string>) => {\n if (!isEnabledForChunk(chunk)) {\n return;\n }\n set.add(RuntimeGlobals.getChunkUpdateScriptFilename);\n set.add(RuntimeGlobals.moduleCache);\n set.add(RuntimeGlobals.hmrModuleData);\n set.add(RuntimeGlobals.moduleFactoriesAddOnly);\n },\n );\n compilation.hooks.runtimeRequirementInTree\n .for(RuntimeGlobals.hmrDownloadManifest)\n .tap(\n 'DynamicFilesystemChunkLoadingPlugin',\n (chunk: Chunk, set: Set<string>) => {\n if (!isEnabledForChunk(chunk)) {\n return;\n }\n set.add(RuntimeGlobals.getUpdateManifestFilename);\n },\n );\n\n compilation.hooks.runtimeRequirementInTree\n .for(RuntimeGlobals.publicPath)\n .tap('RuntimePlugin', (chunk, set) => {\n const { outputOptions } = compilation;\n const { publicPath: globalPublicPath, scriptType } = outputOptions;\n const entryOptions = chunk.getEntryOptions();\n const publicPath =\n entryOptions && entryOptions.publicPath !== undefined\n ? entryOptions.publicPath\n : globalPublicPath;\n\n const module = new AutoPublicPathRuntimeModule(this.options);\n if (publicPath === 'auto' && scriptType !== 'module') {\n set.add(RuntimeGlobals.global);\n } else if (\n typeof publicPath !== 'string' ||\n /\\[(full)?hash\\]/.test(publicPath)\n ) {\n module.fullHash = true;\n }\n\n compilation.addRuntimeModule(chunk, module);\n return true;\n });\n\n compilation.hooks.additionalTreeRuntimeRequirements.tap(\n 'StartupChunkDependenciesPlugin',\n (\n chunk: Chunk,\n set: Set<string>,\n { chunkGraph }: { chunkGraph: ChunkGraph },\n ) => {\n // compilation.addRuntimeModule(\n // chunk,\n // //@ts-ignore\n // new FederationModuleInfoRuntimeModule(),\n // );\n },\n );\n },\n );\n }\n}\n\nexport default DynamicFilesystemChunkL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ACf,IAAI,eAAe,oBAAoB,CACvC,IACC,wCACC,OAAc,QAAqB;AAClC,QAAI,CAAC,kBAAkB,MAAM,CAC3B;AAEF,QAAI,IAAI,eAAe,uBAAuB;KAEjD;AACH,eAAY,MAAM,yBACf,IAAI,eAAe,0BAA0B,CAC7C,IACC,wCACC,OAAc,QAAqB;AAClC,QAAI,CAAC,kBAAkB,MAAM,CAC3B;AAEF,QAAI,IAAI,eAAe,6BAA6B;AACpD,QAAI,IAAI,eAAe,YAAY;AACnC,QAAI,IAAI,eAAe,cAAc;AACrC,QAAI,IAAI,eAAe,uBAAuB;KAEjD;AACH,eAAY,MAAM,yBACf,IAAI,eAAe,oBAAoB,CACvC,IACC,wCACC,OAAc,QAAqB;AAClC,QAAI,CAAC,kBAAkB,MAAM,CAC3B;AAEF,QAAI,IAAI,eAAe,0BAA0B;KAEpD;AAEH,eAAY,MAAM,yBACf,IAAI,eAAe,WAAW,CAC9B,IAAI,kBAAkB,OAAO,QAAQ;IACpC,MAAM,EAAE,kBAAkB;IAC1B,MAAM,EAAE,YAAY,kBAAkB,eAAe;IACrD,MAAM,eAAe,MAAM,iBAAiB;IAC5C,MAAM,aACJ,gBAAgB,aAAa,eAAe,SACxC,aAAa,aACb;IAEN,MAAM,SAAS,IAAIC,0DAA4B,KAAK,QAAQ;AAC5D,QAAI,eAAe,UAAU,eAAe,SAC1C,KAAI,IAAI,eAAe,OAAO;aAE9B,OAAO,eAAe,YACtB,kBAAkB,KAAK,WAAW,CAElC,QAAO,WAAW;AAGpB,gBAAY,iBAAiB,OAAO,OAAO;AAC3C,WAAO;KACP;AAEJ,eAAY,MAAM,kCAAkC,IAClD,mCAEE,OACA,KACA,EAAE,iBACC,GAON;IAEJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommonJsChunkLoadingPlugin.mjs","names":["ChunkLoadingRuntimeModule"],"sources":["../../../src/plugins/CommonJsChunkLoadingPlugin.ts"],"sourcesContent":["import type { Chunk, Compiler, Compilation, ChunkGraph } from 'webpack';\nimport { normalizeWebpackPath } from '@module-federation/sdk/normalize-webpack-path';\nimport type { ModuleFederationPluginOptions } from '../types';\nconst StartupChunkDependenciesPlugin = require(\n normalizeWebpackPath('webpack/lib/runtime/StartupChunkDependenciesPlugin'),\n) as typeof import('webpack/lib/runtime/StartupChunkDependenciesPlugin');\nimport ChunkLoadingRuntimeModule from './DynamicFilesystemChunkLoadingRuntimeModule';\nimport AutoPublicPathRuntimeModule from './RemotePublicPathRuntimeModule';\n\ninterface DynamicFilesystemChunkLoadingOptions
|
|
1
|
+
{"version":3,"file":"CommonJsChunkLoadingPlugin.mjs","names":["ChunkLoadingRuntimeModule"],"sources":["../../../src/plugins/CommonJsChunkLoadingPlugin.ts"],"sourcesContent":["import type { Chunk, Compiler, Compilation, ChunkGraph } from 'webpack';\nimport { normalizeWebpackPath } from '@module-federation/sdk/normalize-webpack-path';\nimport type { ModuleFederationPluginOptions } from '../types';\nconst StartupChunkDependenciesPlugin = require(\n normalizeWebpackPath('webpack/lib/runtime/StartupChunkDependenciesPlugin'),\n) as typeof import('webpack/lib/runtime/StartupChunkDependenciesPlugin');\nimport ChunkLoadingRuntimeModule from './DynamicFilesystemChunkLoadingRuntimeModule';\nimport AutoPublicPathRuntimeModule from './RemotePublicPathRuntimeModule';\n\ninterface DynamicFilesystemChunkLoadingOptions extends ModuleFederationPluginOptions {\n baseURI: Compiler['options']['output']['publicPath'];\n promiseBaseURI?: string;\n remotes: Record<string, string>;\n name?: string;\n asyncChunkLoading: boolean;\n debug?: boolean;\n}\n\nclass DynamicFilesystemChunkLoadingPlugin {\n private options: DynamicFilesystemChunkLoadingOptions;\n private _asyncChunkLoading: boolean;\n\n constructor(options: DynamicFilesystemChunkLoadingOptions) {\n this.options = options || ({} as DynamicFilesystemChunkLoadingOptions);\n this._asyncChunkLoading = this.options.asyncChunkLoading;\n }\n\n apply(compiler: Compiler) {\n const { RuntimeGlobals } = compiler.webpack;\n const chunkLoadingValue = this._asyncChunkLoading\n ? 'async-node'\n : 'require';\n\n new StartupChunkDependenciesPlugin({\n chunkLoading: chunkLoadingValue,\n asyncChunkLoading: this._asyncChunkLoading,\n //@ts-ignore\n }).apply(compiler);\n\n compiler.hooks.thisCompilation.tap(\n 'DynamicFilesystemChunkLoadingPlugin',\n (compilation: Compilation) => {\n // Always enabled\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const isEnabledForChunk = (_: Chunk) => true;\n const onceForChunkSet = new WeakSet();\n\n const handler = (chunk: Chunk, set: Set<string>) => {\n if (onceForChunkSet.has(chunk)) {\n return;\n }\n\n onceForChunkSet.add(chunk);\n if (!isEnabledForChunk(chunk)) {\n return;\n }\n set.add(RuntimeGlobals.moduleFactoriesAddOnly);\n set.add(RuntimeGlobals.hasOwnProperty);\n\n set.add(RuntimeGlobals.publicPath); // this breaks things\n compilation.addRuntimeModule(\n chunk,\n new ChunkLoadingRuntimeModule(set, this.options, {\n webpack: compiler.webpack,\n }),\n );\n };\n compilation.hooks.runtimeRequirementInTree\n .for(RuntimeGlobals.ensureChunkHandlers)\n .tap('DynamicFilesystemChunkLoadingPlugin', handler);\n compilation.hooks.runtimeRequirementInTree\n .for(RuntimeGlobals.hmrDownloadUpdateHandlers)\n .tap('DynamicFilesystemChunkLoadingPlugin', handler);\n compilation.hooks.runtimeRequirementInTree\n .for(RuntimeGlobals.hmrDownloadManifest)\n .tap('DynamicFilesystemChunkLoadingPlugin', handler);\n compilation.hooks.runtimeRequirementInTree\n .for(RuntimeGlobals.baseURI)\n .tap('DynamicFilesystemChunkLoadingPlugin', handler);\n compilation.hooks.runtimeRequirementInTree\n .for(RuntimeGlobals.externalInstallChunk)\n .tap('DynamicFilesystemChunkLoadingPlugin', handler);\n compilation.hooks.runtimeRequirementInTree\n .for(RuntimeGlobals.onChunksLoaded)\n .tap('DynamicFilesystemChunkLoadingPlugin', handler);\n compilation.hooks.runtimeRequirementInTree\n .for(RuntimeGlobals.ensureChunkHandlers)\n .tap(\n 'DynamicFilesystemChunkLoadingPlugin',\n (chunk: Chunk, set: Set<string>) => {\n if (!isEnabledForChunk(chunk)) {\n return;\n }\n set.add(RuntimeGlobals.getChunkScriptFilename);\n },\n );\n compilation.hooks.runtimeRequirementInTree\n .for(RuntimeGlobals.hmrDownloadUpdateHandlers)\n .tap(\n 'DynamicFilesystemChunkLoadingPlugin',\n (chunk: Chunk, set: Set<string>) => {\n if (!isEnabledForChunk(chunk)) {\n return;\n }\n set.add(RuntimeGlobals.getChunkUpdateScriptFilename);\n set.add(RuntimeGlobals.moduleCache);\n set.add(RuntimeGlobals.hmrModuleData);\n set.add(RuntimeGlobals.moduleFactoriesAddOnly);\n },\n );\n compilation.hooks.runtimeRequirementInTree\n .for(RuntimeGlobals.hmrDownloadManifest)\n .tap(\n 'DynamicFilesystemChunkLoadingPlugin',\n (chunk: Chunk, set: Set<string>) => {\n if (!isEnabledForChunk(chunk)) {\n return;\n }\n set.add(RuntimeGlobals.getUpdateManifestFilename);\n },\n );\n\n compilation.hooks.runtimeRequirementInTree\n .for(RuntimeGlobals.publicPath)\n .tap('RuntimePlugin', (chunk, set) => {\n const { outputOptions } = compilation;\n const { publicPath: globalPublicPath, scriptType } = outputOptions;\n const entryOptions = chunk.getEntryOptions();\n const publicPath =\n entryOptions && entryOptions.publicPath !== undefined\n ? entryOptions.publicPath\n : globalPublicPath;\n\n const module = new AutoPublicPathRuntimeModule(this.options);\n if (publicPath === 'auto' && scriptType !== 'module') {\n set.add(RuntimeGlobals.global);\n } else if (\n typeof publicPath !== 'string' ||\n /\\[(full)?hash\\]/.test(publicPath)\n ) {\n module.fullHash = true;\n }\n\n compilation.addRuntimeModule(chunk, module);\n return true;\n });\n\n compilation.hooks.additionalTreeRuntimeRequirements.tap(\n 'StartupChunkDependenciesPlugin',\n (\n chunk: Chunk,\n set: Set<string>,\n { chunkGraph }: { chunkGraph: ChunkGraph },\n ) => {\n // compilation.addRuntimeModule(\n // chunk,\n // //@ts-ignore\n // new FederationModuleInfoRu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adingContext;
|
|
22
22
|
hooks: {
|
|
23
|
-
strategyCase: SyncWaterfallHook<unknown, tapable.UnsetAdditionalOptions>;
|
|
23
|
+
strategyCase: SyncWaterfallHook<unknown, unknown, tapable.UnsetAdditionalOptions>;
|
|
24
24
|
};
|
|
25
25
|
private logger;
|
|
26
26
|
constructor(runtimeRequirements: Set<string>, options: DynamicFilesystemChunkLoadingRuntimeModuleOptions, chunkLoadingContext: ChunkLoadingContext);
|
|
@@ -20,7 +20,7 @@ declare class DynamicFilesystemChunkLoadingRuntimeModule extends RuntimeModule {
|
|
|
20
20
|
private options;
|
|
21
21
|
private chunkLoadingContext;
|
|
22
22
|
hooks: {
|
|
23
|
-
strategyCase: SyncWaterfallHook<unknown, tapable.UnsetAdditionalOptions>;
|
|
23
|
+
strategyCase: SyncWaterfallHook<unknown, unknown, tapable.UnsetAdditionalOptions>;
|
|
24
24
|
};
|
|
25
25
|
private logger;
|
|
26
26
|
constructor(runtimeRequirements: Set<string>, options: DynamicFilesystemChunkLoadingRuntimeModuleOptions, chunkLoadingContext: ChunkLoadingContext);
|
|
@@ -7,6 +7,9 @@ let _module_federation_sdk = require("@module-federation/sdk");
|
|
|
7
7
|
|
|
8
8
|
//#region src/plugins/NodeFederationPlugin.ts
|
|
9
9
|
const createBundlerLogger = typeof _module_federation_sdk.createInfrastructureLogger === "function" ? _module_federation_sdk.createInfrastructureLogger : _module_federation_sdk.createLogger;
|
|
10
|
+
function getRuntimePluginPath() {
|
|
11
|
+
return require.resolve("../runtimePlugin.js");
|
|
12
|
+
}
|
|
10
13
|
/**
|
|
11
14
|
* Class representing a NodeFederationPlugin.
|
|
12
15
|
* @class
|
|
@@ -38,7 +41,7 @@ var NodeFederationPlugin = class {
|
|
|
38
41
|
new require_src_plugins_EntryChunkTrackerPlugin.default({}).apply(compiler);
|
|
39
42
|
}
|
|
40
43
|
preparePluginOptions() {
|
|
41
|
-
this._options.runtimePlugins = [...this.useRuntimePlugin ? [
|
|
44
|
+
this._options.runtimePlugins = [...this.useRuntimePlugin ? [getRuntimePluginPath()] : [], ...this._options.runtimePlugins || []];
|
|
42
45
|
return {
|
|
43
46
|
...this._options,
|
|
44
47
|
remotes: this._options.remotes || {},
|
|
@@ -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\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 ? [
|
|
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"}
|
|
@@ -4,6 +4,9 @@ import { bindLoggerToCompiler, createInfrastructureLogger, createLogger } from "
|
|
|
4
4
|
|
|
5
5
|
//#region src/plugins/NodeFederationPlugin.ts
|
|
6
6
|
const createBundlerLogger = typeof createInfrastructureLogger === "function" ? createInfrastructureLogger : createLogger;
|
|
7
|
+
function getRuntimePluginPath() {
|
|
8
|
+
return __require.resolve("../runtimePlugin.mjs");
|
|
9
|
+
}
|
|
7
10
|
/**
|
|
8
11
|
* Class representing a NodeFederationPlugin.
|
|
9
12
|
* @class
|
|
@@ -35,7 +38,7 @@ var NodeFederationPlugin = class {
|
|
|
35
38
|
new EntryChunkTrackerPlugin({}).apply(compiler);
|
|
36
39
|
}
|
|
37
40
|
preparePluginOptions() {
|
|
38
|
-
this._options.runtimePlugins = [...this.useRuntimePlugin ? [
|
|
41
|
+
this._options.runtimePlugins = [...this.useRuntimePlugin ? [getRuntimePluginPath()] : [], ...this._options.runtimePlugins || []];
|
|
39
42
|
return {
|
|
40
43
|
...this._options,
|
|
41
44
|
remotes: this._options.remotes || {},
|
|
@@ -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\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 ? [
|
|
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 +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 (webpack?.node?.NodeEnvironmentPlugin ||\n require('webpack/lib/node/NodeEnvironmentPlugin'))({\n infrastructureLogging: compiler.options.infrastructureLogging,\n }).apply(compiler);\n\n new (webpack?.node?.NodeTargetPlugin ||\n require('webpack/lib/node/NodeTargetPlugin'))().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,
|
|
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 +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 (webpack?.node?.NodeEnvironmentPlugin ||\n require('webpack/lib/node/NodeEnvironmentPlugin'))({\n infrastructureLogging: compiler.options.infrastructureLogging,\n }).apply(compiler);\n\n new (webpack?.node?.NodeTargetPlugin ||\n require('webpack/lib/node/NodeTargetPlugin'))().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,
|
|
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"}
|
|
@@ -9,6 +9,7 @@ let _module_federation_enhanced_webpack = require("@module-federation/enhanced/w
|
|
|
9
9
|
/**
|
|
10
10
|
* Importing necessary plugins and types
|
|
11
11
|
*/
|
|
12
|
+
const resolveRuntimePluginPath = () => require.resolve("../runtimePlugin.js");
|
|
12
13
|
/**
|
|
13
14
|
* Class representing a UniversalFederationPlugin
|
|
14
15
|
*/
|
|
@@ -22,7 +23,10 @@ var UniversalFederationPlugin = class {
|
|
|
22
23
|
this._options = options || {};
|
|
23
24
|
this.context = context || {};
|
|
24
25
|
this.name = "ModuleFederationPlugin";
|
|
25
|
-
if (this._options.useRuntimePlugin && this._options.isServer)
|
|
26
|
+
if (this._options.useRuntimePlugin && this._options.isServer) {
|
|
27
|
+
const runtimePluginPath = resolveRuntimePluginPath();
|
|
28
|
+
this._options.runtimePlugins = this._options.runtimePlugins ? this._options.runtimePlugins.concat([runtimePluginPath]) : [runtimePluginPath];
|
|
29
|
+
}
|
|
26
30
|
}
|
|
27
31
|
updateCompilerOptions(compiler) {
|
|
28
32
|
compiler.options.output.chunkFormat = "commonjs";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UniversalFederationPlugin.js","names":["ModuleFederationPlugin","NodeFederationPlugin","StreamingTargetPlugin"],"sources":["../../../src/plugins/UniversalFederationPlugin.ts"],"sourcesContent":["/**\n * Importing necessary plugins and types\n */\nimport StreamingTargetPlugin from './StreamingTargetPlugin';\nimport NodeFederationPlugin from './NodeFederationPlugin';\nimport { ModuleFederationPlugin } from '@module-federation/enhanced/webpack';\nimport { ModuleFederationPluginOptions } from '../types';\nimport type { Compiler, container } from 'webpack';\nimport { getWebpackPath } from '@module-federation/sdk/normalize-webpack-path';\n\n/**\n * Interface for NodeFederationOptions\n * @property {boolean} isServer - Indicates if the server is running\n * @property {string} [promiseBaseURI] - The base URI for the promise\n * @property {boolean} [debug] - Indicates if debug mode is enabled\n */\ninterface NodeFederationOptions extends ModuleFederationPluginOptions {\n isServer: boolean;\n promiseBaseURI?: string;\n debug?: boolean;\n useRuntimePlugin?: boolean;\n}\n\n/**\n * Interface for NodeFederationContext\n * @property {typeof container.ModuleFederationPlugin} [ModuleFederationPlugin] - The ModuleFederationPlugin from webpack container\n */\ninterface NodeFederationContext {\n ModuleFederationPlugin?: typeof container.ModuleFederationPlugin;\n}\n\n/**\n * Class representing a UniversalFederationPlugin\n */\nclass UniversalFederationPlugin {\n private _options: NodeFederationOptions;\n private context: NodeFederationContext;\n private name: string;\n\n /**\n * Create a UniversalFederationPlugin\n * @param {NodeFederationOptions} options - The options for the plugin\n * @param {NodeFederationContext} context - The context for the plugin\n */\n constructor(options: NodeFederationOptions, context: NodeFederationContext) {\n this._options = options || ({} as NodeFederationOptions);\n this.context = context || ({} as NodeFederationContext);\n this.name = 'ModuleFederationPlugin';\n if (this._options.useRuntimePlugin && this._options.isServer) {\n this._options.runtimePlugins = this._options.runtimePlugins\n ? this._options.runtimePlugins.concat([
|
|
1
|
+
{"version":3,"file":"UniversalFederationPlugin.js","names":["ModuleFederationPlugin","NodeFederationPlugin","StreamingTargetPlugin"],"sources":["../../../src/plugins/UniversalFederationPlugin.ts"],"sourcesContent":["/**\n * Importing necessary plugins and types\n */\nimport StreamingTargetPlugin from './StreamingTargetPlugin';\nimport NodeFederationPlugin from './NodeFederationPlugin';\nimport { ModuleFederationPlugin } from '@module-federation/enhanced/webpack';\nimport { ModuleFederationPluginOptions } from '../types';\nimport type { Compiler, container } from 'webpack';\nimport { getWebpackPath } from '@module-federation/sdk/normalize-webpack-path';\n\n/**\n * Interface for NodeFederationOptions\n * @property {boolean} isServer - Indicates if the server is running\n * @property {string} [promiseBaseURI] - The base URI for the promise\n * @property {boolean} [debug] - Indicates if debug mode is enabled\n */\ninterface NodeFederationOptions extends ModuleFederationPluginOptions {\n isServer: boolean;\n promiseBaseURI?: string;\n debug?: boolean;\n useRuntimePlugin?: boolean;\n}\n\n/**\n * Interface for NodeFederationContext\n * @property {typeof container.ModuleFederationPlugin} [ModuleFederationPlugin] - The ModuleFederationPlugin from webpack container\n */\ninterface NodeFederationContext {\n ModuleFederationPlugin?: typeof container.ModuleFederationPlugin;\n}\n\nconst resolveRuntimePluginPath = (): string =>\n process.env.IS_ESM_BUILD === 'true'\n ? require.resolve('../runtimePlugin.mjs')\n : require.resolve('../runtimePlugin.js');\n\n/**\n * Class representing a UniversalFederationPlugin\n */\nclass UniversalFederationPlugin {\n private _options: NodeFederationOptions;\n private context: NodeFederationContext;\n private name: string;\n\n /**\n * Create a UniversalFederationPlugin\n * @param {NodeFederationOptions} options - The options for the plugin\n * @param {NodeFederationContext} context - The context for the plugin\n */\n constructor(options: NodeFederationOptions, context: NodeFederationContext) {\n this._options = options || ({} as NodeFederationOptions);\n this.context = context || ({} as NodeFederationContext);\n this.name = 'ModuleFederationPlugin';\n if (this._options.useRuntimePlugin && this._options.isServer) {\n const runtimePluginPath = resolveRuntimePluginPath();\n this._options.runtimePlugins = this._options.runtimePlugins\n ? this._options.runtimePlugins.concat([runtimePluginPath])\n : [runtimePluginPath];\n }\n }\n\n private updateCompilerOptions(compiler: Compiler): void {\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 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 /**\n * Apply the plugin to the compiler\n * @param {Compiler} compiler - The webpack compiler\n */\n apply(compiler: Compiler) {\n const { isServer, debug, useRuntimePlugin, ...options } = this._options;\n const { webpack } = compiler;\n if (!process.env['FEDERATION_WEBPACK_PATH']) {\n process.env['FEDERATION_WEBPACK_PATH'] = getWebpackPath(compiler);\n }\n if (\n isServer ||\n compiler.options.name === 'server' ||\n compiler.options.target === 'node' ||\n compiler.options.target === 'async-node'\n ) {\n if (useRuntimePlugin) {\n this.updateCompilerOptions(compiler);\n new ModuleFederationPlugin({\n ...options,\n }).apply(compiler);\n } else {\n new NodeFederationPlugin(options, this.context).apply(compiler);\n new StreamingTargetPlugin({ ...options, debug }).apply(compiler);\n }\n } else {\n new ModuleFederationPlugin(options).apply(compiler);\n }\n }\n}\n\n/**\n * Exporting UniversalFederationPlugin as default\n */\nexport default UniversalFederationPlugin;\n"],"mappings":";;;;;;;;;;;AA+BA,MAAM,iCAGA,QAAQ,QAAQ,sBAAsB;;;;AAK5C,IAAM,4BAAN,MAAgC;;;;;;CAU9B,YAAY,SAAgC,SAAgC;AAC1E,OAAK,WAAW,WAAY,EAAE;AAC9B,OAAK,UAAU,WAAY,EAAE;AAC7B,OAAK,OAAO;AAC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/enhanced/webpack";
|
|
|
8
8
|
/**
|
|
9
9
|
* Importing necessary plugins and types
|
|
10
10
|
*/
|
|
11
|
+
const resolveRuntimePluginPath = () => __require.resolve("../runtimePlugin.mjs");
|
|
11
12
|
/**
|
|
12
13
|
* Class representing a UniversalFederationPlugin
|
|
13
14
|
*/
|
|
@@ -21,7 +22,10 @@ var UniversalFederationPlugin = class {
|
|
|
21
22
|
this._options = options || {};
|
|
22
23
|
this.context = context || {};
|
|
23
24
|
this.name = "ModuleFederationPlugin";
|
|
24
|
-
if (this._options.useRuntimePlugin && this._options.isServer)
|
|
25
|
+
if (this._options.useRuntimePlugin && this._options.isServer) {
|
|
26
|
+
const runtimePluginPath = resolveRuntimePluginPath();
|
|
27
|
+
this._options.runtimePlugins = this._options.runtimePlugins ? this._options.runtimePlugins.concat([runtimePluginPath]) : [runtimePluginPath];
|
|
28
|
+
}
|
|
25
29
|
}
|
|
26
30
|
updateCompilerOptions(compiler) {
|
|
27
31
|
compiler.options.output.chunkFormat = "commonjs";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UniversalFederationPlugin.mjs","names":[],"sources":["../../../src/plugins/UniversalFederationPlugin.ts"],"sourcesContent":["/**\n * Importing necessary plugins and types\n */\nimport StreamingTargetPlugin from './StreamingTargetPlugin';\nimport NodeFederationPlugin from './NodeFederationPlugin';\nimport { ModuleFederationPlugin } from '@module-federation/enhanced/webpack';\nimport { ModuleFederationPluginOptions } from '../types';\nimport type { Compiler, container } from 'webpack';\nimport { getWebpackPath } from '@module-federation/sdk/normalize-webpack-path';\n\n/**\n * Interface for NodeFederationOptions\n * @property {boolean} isServer - Indicates if the server is running\n * @property {string} [promiseBaseURI] - The base URI for the promise\n * @property {boolean} [debug] - Indicates if debug mode is enabled\n */\ninterface NodeFederationOptions extends ModuleFederationPluginOptions {\n isServer: boolean;\n promiseBaseURI?: string;\n debug?: boolean;\n useRuntimePlugin?: boolean;\n}\n\n/**\n * Interface for NodeFederationContext\n * @property {typeof container.ModuleFederationPlugin} [ModuleFederationPlugin] - The ModuleFederationPlugin from webpack container\n */\ninterface NodeFederationContext {\n ModuleFederationPlugin?: typeof container.ModuleFederationPlugin;\n}\n\n/**\n * Class representing a UniversalFederationPlugin\n */\nclass UniversalFederationPlugin {\n private _options: NodeFederationOptions;\n private context: NodeFederationContext;\n private name: string;\n\n /**\n * Create a UniversalFederationPlugin\n * @param {NodeFederationOptions} options - The options for the plugin\n * @param {NodeFederationContext} context - The context for the plugin\n */\n constructor(options: NodeFederationOptions, context: NodeFederationContext) {\n this._options = options || ({} as NodeFederationOptions);\n this.context = context || ({} as NodeFederationContext);\n this.name = 'ModuleFederationPlugin';\n if (this._options.useRuntimePlugin && this._options.isServer) {\n this._options.runtimePlugins = this._options.runtimePlugins\n ? this._options.runtimePlugins.concat([
|
|
1
|
+
{"version":3,"file":"UniversalFederationPlugin.mjs","names":[],"sources":["../../../src/plugins/UniversalFederationPlugin.ts"],"sourcesContent":["/**\n * Importing necessary plugins and types\n */\nimport StreamingTargetPlugin from './StreamingTargetPlugin';\nimport NodeFederationPlugin from './NodeFederationPlugin';\nimport { ModuleFederationPlugin } from '@module-federation/enhanced/webpack';\nimport { ModuleFederationPluginOptions } from '../types';\nimport type { Compiler, container } from 'webpack';\nimport { getWebpackPath } from '@module-federation/sdk/normalize-webpack-path';\n\n/**\n * Interface for NodeFederationOptions\n * @property {boolean} isServer - Indicates if the server is running\n * @property {string} [promiseBaseURI] - The base URI for the promise\n * @property {boolean} [debug] - Indicates if debug mode is enabled\n */\ninterface NodeFederationOptions extends ModuleFederationPluginOptions {\n isServer: boolean;\n promiseBaseURI?: string;\n debug?: boolean;\n useRuntimePlugin?: boolean;\n}\n\n/**\n * Interface for NodeFederationContext\n * @property {typeof container.ModuleFederationPlugin} [ModuleFederationPlugin] - The ModuleFederationPlugin from webpack container\n */\ninterface NodeFederationContext {\n ModuleFederationPlugin?: typeof container.ModuleFederationPlugin;\n}\n\nconst resolveRuntimePluginPath = (): string =>\n process.env.IS_ESM_BUILD === 'true'\n ? require.resolve('../runtimePlugin.mjs')\n : require.resolve('../runtimePlugin.js');\n\n/**\n * Class representing a UniversalFederationPlugin\n */\nclass UniversalFederationPlugin {\n private _options: NodeFederationOptions;\n private context: NodeFederationContext;\n private name: string;\n\n /**\n * Create a UniversalFederationPlugin\n * @param {NodeFederationOptions} options - The options for the plugin\n * @param {NodeFederationContext} context - The context for the plugin\n */\n constructor(options: NodeFederationOptions, context: NodeFederationContext) {\n this._options = options || ({} as NodeFederationOptions);\n this.context = context || ({} as NodeFederationContext);\n this.name = 'ModuleFederationPlugin';\n if (this._options.useRuntimePlugin && this._options.isServer) {\n const runtimePluginPath = resolveRuntimePluginPath();\n this._options.runtimePlugins = this._options.runtimePlugins\n ? this._options.runtimePlugins.concat([runtimePluginPath])\n : [runtimePluginPath];\n }\n }\n\n private updateCompilerOptions(compiler: Compiler): void {\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 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 /**\n * Apply the plugin to the compiler\n * @param {Compiler} compiler - The webpack compiler\n */\n apply(compiler: Compiler) {\n const { isServer, debug, useRuntimePlugin, ...options } = this._options;\n const { webpack } = compiler;\n if (!process.env['FEDERATION_WEBPACK_PATH']) {\n process.env['FEDERATION_WEBPACK_PATH'] = getWebpackPath(compiler);\n }\n if (\n isServer ||\n compiler.options.name === 'server' ||\n compiler.options.target === 'node' ||\n compiler.options.target === 'async-node'\n ) {\n if (useRuntimePlugin) {\n this.updateCompilerOptions(compiler);\n new ModuleFederationPlugin({\n ...options,\n }).apply(compiler);\n } else {\n new NodeFederationPlugin(options, this.context).apply(compiler);\n new StreamingTargetPlugin({ ...options, debug }).apply(compiler);\n }\n } else {\n new ModuleFederationPlugin(options).apply(compiler);\n }\n }\n}\n\n/**\n * Exporting UniversalFederationPlugin as default\n */\nexport default UniversalFederationPlugin;\n"],"mappings":";;;;;;;;;;AA+BA,MAAM,2CAEQ,QAAQ,uBAAuB;;;;AAM7C,IAAM,4BAAN,MAAgC;;;;;;CAU9B,YAAY,SAAgC,SAAgC;AAC1E,OAAK,WAAW,WAAY,EAAE;AAC9B,OAAK,UAAU,WAAY,EAAE;AAC7B,OAAK,OAAO;AACZ,MAAI,KAAK,SAAS,oBAAoB,KAAK,SAAS,UAAU;GAC5D,MAAM,oBAAoB,0BAA0B;AACpD,QAAK,SAAS,iBAAiB,KAAK,SAAS,iBACzC,KAAK,SAAS,eAAe,OAAO,CAAC,kBAAkB,CAAC,GACxD,CAAC,kBAAkB;;;CAI3B,AAAQ,sBAAsB,UAA0B;AACtD,WAAS,QAAQ,OAAO,cAAc;AACtC,MAAI,SAAS,QAAQ,OAAO,wBAAwB,OAClD,UAAS,QAAQ,OAAO,sBAAsB,CAAC,kBAAkB;MAEjE,UAAS,QAAQ,OAAO,oBAAoB,KAAK,kBAAkB;EAGrE,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;;;;;;;CAQL,MAAM,UAAoB;EACxB,MAAM,EAAE,UAAU,OAAO,kBAAkB,GAAG,YAAY,KAAK;EAC/D,MAAM,EAAE,YAAY;AACpB,MAAI,CAAC,QAAQ,IAAI,2BACf,SAAQ,IAAI,6BAA6B,eAAe,SAAS;AAEnE,MACE,YACA,SAAS,QAAQ,SAAS,YAC1B,SAAS,QAAQ,WAAW,UAC5B,SAAS,QAAQ,WAAW,aAE5B,KAAI,kBAAkB;AACpB,QAAK,sBAAsB,SAAS;AACpC,OAAI,uBAAuB,EACzB,GAAG,SACJ,CAAC,CAAC,MAAM,SAAS;SACb;AACL,OAAI,qBAAqB,SAAS,KAAK,QAAQ,CAAC,MAAM,SAAS;AAC/D,OAAI,sBAAsB;IAAE,GAAG;IAAS;IAAO,CAAC,CAAC,MAAM,SAAS;;MAGlE,KAAI,uBAAuB,QAAQ,CAAC,MAAM,SAAS"}
|
|
@@ -48,8 +48,11 @@ const createShareMap = () => {
|
|
|
48
48
|
*/
|
|
49
49
|
const processChunk = async (chunk, shareMap, hostStats) => {
|
|
50
50
|
const chunks = /* @__PURE__ */ new Set();
|
|
51
|
-
const
|
|
52
|
-
const
|
|
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;
|
|
53
56
|
const knownRemotes = getAllKnownRemotes();
|
|
54
57
|
if (!knownRemotes[remote]) {
|
|
55
58
|
console.error(`flush chunks: Remote ${remote} is not defined in the global config`);
|
|
@@ -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
|
|
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,MAAM,YAAY,qBAAqB,cAE1C,MA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AAM,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"}
|
|
@@ -46,8 +46,11 @@ const createShareMap = () => {
|
|
|
46
46
|
*/
|
|
47
47
|
const processChunk = async (chunk, shareMap, hostStats) => {
|
|
48
48
|
const chunks = /* @__PURE__ */ new Set();
|
|
49
|
-
const
|
|
50
|
-
const
|
|
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;
|
|
51
54
|
const knownRemotes = getAllKnownRemotes();
|
|
52
55
|
if (!knownRemotes[remote]) {
|
|
53
56
|
console.error(`flush chunks: Remote ${remote} is not defined in the global config`);
|
|
@@ -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
|
|
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,0BAA0B,QAG5B,QAAO,OAAO,KAAK,yBAAyB,QAAQ,CAAC,QAAQ,KAAK,QAAQ;EAExE,MAAM,WAAW,yBAAyB,QAAQ;AAElD,MAAI,CAAC,YAAY,OAAO,aAAa,SACnC,QAAO;EAGT,MAAM,gBAAgB,OAAO,OAAO,SAAS,CAG1C,QAAQ,iBAAiB,aAAa,OAAO,CAG7C,KAAK,iBAAiB,aAAa,KAAK;AAG3C,MAAI,cAAc,SAAS,EAEzB,KAAI,OAAO;AAGb,SAAO;IACN,EAAE,CAAC;AAGR,QAAO,EAAE;;;;;;;;;AAWX,MAAM,eAAe,OAAO,OAAO,UAAU,cAAc;CACzD,MAAM,yBAAS,IAAI,KAAK;CACxB,MAAM,kBAAkB,MAAM,SAAS,KAAK,GACxC,MAAM,QAAQ,MAAM,IAAI,GACx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a,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"}
|
|
@@ -77,6 +77,7 @@ const searchCache = function(moduleName, callback) {
|
|
|
77
77
|
callback(current);
|
|
78
78
|
})(mod);
|
|
79
79
|
};
|
|
80
|
+
globalThis.moduleGraphDirty = false;
|
|
80
81
|
const hashmap = globalThis.mfHashMap || {};
|
|
81
82
|
globalThis.moduleGraphDirty = false;
|
|
82
83
|
const requireCacheRegex = /(remote|server|hot-reload|react-loadable-manifest|runtime|styled-jsx)/;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hot-reload.js","names":["getAllKnownRemotes"],"sources":["../../../src/utils/hot-reload.ts"],"sourcesContent":["import { getAllKnownRemotes } from './flush-chunks';\nimport crypto from 'crypto';\nimport helpers from '@module-federation/runtime/helpers';\nimport path from 'path';\n\ndeclare global {\n var mfHashMap: Record<string, string> | undefined;\n var moduleGraphDirty: boolean;\n}\n\nconst getRequire = (): NodeRequire => {\n //@ts-ignore\n return typeof __non_webpack_require__ !== 'undefined'\n ? (__non_webpack_require__ as NodeRequire)\n : eval('require');\n};\n\nfunction callsites(): any[] {\n const _prepareStackTrace = Error.prepareStackTrace;\n try {\n let result: any[] = [];\n Error.prepareStackTrace = (_, callSites) => {\n const callSitesWithoutCurrent = callSites.slice(1);\n result = callSitesWithoutCurrent;\n return callSitesWithoutCurrent;\n };\n\n new Error().stack;\n return result;\n } finally {\n Error.prepareStackTrace = _prepareStackTrace;\n }\n}\n\nconst find = function (moduleName: string): string | undefined {\n if (moduleName[0] === '.') {\n // Use custom callsites function\n const stack = callsites();\n for (const frame of stack) {\n const filename = frame.getFileName();\n if (filename && filename !== module.filename) {\n moduleName = path.resolve(path.dirname(filename), moduleName);\n break;\n }\n }\n }\n try {\n return getRequire().resolve(moduleName);\n } catch (e) {\n return;\n }\n};\n\n/**\n * Removes a module from the cache. We need this to re-load our http_request !\n * see: https://stackoverflow.com/a/14801711/1148249\n */\nconst decache = async function (moduleName: string) {\n //@ts-ignore\n moduleName = find(moduleName);\n\n if (!moduleName) {\n return;\n }\n\n const currentChunk = getRequire().cache[__filename];\n\n // Run over the cache looking for the files\n // loaded by the specified module name\n searchCache(moduleName, function (mod: NodeModule) {\n delete getRequire().cache[mod.id];\n });\n try {\n // Remove cached paths to the module.\n // Thanks to @bentael for pointing this out.\n //@ts-ignore\n Object.keys((currentChunk.constructor as any)._pathCache).forEach(\n function (cacheKey) {\n if (cacheKey.indexOf(moduleName) > -1) {\n //@ts-ignore\n delete (currentChunk.constructor as any)._pathCache[cacheKey];\n }\n },\n );\n } catch (error) {\n //null\n }\n};\n\n/**\n * Runs over the cache to search for all the cached\n * files\n */\nconst searchCache = function (\n moduleName: string,\n callback: (mod: NodeModule) => void,\n) {\n // Resolve the module identified by the specified name\n let mod = getRequire().resolve(moduleName);\n const visited: Record<string, boolean> = {};\n\n // Check if the module has been resolved and found within\n // the cache no else so #ignore else https://git.io/vtgMI\n /* istanbul ignore else */\n //@ts-ignore\n if (mod && (mod = getRequire().cache[mod]) !== undefined) {\n // Recursively go over the results\n (function run(current: NodeModule) {\n visited[current.id] = true;\n // Go over each of the module's children and\n // run over it\n current.children.forEach(function (child: NodeModule) {\n // ignore .node files, decaching native modules throws a\n // \"module did not self-register\" error on second require\n if (path.extname(child.filename) !== '.node' && !visited[child.id]) {\n run(child);\n }\n });\n\n // Call the specified callback providing the\n // found module\n callback(current);\n //@ts-ignore\n })(mod);\n }\n};\n\nconst hashmap = globalThis.mfHashMap || ({} as Record<string, string>);\nglobalThis.moduleGraphDirty = false;\n\nconst requireCacheRegex =\n /(remote|server|hot-reload|react-loadable-manifest|runtime|styled-jsx)/;\n\nexport const performReload = async (\n shouldReload: boolean,\n): Promise<boolean> => {\n if (!shouldReload) {\n return false;\n }\n\n const req = getRequire();\n\n const gs = new Function('return globalThis')();\n const entries: Set<string> = gs.entryChunkCache || new Set();\n\n //@ts-ignore\n gs.__FEDERATION__.__INSTANCES__.map((i: any) => {\n //@ts-ignore\n i.moduleCache.forEach((mc: any) => {\n if (mc.remoteInfo && mc.remoteInfo.entryGlobalName) {\n delete gs[mc.remoteInfo.entryGlobalName];\n }\n });\n i.moduleCache.clear();\n if (gs[i.name]) {\n delete gs[i.name];\n }\n });\n //@ts-ignore\n __webpack_require__?.federation?.instance?.moduleCache?.clear();\n helpers.global.resetFederationGlobalInfo();\n globalThis.moduleGraphDirty = false;\n globalThis.mfHashMap = {};\n\n if (!entries) {\n Object.keys(req.cache).forEach((key) => {\n if (requireCacheRegex.test(key)) {\n decache(key); // Use decache here\n }\n });\n } else {\n for (const entry of entries) {\n decache(entry);\n //reload entries again\n await getRequire()(entry);\n }\n }\n\n return true;\n};\n\nexport const checkUnreachableRemote = (remoteScope: any): boolean => {\n for (const property in remoteScope.remotes) {\n if (!remoteScope[property]) {\n console.error(\n 'unreachable remote found',\n property,\n 'hot reloading to refetch',\n );\n return true;\n }\n }\n return false;\n};\n\nexport const checkMedusaConfigChange = (\n remoteScope: any,\n fetchModule: any,\n): boolean => {\n //@ts-ignore\n if (remoteScope._medusa) {\n //@ts-ignore\n for (const property in remoteScope._medusa) {\n fetchModule(property)\n .then((res: Response) => res.json())\n .then((medusaResponse: any): void | boolean => {\n if (\n medusaResponse.version !==\n //@ts-ignore\n remoteScope?._medusa[property].version\n ) {\n console.log(\n 'medusa config changed',\n property,\n 'hot reloading to refetch',\n );\n performReload(true);\n return true;\n }\n });\n }\n }\n return false;\n};\n\nexport const checkFakeRemote = (remoteScope: any): boolean => {\n for (const property in remoteScope._config) {\n let remote = remoteScope._config[property];\n\n const resolveRemote = async () => {\n remote = await remote();\n };\n\n if (typeof remote === 'function') {\n resolveRemote();\n }\n\n if (remote.fake) {\n console.log('fake remote found', property, 'hot reloading to refetch');\n return true;\n }\n }\n return false;\n};\n\nexport const createFetcher = (\n url: string,\n fetchModule: any,\n name: string,\n cb: (hash: string) => void,\n): Promise<void | boolean> => {\n return fetchModule(url)\n .then((re: Response) => {\n if (!re.ok) {\n throw new Error(\n `Error loading remote: status: ${\n re.status\n }, content-type: ${re.headers.get('content-type')}`,\n );\n }\n return re.text();\n })\n .then((contents: string): void | boolean => {\n const hash = crypto.createHash('md5').update(contents).digest('hex');\n cb(hash);\n })\n .catch((e: Error) => {\n console.error('Remote', name, url, 'Failed to load or is not online', e);\n });\n};\n\nexport const fetchRemote = (\n remoteScope: any,\n fetchModule: any,\n): Promise<boolean> => {\n const fetches: Promise<void | boolean>[] = [];\n let needReload = false;\n for (const property in remoteScope) {\n const name = property;\n const container = remoteScope[property];\n const url = container.entry;\n const fetcher = createFetcher(url, fetchModule, name, (hash) => {\n if (hashmap[name]) {\n if (hashmap[name] !== hash) {\n hashmap[name] = hash;\n needReload = true;\n console.log(name, 'hash is different - must hot reload server');\n }\n } else {\n hashmap[name] = hash;\n }\n });\n\n fetches.push(fetcher);\n }\n return Promise.all(fetches).then(() => {\n return needReload;\n });\n};\n//@ts-ignore\nexport const revalidate = async (\n fetchModule: any = getFetchModule() || (() => {}),\n force: boolean = false,\n): Promise<boolean> => {\n if (globalThis.moduleGraphDirty) {\n force = true;\n }\n const remotesFromAPI = getAllKnownRemotes();\n //@ts-ignore\n return new Promise((res) => {\n if (force) {\n if (Object.keys(hashmap).length !== 0) {\n res(true);\n return;\n }\n }\n if (checkMedusaConfigChange(remotesFromAPI, fetchModule)) {\n res(true);\n }\n\n if (checkFakeRemote(remotesFromAPI)) {\n res(true);\n }\n\n fetchRemote(remotesFromAPI, fetchModule).then((val) => {\n res(val);\n });\n }).then((shouldReload: unknown) => {\n return performReload(shouldReload as boolean);\n });\n};\n\nexport function getFetchModule(): any {\n //@ts-ignore\n const loadedModule =\n //@ts-ignore\n globalThis.webpackChunkLoad || global.webpackChunkLoad || global.fetch;\n if (loadedModule) {\n return loadedModule;\n }\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const nodeFetch = require('node-fetch');\n return nodeFetch.default || nodeFetch;\n}\n"],"mappings":";;;;;;;;;;;AAUA,MAAM,mBAAgC;AAEpC,QAAO,OAAO,4BAA4B,cACrC,0BACD,KAAK,UAAU;;AAGrB,SAAS,YAAmB;CAC1B,MAAM,qBAAqB,MAAM;AACjC,KAAI;EACF,IAAI,SAAgB,EAAE;AACtB,QAAM,qBAAqB,GAAG,cAAc;GAC1C,MAAM,0BAA0B,UAAU,MAAM,EAAE;AAClD,YAAS;AACT,UAAO;;AAGT,uBAAI,OAAO,EAAC;AACZ,SAAO;WACC;AACR,QAAM,oBAAoB;;;AAI9B,MAAM,OAAO,SAAU,YAAwC;AAC7D,KAAI,WAAW,OAAO,KAAK;EAEzB,MAAM,QAAQ,WAAW;AACzB,OAAK,MAAM,SAAS,OAAO;GACzB,MAAM,WAAW,MAAM,aAAa;AACpC,OAAI,YAAY,aAAa,OAAO,UAAU;AAC5C,iBAAa,aAAK,QAAQ,aAAK,QAAQ,SAAS,EAAE,WAAW;AAC7D;;;;AAIN,KAAI;AACF,SAAO,YAAY,CAAC,QAAQ,WAAW;UAChC,GAAG;AACV;;;;;;;AAQJ,MAAM,UAAU,eAAgB,YAAoB;AAElD,cAAa,KAAK,WAAW;AAE7B,KAAI,CAAC,WACH;CAGF,MAAM,eAAe,YAAY,CAAC,MAAM;AAIxC,aAAY,YAAY,SAAU,KAAiB;AACjD,SAAO,YAAY,CAAC,MAAM,IAAI;GAC9B;AACF,KAAI;AAIF,SAAO,KAAM,aAAa,YAAoB,WAAW,CAAC,QACxD,SAAU,UAAU;AAClB,OAAI,SAAS,QAAQ,WAAW,GAAG,GAEjC,QAAQ,aAAa,YAAoB,WAAW;I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AAM,MADY,YAAY,UACR;EACtB,MAAM,UAAU,cAAc,KAAK,aAAa,OAAO,SAAS;AAC9D,OAAI,QAAQ,OACV;QAAI,QAAQ,UAAU,MAAM;AAC1B,aAAQ,QAAQ;AAChB,kBAAa;AACb,aAAQ,IAAI,MAAM,6CAA6C;;SAGjE,SAAQ,QAAQ;IAElB;AAEF,UAAQ,KAAK,QAAQ;;AAEvB,QAAO,QAAQ,IAAI,QAAQ,CAAC,WAAW;AACrC,SAAO;GACP;;AAGJ,MAAa,aAAa,OACxB,cAAmB,gBAAgB,WAAW,KAC9C,QAAiB,UACI;AACrB,KAAI,WAAW,iBACb,SAAQ;CAEV,MAAM,iBAAiBA,mDAAoB;AAE3C,QAAO,IAAI,SAAS,QAAQ;AAC1B,MAAI,OACF;OAAI,OAAO,KAAK,QAAQ,CAAC,WAAW,GAAG;AACrC,QAAI,KAAK;AACT;;;AAGJ,MAAI,wBAAwB,gBAAgB,YAAY,CACtD,KAAI,KAAK;AAGX,MAAI,gBAAgB,eAAe,CACjC,KAAI,KAAK;AAGX,cAAY,gBAAgB,YAAY,CAAC,MAAM,QAAQ;AACrD,OAAI,IAAI;IACR;GACF,CAAC,MAAM,iBAA0B;AACjC,SAAO,cAAc,aAAwB;GAC7C;;AAGJ,SAAgB,iBAAsB;CAEpC,MAAM,eAEJ,WAAW,oBAAoB,OAAO,oBAAoB,OAAO;AACnE,KAAI,aACF,QAAO;CAGT,MAAM,YAAY,QAAQ,aAAa;AACvC,QAAO,UAAU,WAAW"}
|
|
1
|
+
{"version":3,"file":"hot-reload.js","names":["getAllKnownRemotes"],"sources":["../../../src/utils/hot-reload.ts"],"sourcesContent":["import { getAllKnownRemotes } from './flush-chunks';\nimport crypto from 'crypto';\nimport helpers from '@module-federation/runtime/helpers';\nimport path from 'path';\n\ndeclare global {\n var mfHashMap: Record<string, string> | undefined;\n var moduleGraphDirty: boolean;\n}\n\nconst getRequire = (): NodeRequire => {\n //@ts-ignore\n return typeof __non_webpack_require__ !== 'undefined'\n ? (__non_webpack_require__ as NodeRequire)\n : eval('require');\n};\n\nfunction callsites(): any[] {\n const _prepareStackTrace = Error.prepareStackTrace;\n try {\n let result: any[] = [];\n Error.prepareStackTrace = (_, callSites) => {\n const callSitesWithoutCurrent = callSites.slice(1);\n result = callSitesWithoutCurrent;\n return callSitesWithoutCurrent;\n };\n\n new Error().stack;\n return result;\n } finally {\n Error.prepareStackTrace = _prepareStackTrace;\n }\n}\n\nconst find = function (moduleName: string): string | undefined {\n if (moduleName[0] === '.') {\n // Use custom callsites function\n const stack = callsites();\n for (const frame of stack) {\n const filename = frame.getFileName();\n if (filename && filename !== module.filename) {\n moduleName = path.resolve(path.dirname(filename), moduleName);\n break;\n }\n }\n }\n try {\n return getRequire().resolve(moduleName);\n } catch (e) {\n return;\n }\n};\n\n/**\n * Removes a module from the cache. We need this to re-load our http_request !\n * see: https://stackoverflow.com/a/14801711/1148249\n */\nconst decache = async function (moduleName: string) {\n //@ts-ignore\n moduleName = find(moduleName);\n\n if (!moduleName) {\n return;\n }\n\n const currentChunk = getRequire().cache[__filename];\n\n // Run over the cache looking for the files\n // loaded by the specified module name\n searchCache(moduleName, function (mod: NodeModule) {\n delete getRequire().cache[mod.id];\n });\n try {\n // Remove cached paths to the module.\n // Thanks to @bentael for pointing this out.\n //@ts-ignore\n Object.keys((currentChunk.constructor as any)._pathCache).forEach(\n function (cacheKey) {\n if (cacheKey.indexOf(moduleName) > -1) {\n //@ts-ignore\n delete (currentChunk.constructor as any)._pathCache[cacheKey];\n }\n },\n );\n } catch (error) {\n //null\n }\n};\n\n/**\n * Runs over the cache to search for all the cached\n * files\n */\nconst searchCache = function (\n moduleName: string,\n callback: (mod: NodeModule) => void,\n) {\n // Resolve the module identified by the specified name\n let mod = getRequire().resolve(moduleName);\n const visited: Record<string, boolean> = {};\n\n // Check if the module has been resolved and found within\n // the cache no else so #ignore else https://git.io/vtgMI\n /* istanbul ignore else */\n //@ts-ignore\n if (mod && (mod = getRequire().cache[mod]) !== undefined) {\n // Recursively go over the results\n (function run(current: NodeModule) {\n visited[current.id] = true;\n // Go over each of the module's children and\n // run over it\n current.children.forEach(function (child: NodeModule) {\n // ignore .node files, decaching native modules throws a\n // \"module did not self-register\" error on second require\n if (path.extname(child.filename) !== '.node' && !visited[child.id]) {\n run(child);\n }\n });\n\n // Call the specified callback providing the\n // found module\n callback(current);\n //@ts-ignore\n })(mod);\n }\n};\n\nglobalThis.moduleGraphDirty = false;\n\nconst hashmap = globalThis.mfHashMap || ({} as Record<string, string>);\nglobalThis.moduleGraphDirty = false;\n\nconst requireCacheRegex =\n /(remote|server|hot-reload|react-loadable-manifest|runtime|styled-jsx)/;\n\nexport const performReload = async (\n shouldReload: boolean,\n): Promise<boolean> => {\n if (!shouldReload) {\n return false;\n }\n\n const req = getRequire();\n\n const gs = new Function('return globalThis')();\n const entries: Set<string> = gs.entryChunkCache || new Set();\n\n //@ts-ignore\n gs.__FEDERATION__.__INSTANCES__.map((i: any) => {\n //@ts-ignore\n i.moduleCache.forEach((mc: any) => {\n if (mc.remoteInfo && mc.remoteInfo.entryGlobalName) {\n delete gs[mc.remoteInfo.entryGlobalName];\n }\n });\n i.moduleCache.clear();\n if (gs[i.name]) {\n delete gs[i.name];\n }\n });\n //@ts-ignore\n __webpack_require__?.federation?.instance?.moduleCache?.clear();\n helpers.global.resetFederationGlobalInfo();\n globalThis.moduleGraphDirty = false;\n globalThis.mfHashMap = {};\n\n if (!entries) {\n Object.keys(req.cache).forEach((key) => {\n if (requireCacheRegex.test(key)) {\n decache(key); // Use decache here\n }\n });\n } else {\n for (const entry of entries) {\n decache(entry);\n //reload entries again\n await getRequire()(entry);\n }\n }\n\n return true;\n};\n\nexport const checkUnreachableRemote = (remoteScope: any): boolean => {\n for (const property in remoteScope.remotes) {\n if (!remoteScope[property]) {\n console.error(\n 'unreachable remote found',\n property,\n 'hot reloading to refetch',\n );\n return true;\n }\n }\n return false;\n};\n\nexport const checkMedusaConfigChange = (\n remoteScope: any,\n fetchModule: any,\n): boolean => {\n //@ts-ignore\n if (remoteScope._medusa) {\n //@ts-ignore\n for (const property in remoteScope._medusa) {\n fetchModule(property)\n .then((res: Response) => res.json())\n .then((medusaResponse: any): void | boolean => {\n if (\n medusaResponse.version !==\n //@ts-ignore\n remoteScope?._medusa[property].version\n ) {\n console.log(\n 'medusa config changed',\n property,\n 'hot reloading to refetch',\n );\n performReload(true);\n return true;\n }\n });\n }\n }\n return false;\n};\n\nexport const checkFakeRemote = (remoteScope: any): boolean => {\n for (const property in remoteScope._config) {\n let remote = remoteScope._config[property];\n\n const resolveRemote = async () => {\n remote = await remote();\n };\n\n if (typeof remote === 'function') {\n resolveRemote();\n }\n\n if (remote.fake) {\n console.log('fake remote found', property, 'hot reloading to refetch');\n return true;\n }\n }\n return false;\n};\n\nexport const createFetcher = (\n url: string,\n fetchModule: any,\n name: string,\n cb: (hash: string) => void,\n): Promise<void | boolean> => {\n return fetchModule(url)\n .then((re: Response) => {\n if (!re.ok) {\n throw new Error(\n `Error loading remote: status: ${\n re.status\n }, content-type: ${re.headers.get('content-type')}`,\n );\n }\n return re.text();\n })\n .then((contents: string): void | boolean => {\n const hash = crypto.createHash('md5').update(contents).digest('hex');\n cb(hash);\n })\n .catch((e: Error) => {\n console.error('Remote', name, url, 'Failed to load or is not online', e);\n });\n};\n\nexport const fetchRemote = (\n remoteScope: any,\n fetchModule: any,\n): Promise<boolean> => {\n const fetches: Promise<void | boolean>[] = [];\n let needReload = false;\n for (const property in remoteScope) {\n const name = property;\n const container = remoteScope[property];\n const url = container.entry;\n const fetcher = createFetcher(url, fetchModule, name, (hash) => {\n if (hashmap[name]) {\n if (hashmap[name] !== hash) {\n hashmap[name] = hash;\n needReload = true;\n console.log(name, 'hash is different - must hot reload server');\n }\n } else {\n hashmap[name] = hash;\n }\n });\n\n fetches.push(fetcher);\n }\n return Promise.all(fetches).then(() => {\n return needReload;\n });\n};\n//@ts-ignore\nexport const revalidate = async (\n fetchModule: any = getFetchModule() || (() => {}),\n force: boolean = false,\n): Promise<boolean> => {\n if (globalThis.moduleGraphDirty) {\n force = true;\n }\n const remotesFromAPI = getAllKnownRemotes();\n //@ts-ignore\n return new Promise((res) => {\n if (force) {\n if (Object.keys(hashmap).length !== 0) {\n res(true);\n return;\n }\n }\n if (checkMedusaConfigChange(remotesFromAPI, fetchModule)) {\n res(true);\n }\n\n if (checkFakeRemote(remotesFromAPI)) {\n res(true);\n }\n\n fetchRemote(remotesFromAPI, fetchModule).then((val) => {\n res(val);\n });\n }).then((shouldReload: unknown) => {\n return performReload(shouldReload as boolean);\n });\n};\n\nexport function getFetchModule(): any {\n //@ts-ignore\n const loadedModule =\n //@ts-ignore\n globalThis.webpackChunkLoad || global.webpackChunkLoad || global.fetch;\n if (loadedModule) {\n return loadedModule;\n }\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const nodeFetch = require('node-fetch');\n return nodeFetch.default || nodeFetch;\n}\n"],"mappings":";;;;;;;;;;;AAUA,MAAM,mBAAgC;AAEpC,QAAO,OAAO,4BAA4B,cACrC,0BACD,KAAK,UAAU;;AAGrB,SAAS,YAAmB;CAC1B,MAAM,qBAAqB,MAAM;AACjC,KAAI;EACF,IAAI,SAAgB,EAAE;AACtB,QAAM,qBAAqB,GAAG,cAAc;GAC1C,MAAM,0BAA0B,UAAU,MAAM,EAAE;AAClD,YAAS;AACT,UAAO;;AAGT,uBAAI,OAAO,EAAC;AACZ,SAAO;WACC;AACR,QAAM,oBAAoB;;;AAI9B,MAAM,OAAO,SAAU,YAAwC;AAC7D,KAAI,WAAW,OAAO,KAAK;EAEzB,MAAM,QAAQ,WAAW;AACzB,OAAK,MAAM,SAAS,OAAO;GACzB,MAAM,WAAW,MAAM,aAAa;AACpC,OAAI,YAAY,aAAa,OAAO,UAAU;AAC5C,iBAAa,aAAK,QAAQ,aAAK,QAAQ,SAAS,EAAE,WAAW;AAC7D;;;;AAIN,KAAI;AACF,SAAO,YAAY,CAAC,QAAQ,WAAW;UAChC,GAAG;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nE,KAAI,aACF,QAAO;CAGT,MAAM,YAAY,QAAQ,aAAa;AACvC,QAAO,UAAU,WAAW"}
|
|
@@ -73,6 +73,7 @@ const searchCache = function(moduleName, callback) {
|
|
|
73
73
|
callback(current);
|
|
74
74
|
})(mod);
|
|
75
75
|
};
|
|
76
|
+
globalThis.moduleGraphDirty = false;
|
|
76
77
|
const hashmap = globalThis.mfHashMap || {};
|
|
77
78
|
globalThis.moduleGraphDirty = false;
|
|
78
79
|
const requireCacheRegex = /(remote|server|hot-reload|react-loadable-manifest|runtime|styled-jsx)/;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hot-reload.mjs","names":[],"sources":["../../../src/utils/hot-reload.ts"],"sourcesContent":["import { getAllKnownRemotes } from './flush-chunks';\nimport crypto from 'crypto';\nimport helpers from '@module-federation/runtime/helpers';\nimport path from 'path';\n\ndeclare global {\n var mfHashMap: Record<string, string> | undefined;\n var moduleGraphDirty: boolean;\n}\n\nconst getRequire = (): NodeRequire => {\n //@ts-ignore\n return typeof __non_webpack_require__ !== 'undefined'\n ? (__non_webpack_require__ as NodeRequire)\n : eval('require');\n};\n\nfunction callsites(): any[] {\n const _prepareStackTrace = Error.prepareStackTrace;\n try {\n let result: any[] = [];\n Error.prepareStackTrace = (_, callSites) => {\n const callSitesWithoutCurrent = callSites.slice(1);\n result = callSitesWithoutCurrent;\n return callSitesWithoutCurrent;\n };\n\n new Error().stack;\n return result;\n } finally {\n Error.prepareStackTrace = _prepareStackTrace;\n }\n}\n\nconst find = function (moduleName: string): string | undefined {\n if (moduleName[0] === '.') {\n // Use custom callsites function\n const stack = callsites();\n for (const frame of stack) {\n const filename = frame.getFileName();\n if (filename && filename !== module.filename) {\n moduleName = path.resolve(path.dirname(filename), moduleName);\n break;\n }\n }\n }\n try {\n return getRequire().resolve(moduleName);\n } catch (e) {\n return;\n }\n};\n\n/**\n * Removes a module from the cache. We need this to re-load our http_request !\n * see: https://stackoverflow.com/a/14801711/1148249\n */\nconst decache = async function (moduleName: string) {\n //@ts-ignore\n moduleName = find(moduleName);\n\n if (!moduleName) {\n return;\n }\n\n const currentChunk = getRequire().cache[__filename];\n\n // Run over the cache looking for the files\n // loaded by the specified module name\n searchCache(moduleName, function (mod: NodeModule) {\n delete getRequire().cache[mod.id];\n });\n try {\n // Remove cached paths to the module.\n // Thanks to @bentael for pointing this out.\n //@ts-ignore\n Object.keys((currentChunk.constructor as any)._pathCache).forEach(\n function (cacheKey) {\n if (cacheKey.indexOf(moduleName) > -1) {\n //@ts-ignore\n delete (currentChunk.constructor as any)._pathCache[cacheKey];\n }\n },\n );\n } catch (error) {\n //null\n }\n};\n\n/**\n * Runs over the cache to search for all the cached\n * files\n */\nconst searchCache = function (\n moduleName: string,\n callback: (mod: NodeModule) => void,\n) {\n // Resolve the module identified by the specified name\n let mod = getRequire().resolve(moduleName);\n const visited: Record<string, boolean> = {};\n\n // Check if the module has been resolved and found within\n // the cache no else so #ignore else https://git.io/vtgMI\n /* istanbul ignore else */\n //@ts-ignore\n if (mod && (mod = getRequire().cache[mod]) !== undefined) {\n // Recursively go over the results\n (function run(current: NodeModule) {\n visited[current.id] = true;\n // Go over each of the module's children and\n // run over it\n current.children.forEach(function (child: NodeModule) {\n // ignore .node files, decaching native modules throws a\n // \"module did not self-register\" error on second require\n if (path.extname(child.filename) !== '.node' && !visited[child.id]) {\n run(child);\n }\n });\n\n // Call the specified callback providing the\n // found module\n callback(current);\n //@ts-ignore\n })(mod);\n }\n};\n\nconst hashmap = globalThis.mfHashMap || ({} as Record<string, string>);\nglobalThis.moduleGraphDirty = false;\n\nconst requireCacheRegex =\n /(remote|server|hot-reload|react-loadable-manifest|runtime|styled-jsx)/;\n\nexport const performReload = async (\n shouldReload: boolean,\n): Promise<boolean> => {\n if (!shouldReload) {\n return false;\n }\n\n const req = getRequire();\n\n const gs = new Function('return globalThis')();\n const entries: Set<string> = gs.entryChunkCache || new Set();\n\n //@ts-ignore\n gs.__FEDERATION__.__INSTANCES__.map((i: any) => {\n //@ts-ignore\n i.moduleCache.forEach((mc: any) => {\n if (mc.remoteInfo && mc.remoteInfo.entryGlobalName) {\n delete gs[mc.remoteInfo.entryGlobalName];\n }\n });\n i.moduleCache.clear();\n if (gs[i.name]) {\n delete gs[i.name];\n }\n });\n //@ts-ignore\n __webpack_require__?.federation?.instance?.moduleCache?.clear();\n helpers.global.resetFederationGlobalInfo();\n globalThis.moduleGraphDirty = false;\n globalThis.mfHashMap = {};\n\n if (!entries) {\n Object.keys(req.cache).forEach((key) => {\n if (requireCacheRegex.test(key)) {\n decache(key); // Use decache here\n }\n });\n } else {\n for (const entry of entries) {\n decache(entry);\n //reload entries again\n await getRequire()(entry);\n }\n }\n\n return true;\n};\n\nexport const checkUnreachableRemote = (remoteScope: any): boolean => {\n for (const property in remoteScope.remotes) {\n if (!remoteScope[property]) {\n console.error(\n 'unreachable remote found',\n property,\n 'hot reloading to refetch',\n );\n return true;\n }\n }\n return false;\n};\n\nexport const checkMedusaConfigChange = (\n remoteScope: any,\n fetchModule: any,\n): boolean => {\n //@ts-ignore\n if (remoteScope._medusa) {\n //@ts-ignore\n for (const property in remoteScope._medusa) {\n fetchModule(property)\n .then((res: Response) => res.json())\n .then((medusaResponse: any): void | boolean => {\n if (\n medusaResponse.version !==\n //@ts-ignore\n remoteScope?._medusa[property].version\n ) {\n console.log(\n 'medusa config changed',\n property,\n 'hot reloading to refetch',\n );\n performReload(true);\n return true;\n }\n });\n }\n }\n return false;\n};\n\nexport const checkFakeRemote = (remoteScope: any): boolean => {\n for (const property in remoteScope._config) {\n let remote = remoteScope._config[property];\n\n const resolveRemote = async () => {\n remote = await remote();\n };\n\n if (typeof remote === 'function') {\n resolveRemote();\n }\n\n if (remote.fake) {\n console.log('fake remote found', property, 'hot reloading to refetch');\n return true;\n }\n }\n return false;\n};\n\nexport const createFetcher = (\n url: string,\n fetchModule: any,\n name: string,\n cb: (hash: string) => void,\n): Promise<void | boolean> => {\n return fetchModule(url)\n .then((re: Response) => {\n if (!re.ok) {\n throw new Error(\n `Error loading remote: status: ${\n re.status\n }, content-type: ${re.headers.get('content-type')}`,\n );\n }\n return re.text();\n })\n .then((contents: string): void | boolean => {\n const hash = crypto.createHash('md5').update(contents).digest('hex');\n cb(hash);\n })\n .catch((e: Error) => {\n console.error('Remote', name, url, 'Failed to load or is not online', e);\n });\n};\n\nexport const fetchRemote = (\n remoteScope: any,\n fetchModule: any,\n): Promise<boolean> => {\n const fetches: Promise<void | boolean>[] = [];\n let needReload = false;\n for (const property in remoteScope) {\n const name = property;\n const container = remoteScope[property];\n const url = container.entry;\n const fetcher = createFetcher(url, fetchModule, name, (hash) => {\n if (hashmap[name]) {\n if (hashmap[name] !== hash) {\n hashmap[name] = hash;\n needReload = true;\n console.log(name, 'hash is different - must hot reload server');\n }\n } else {\n hashmap[name] = hash;\n }\n });\n\n fetches.push(fetcher);\n }\n return Promise.all(fetches).then(() => {\n return needReload;\n });\n};\n//@ts-ignore\nexport const revalidate = async (\n fetchModule: any = getFetchModule() || (() => {}),\n force: boolean = false,\n): Promise<boolean> => {\n if (globalThis.moduleGraphDirty) {\n force = true;\n }\n const remotesFromAPI = getAllKnownRemotes();\n //@ts-ignore\n return new Promise((res) => {\n if (force) {\n if (Object.keys(hashmap).length !== 0) {\n res(true);\n return;\n }\n }\n if (checkMedusaConfigChange(remotesFromAPI, fetchModule)) {\n res(true);\n }\n\n if (checkFakeRemote(remotesFromAPI)) {\n res(true);\n }\n\n fetchRemote(remotesFromAPI, fetchModule).then((val) => {\n res(val);\n });\n }).then((shouldReload: unknown) => {\n return performReload(shouldReload as boolean);\n });\n};\n\nexport function getFetchModule(): any {\n //@ts-ignore\n const loadedModule =\n //@ts-ignore\n globalThis.webpackChunkLoad || global.webpackChunkLoad || global.fetch;\n if (loadedModule) {\n return loadedModule;\n }\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const nodeFetch = require('node-fetch');\n return nodeFetch.default || nodeFetch;\n}\n"],"mappings":";;;;;;;AAUA,MA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AAQ,IAAI,QAAQ,CAAC,WAAW;AACrC,SAAO;GACP;;AAGJ,MAAa,aAAa,OACxB,cAAmB,gBAAgB,WAAW,KAC9C,QAAiB,UACI;AACrB,KAAI,WAAW,iBACb,SAAQ;CAEV,MAAM,iBAAiB,oBAAoB;AAE3C,QAAO,IAAI,SAAS,QAAQ;AAC1B,MAAI,OACF;OAAI,OAAO,KAAK,QAAQ,CAAC,WAAW,GAAG;AACrC,QAAI,KAAK;AACT;;;AAGJ,MAAI,wBAAwB,gBAAgB,YAAY,CACtD,KAAI,KAAK;AAGX,MAAI,gBAAgB,eAAe,CACjC,KAAI,KAAK;AAGX,cAAY,gBAAgB,YAAY,CAAC,MAAM,QAAQ;AACrD,OAAI,IAAI;IACR;GACF,CAAC,MAAM,iBAA0B;AACjC,SAAO,cAAc,aAAwB;GAC7C;;AAGJ,SAAgB,iBAAsB;CAEpC,MAAM,eAEJ,WAAW,oBAAoB,OAAO,oBAAoB,OAAO;AACnE,KAAI,aACF,QAAO;CAGT,MAAM,sBAAoB,aAAa;AACvC,QAAO,UAAU,WAAW"}
|
|
1
|
+
{"version":3,"file":"hot-reload.mjs","names":[],"sources":["../../../src/utils/hot-reload.ts"],"sourcesContent":["import { getAllKnownRemotes } from './flush-chunks';\nimport crypto from 'crypto';\nimport helpers from '@module-federation/runtime/helpers';\nimport path from 'path';\n\ndeclare global {\n var mfHashMap: Record<string, string> | undefined;\n var moduleGraphDirty: boolean;\n}\n\nconst getRequire = (): NodeRequire => {\n //@ts-ignore\n return typeof __non_webpack_require__ !== 'undefined'\n ? (__non_webpack_require__ as NodeRequire)\n : eval('require');\n};\n\nfunction callsites(): any[] {\n const _prepareStackTrace = Error.prepareStackTrace;\n try {\n let result: any[] = [];\n Error.prepareStackTrace = (_, callSites) => {\n const callSitesWithoutCurrent = callSites.slice(1);\n result = callSitesWithoutCurrent;\n return callSitesWithoutCurrent;\n };\n\n new Error().stack;\n return result;\n } finally {\n Error.prepareStackTrace = _prepareStackTrace;\n }\n}\n\nconst find = function (moduleName: string): string | undefined {\n if (moduleName[0] === '.') {\n // Use custom callsites function\n const stack = callsites();\n for (const frame of stack) {\n const filename = frame.getFileName();\n if (filename && filename !== module.filename) {\n moduleName = path.resolve(path.dirname(filename), moduleName);\n break;\n }\n }\n }\n try {\n return getRequire().resolve(moduleName);\n } catch (e) {\n return;\n }\n};\n\n/**\n * Removes a module from the cache. We need this to re-load our http_request !\n * see: https://stackoverflow.com/a/14801711/1148249\n */\nconst decache = async function (moduleName: string) {\n //@ts-ignore\n moduleName = find(moduleName);\n\n if (!moduleName) {\n return;\n }\n\n const currentChunk = getRequire().cache[__filename];\n\n // Run over the cache looking for the files\n // loaded by the specified module name\n searchCache(moduleName, function (mod: NodeModule) {\n delete getRequire().cache[mod.id];\n });\n try {\n // Remove cached paths to the module.\n // Thanks to @bentael for pointing this out.\n //@ts-ignore\n Object.keys((currentChunk.constructor as any)._pathCache).forEach(\n function (cacheKey) {\n if (cacheKey.indexOf(moduleName) > -1) {\n //@ts-ignore\n delete (currentChunk.constructor as any)._pathCache[cacheKey];\n }\n },\n );\n } catch (error) {\n //null\n }\n};\n\n/**\n * Runs over the cache to search for all the cached\n * files\n */\nconst searchCache = function (\n moduleName: string,\n callback: (mod: NodeModule) => void,\n) {\n // Resolve the module identified by the specified name\n let mod = getRequire().resolve(moduleName);\n const visited: Record<string, boolean> = {};\n\n // Check if the module has been resolved and found within\n // the cache no else so #ignore else https://git.io/vtgMI\n /* istanbul ignore else */\n //@ts-ignore\n if (mod && (mod = getRequire().cache[mod]) !== undefined) {\n // Recursively go over the results\n (function run(current: NodeModule) {\n visited[current.id] = true;\n // Go over each of the module's children and\n // run over it\n current.children.forEach(function (child: NodeModule) {\n // ignore .node files, decaching native modules throws a\n // \"module did not self-register\" error on second require\n if (path.extname(child.filename) !== '.node' && !visited[child.id]) {\n run(child);\n }\n });\n\n // Call the specified callback providing the\n // found module\n callback(current);\n //@ts-ignore\n })(mod);\n }\n};\n\nglobalThis.moduleGraphDirty = false;\n\nconst hashmap = globalThis.mfHashMap || ({} as Record<string, string>);\nglobalThis.moduleGraphDirty = false;\n\nconst requireCacheRegex =\n /(remote|server|hot-reload|react-loadable-manifest|runtime|styled-jsx)/;\n\nexport const performReload = async (\n shouldReload: boolean,\n): Promise<boolean> => {\n if (!shouldReload) {\n return false;\n }\n\n const req = getRequire();\n\n const gs = new Function('return globalThis')();\n const entries: Set<string> = gs.entryChunkCache || new Set();\n\n //@ts-ignore\n gs.__FEDERATION__.__INSTANCES__.map((i: any) => {\n //@ts-ignore\n i.moduleCache.forEach((mc: any) => {\n if (mc.remoteInfo && mc.remoteInfo.entryGlobalName) {\n delete gs[mc.remoteInfo.entryGlobalName];\n }\n });\n i.moduleCache.clear();\n if (gs[i.name]) {\n delete gs[i.name];\n }\n });\n //@ts-ignore\n __webpack_require__?.federation?.instance?.moduleCache?.clear();\n helpers.global.resetFederationGlobalInfo();\n globalThis.moduleGraphDirty = false;\n globalThis.mfHashMap = {};\n\n if (!entries) {\n Object.keys(req.cache).forEach((key) => {\n if (requireCacheRegex.test(key)) {\n decache(key); // Use decache here\n }\n });\n } else {\n for (const entry of entries) {\n decache(entry);\n //reload entries again\n await getRequire()(entry);\n }\n }\n\n return true;\n};\n\nexport const checkUnreachableRemote = (remoteScope: any): boolean => {\n for (const property in remoteScope.remotes) {\n if (!remoteScope[property]) {\n console.error(\n 'unreachable remote found',\n property,\n 'hot reloading to refetch',\n );\n return true;\n }\n }\n return false;\n};\n\nexport const checkMedusaConfigChange = (\n remoteScope: any,\n fetchModule: any,\n): boolean => {\n //@ts-ignore\n if (remoteScope._medusa) {\n //@ts-ignore\n for (const property in remoteScope._medusa) {\n fetchModule(property)\n .then((res: Response) => res.json())\n .then((medusaResponse: any): void | boolean => {\n if (\n medusaResponse.version !==\n //@ts-ignore\n remoteScope?._medusa[property].version\n ) {\n console.log(\n 'medusa config changed',\n property,\n 'hot reloading to refetch',\n );\n performReload(true);\n return true;\n }\n });\n }\n }\n return false;\n};\n\nexport const checkFakeRemote = (remoteScope: any): boolean => {\n for (const property in remoteScope._config) {\n let remote = remoteScope._config[property];\n\n const resolveRemote = async () => {\n remote = await remote();\n };\n\n if (typeof remote === 'function') {\n resolveRemote();\n }\n\n if (remote.fake) {\n console.log('fake remote found', property, 'hot reloading to refetch');\n return true;\n }\n }\n return false;\n};\n\nexport const createFetcher = (\n url: string,\n fetchModule: any,\n name: string,\n cb: (hash: string) => void,\n): Promise<void | boolean> => {\n return fetchModule(url)\n .then((re: Response) => {\n if (!re.ok) {\n throw new Error(\n `Error loading remote: status: ${\n re.status\n }, content-type: ${re.headers.get('content-type')}`,\n );\n }\n return re.text();\n })\n .then((contents: string): void | boolean => {\n const hash = crypto.createHash('md5').update(contents).digest('hex');\n cb(hash);\n })\n .catch((e: Error) => {\n console.error('Remote', name, url, 'Failed to load or is not online', e);\n });\n};\n\nexport const fetchRemote = (\n remoteScope: any,\n fetchModule: any,\n): Promise<boolean> => {\n const fetches: Promise<void | boolean>[] = [];\n let needReload = false;\n for (const property in remoteScope) {\n const name = property;\n const container = remoteScope[property];\n const url = container.entry;\n const fetcher = createFetcher(url, fetchModule, name, (hash) => {\n if (hashmap[name]) {\n if (hashmap[name] !== hash) {\n hashmap[name] = hash;\n needReload = true;\n console.log(name, 'hash is different - must hot reload server');\n }\n } else {\n hashmap[name] = hash;\n }\n });\n\n fetches.push(fetcher);\n }\n return Promise.all(fetches).then(() => {\n return needReload;\n });\n};\n//@ts-ignore\nexport const revalidate = async (\n fetchModule: any = getFetchModule() || (() => {}),\n force: boolean = false,\n): Promise<boolean> => {\n if (globalThis.moduleGraphDirty) {\n force = true;\n }\n const remotesFromAPI = getAllKnownRemotes();\n //@ts-ignore\n return new Promise((res) => {\n if (force) {\n if (Object.keys(hashmap).length !== 0) {\n res(true);\n return;\n }\n }\n if (checkMedusaConfigChange(remotesFromAPI, fetchModule)) {\n res(true);\n }\n\n if (checkFakeRemote(remotesFromAPI)) {\n res(true);\n }\n\n fetchRemote(remotesFromAPI, fetchModule).then((val) => {\n res(val);\n });\n }).then((shouldReload: unknown) => {\n return performReload(shouldReload as boolean);\n });\n};\n\nexport function getFetchModule(): any {\n //@ts-ignore\n const loadedModule =\n //@ts-ignore\n globalThis.webpackChunkLoad || global.webpackChunkLoad || global.fetch;\n if (loadedModule) {\n return loadedModule;\n }\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const nodeFetch = require('node-fetch');\n return nodeFetch.default || nodeFetch;\n}\n"],"mappings":";;;;;;;AAUA,MAAM,mBAAgC;AAEpC,QAAO,OAAO,4BAA4B,cACrC,0BACD,KAAK,UAAU;;AAGrB,SAAS,YAAmB;CAC1B,MAAM,qBAAqB,MAAM;AACjC,KAAI;EACF,IAAI,SAAgB,EAAE;AACtB,QAAM,qBAAqB,GAAG,cAAc;GAC1C,MAAM,0BAA0B,UAAU,MAAM,EAAE;AAClD,YAAS;AACT,UAAO;;AAGT,uBAAI,OAAO,EAAC;AACZ,SAAO;WACC;AACR,QAAM,oBAAoB;;;AAI9B,MAAM,OAAO,SAAU,YAAwC;AAC7D,KAAI,WAAW,OAAO,KAAK;EAEzB,MAAM,QAAQ,WAAW;AACzB,OAAK,MAAM,SAAS,OAAO;GACzB,MAAM,WAAW,MAAM,aAAa;AACpC,OAAI,YAAY,aAAa,OAAO,UAAU;AAC5C,iBAAa,KAAK,QAAQ,KAAK,QAAQ,SAAS,EAAE,WAAW;AAC7D;;;;AAIN,KAAI;AACF,SAAO,YAAY,CAAC,QAAQ,WAAW;UAChC,GAAG;AACV;;;;;;;AAQJ,MAAM,UAAU,eAAgB,YAAoB;AAElD,cAAa,KAAK,WAAW;AAE7B,KAAI,CAAC,WACH;CAGF,MAAM,eAAe,YAAY,CAAC,MAAM;AAIxC,aAAY,YAAY,SAAU,KAAiB;AACjD,SAAO,YAAY,CAAC,MAAM,IAAI;GAC9B;AACF,KAAI;AAIF,SAAO,KAAM,aAAa,YAAoB,WAAW,CAAC,QACxD,SAAU,UAAU;A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
7
7
|
"module": "./dist/src/index.mjs",
|
|
@@ -111,9 +111,10 @@
|
|
|
111
111
|
"btoa": "1.2.1",
|
|
112
112
|
"encoding": "^0.1.13",
|
|
113
113
|
"node-fetch": "2.7.0",
|
|
114
|
-
"
|
|
115
|
-
"@module-federation/enhanced": "2.1
|
|
116
|
-
"@module-federation/
|
|
114
|
+
"tapable": "2.3.0",
|
|
115
|
+
"@module-federation/enhanced": "2.2.1",
|
|
116
|
+
"@module-federation/sdk": "2.2.1",
|
|
117
|
+
"@module-federation/runtime": "2.2.1"
|
|
117
118
|
},
|
|
118
119
|
"peerDependencies": {
|
|
119
120
|
"webpack": "^5.40.0"
|
|
@@ -122,5 +123,11 @@
|
|
|
122
123
|
"webpack": {
|
|
123
124
|
"optional": true
|
|
124
125
|
}
|
|
126
|
+
},
|
|
127
|
+
"scripts": {
|
|
128
|
+
"build": "tsdown --config tsdown.config.mts",
|
|
129
|
+
"lint": "ESLINT_USE_FLAT_CONFIG=false pnpm exec eslint --ignore-pattern node_modules \"**/*.js\" \"**/*.ts\"",
|
|
130
|
+
"test": "pnpm exec jest --config jest.config.js --passWithNoTests",
|
|
131
|
+
"pre-release": "pnpm run test && pnpm run build && rm -f ./dist/package.json"
|
|
125
132
|
}
|
|
126
133
|
}
|