@module-federation/nextjs-mf 8.8.69 → 8.8.71
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/client/UrlNode.d.mts +17 -0
- package/dist/client/UrlNode.d.ts +17 -0
- package/dist/node.d.mts +1 -0
- package/dist/node.d.ts +1 -0
- package/dist/src/federation-noop.d.mts +0 -1
- package/dist/src/federation-noop.d.ts +0 -1
- package/dist/src/index.d.mts +3 -2
- package/dist/src/index.d.ts +3 -2
- package/dist/src/internal.d.mts +50 -0
- package/dist/src/internal.d.ts +50 -0
- package/dist/src/loaders/fixImageLoader.d.mts +3 -8
- package/dist/src/loaders/fixImageLoader.d.ts +3 -8
- package/dist/src/loaders/fixUrlLoader.d.mts +2 -5
- package/dist/src/loaders/fixUrlLoader.d.ts +2 -5
- package/dist/src/loaders/helpers.d.mts +17 -0
- package/dist/src/loaders/helpers.d.ts +17 -0
- package/dist/src/loaders/nextPageMapLoader.d.mts +5 -10
- package/dist/src/loaders/nextPageMapLoader.d.ts +5 -10
- package/dist/src/logger.d.mts +2 -0
- package/dist/src/logger.d.ts +2 -0
- package/dist/src/plugins/AddRuntimeRequirementToPromiseExternalPlugin.d.mts +5 -0
- package/dist/src/plugins/AddRuntimeRequirementToPromiseExternalPlugin.d.ts +5 -0
- package/dist/src/plugins/CopyFederationPlugin.d.mts +20 -0
- package/dist/src/plugins/CopyFederationPlugin.d.ts +20 -0
- package/dist/src/plugins/NextFederationPlugin/apply-client-plugins.d.mts +23 -0
- package/dist/src/plugins/NextFederationPlugin/apply-client-plugins.d.ts +23 -0
- package/dist/src/plugins/NextFederationPlugin/apply-server-plugins.d.mts +36 -0
- package/dist/src/plugins/NextFederationPlugin/apply-server-plugins.d.ts +36 -0
- package/dist/src/plugins/NextFederationPlugin/index.d.mts +23 -27
- package/dist/src/plugins/NextFederationPlugin/index.d.ts +23 -27
- package/dist/src/plugins/NextFederationPlugin/index.js +2 -1
- package/dist/src/plugins/NextFederationPlugin/index.js.map +1 -1
- package/dist/src/plugins/NextFederationPlugin/index.mjs +2 -1
- package/dist/src/plugins/NextFederationPlugin/index.mjs.map +1 -1
- package/dist/src/plugins/NextFederationPlugin/next-fragments.d.mts +18 -16
- package/dist/src/plugins/NextFederationPlugin/next-fragments.d.ts +18 -16
- package/dist/src/plugins/NextFederationPlugin/regex-equal.d.mts +14 -0
- package/dist/src/plugins/NextFederationPlugin/regex-equal.d.ts +14 -0
- package/dist/src/plugins/NextFederationPlugin/remove-unnecessary-shared-keys.d.mts +8 -0
- package/dist/src/plugins/NextFederationPlugin/remove-unnecessary-shared-keys.d.ts +8 -0
- package/dist/src/plugins/NextFederationPlugin/set-options.d.mts +16 -0
- package/dist/src/plugins/NextFederationPlugin/set-options.d.ts +16 -0
- package/dist/src/plugins/NextFederationPlugin/validate-options.d.mts +25 -0
- package/dist/src/plugins/NextFederationPlugin/validate-options.d.ts +25 -0
- package/dist/src/plugins/container/InvertedContainerPlugin.d.mts +5 -0
- package/dist/src/plugins/container/InvertedContainerPlugin.d.ts +5 -0
- package/dist/src/plugins/container/InvertedContainerRuntimeModule.d.mts +11 -0
- package/dist/src/plugins/container/InvertedContainerRuntimeModule.d.ts +11 -0
- package/dist/src/plugins/container/InvertedContainerRuntimeModule.js.map +1 -1
- package/dist/src/plugins/container/InvertedContainerRuntimeModule.mjs.map +1 -1
- package/dist/src/plugins/container/RemoveEagerModulesFromRuntimePlugin.d.mts +39 -0
- package/dist/src/plugins/container/RemoveEagerModulesFromRuntimePlugin.d.ts +39 -0
- package/dist/src/plugins/container/runtimePlugin.d.mts +2 -7
- package/dist/src/plugins/container/runtimePlugin.d.ts +2 -6
- package/dist/src/plugins/container/types.d.mts +2 -0
- package/dist/src/plugins/container/types.d.ts +2 -0
- package/dist/src/types.d.mts +28 -0
- package/dist/src/types.d.ts +28 -0
- package/dist/utils/flushedChunks.d.mts +5 -12
- package/dist/utils/flushedChunks.d.ts +5 -12
- package/dist/utils/index.d.mts +14 -8
- package/dist/utils/index.d.ts +14 -8
- package/package.json +10 -9
|
@@ -119,6 +119,7 @@ var NextFederationPlugin = class {
|
|
|
119
119
|
}
|
|
120
120
|
getNormalFederationPluginOptions(compiler, isServer) {
|
|
121
121
|
const defaultShared = this._extraOptions.skipSharingNextInternals ? {} : require_next_fragments.retrieveDefaultShared(isServer);
|
|
122
|
+
const manifestOptions = typeof this._options.manifest === "object" && this._options.manifest !== null ? this._options.manifest : {};
|
|
122
123
|
return {
|
|
123
124
|
...this._options,
|
|
124
125
|
runtime: false,
|
|
@@ -138,7 +139,7 @@ var NextFederationPlugin = class {
|
|
|
138
139
|
...this._options.shared
|
|
139
140
|
},
|
|
140
141
|
manifest: {
|
|
141
|
-
...
|
|
142
|
+
...manifestOptions,
|
|
142
143
|
filePath: isServer ? "" : "/static/chunks"
|
|
143
144
|
},
|
|
144
145
|
dts: this._options.dts ?? false,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["setOptions","logger","CopyFederationPlugin","ModuleFederationPlugin","validateCompilerOptions","validatePluginOptions","retrieveDefaultShared","exposeNextjsPages"],"sources":["../../../../src/plugins/NextFederationPlugin/index.ts"],"sourcesContent":["/**\n * MIT License http://www.opensource.org/licenses/mit-license.php\n * Author Zackary Jackson @ScriptedAlchemy\n * This module contains the NextFederationPlugin class which is a webpack plugin that handles Next.js application federation using Module Federation.\n */\n'use strict';\n\nimport type {\n NextFederationPluginExtraOptions,\n NextFederationPluginOptions,\n} from './next-fragments';\nimport type { Compiler, WebpackPluginInstance } from 'webpack';\nimport path from 'path';\nimport { getWebpackPath } from '@module-federation/sdk/normalize-webpack-path';\nimport CopyFederationPlugin from '../CopyFederationPlugin';\nimport { exposeNextjsPages } from '../../loaders/nextPageMapLoader';\nimport { retrieveDefaultShared, applyPathFixes } from './next-fragments';\nimport { setOptions } from './set-options';\nimport {\n validateCompilerOptions,\n validatePluginOptions,\n} from './validate-options';\nimport {\n applyServerPlugins,\n configureServerCompilerOptions,\n configureServerLibraryAndFilename,\n handleServerExternals,\n} from './apply-server-plugins';\nimport { applyClientPlugins } from './apply-client-plugins';\nimport { ModuleFederationPlugin } from '@module-federation/enhanced/webpack';\nimport { bindLoggerToCompiler } from '@module-federation/sdk';\nimport type { moduleFederationPlugin } from '@module-federation/sdk';\nimport logger from '../../logger';\n\nconst resolveRuntimePluginPath = (): string =>\n process.env.IS_ESM_BUILD === 'true'\n ? require.resolve('@module-federation/nextjs-mf/dist/src/plugins/container/runtimePlugin.mjs')\n : require.resolve('@module-federation/nextjs-mf/dist/src/plugins/container/runtimePlugin.js');\n\nconst resolveNoopPath = (): string =>\n process.env.IS_ESM_BUILD === 'true'\n ? require.resolve('@module-federation/nextjs-mf/dist/src/federation-noop.mjs')\n : require.resolve('@module-federation/nextjs-mf/dist/src/federation-noop.js');\n\nconst resolveNodeRuntimePluginPath = (): string => {\n const nodePackageRoot = path.dirname(\n require.resolve('@module-federation/node/package.json'),\n );\n\n return require.resolve(\n path.join(\n nodePackageRoot,\n process.env.IS_ESM_BUILD === 'true'\n ? 'dist/src/runtimePlugin.mjs'\n : 'dist/src/runtimePlugin.js',\n ),\n );\n};\n/**\n * NextFederationPlugin is a webpack plugin that handles Next.js application federation using Module Federation.\n */\nexport class NextFederationPlugin {\n private _options: moduleFederationPlugin.ModuleFederationPluginOptions;\n private _extraOptions: NextFederationPluginExtraOptions;\n public name: string;\n /**\n * Constructs the NextFederationPlugin with the provided options.\n *\n * @param options The options to configure the plugin.\n */\n constructor(options: NextFederationPluginOptions) {\n const { mainOptions, extraOptions } = setOptions(options);\n this._options = mainOptions;\n this._extraOptions = extraOptions;\n this.name = 'ModuleFederationPlugin';\n }\n\n /**\n * The apply method is called by the webpack compiler and allows the plugin to hook into the webpack process.\n * @param compiler The webpack compiler object.\n */\n apply(compiler: Compiler) {\n bindLoggerToCompiler(logger, compiler, 'NextFederationPlugin');\n process.env['FEDERATION_WEBPACK_PATH'] =\n process.env['FEDERATION_WEBPACK_PATH'] ||\n getWebpackPath(compiler, { framework: 'nextjs' });\n if (!this.validateOptions(compiler)) return;\n const isServer = this.isServerCompiler(compiler);\n new CopyFederationPlugin(isServer).apply(compiler);\n const normalFederationPluginOptions = this.getNormalFederationPluginOptions(\n compiler,\n isServer,\n );\n this._options = normalFederationPluginOptions;\n this.applyConditionalPlugins(compiler, isServer);\n\n new ModuleFederationPlugin(normalFederationPluginOptions).apply(compiler);\n\n const noop = this.getNoopPath();\n\n if (!this._extraOptions.skipSharingNextInternals) {\n compiler.hooks.make.tapAsync(\n 'NextFederationPlugin',\n (compilation, callback) => {\n const dep = compiler.webpack.EntryPlugin.createDependency(\n noop,\n 'noop',\n );\n compilation.addEntry(\n compiler.context,\n dep,\n { name: 'noop' },\n (err, module) => {\n if (err) {\n return callback(err);\n }\n callback();\n },\n );\n },\n );\n }\n\n if (!compiler.options.ignoreWarnings) {\n compiler.options.ignoreWarnings = [\n //@ts-ignore\n (message) => /your target environment does not appear/.test(message),\n ];\n }\n }\n\n private validateOptions(compiler: Compiler): boolean {\n const manifestPlugin = compiler.options.plugins.find(\n (p): p is WebpackPluginInstance =>\n p?.constructor?.name === 'BuildManifestPlugin',\n );\n\n if (manifestPlugin) {\n //@ts-ignore\n if (manifestPlugin?.appDirEnabled) {\n throw new Error(\n 'App Directory is not supported by nextjs-mf. Use only pages directory, do not open git issues about this',\n );\n }\n }\n\n const compilerValid = validateCompilerOptions(compiler);\n const pluginValid = validatePluginOptions(this._options);\n const envValid = process.env['NEXT_PRIVATE_LOCAL_WEBPACK'];\n if (compilerValid === undefined) logger.error('Compiler validation failed');\n if (pluginValid === undefined) logger.error('Plugin validation failed');\n const validCompilerTarget =\n compiler.options.name === 'server' || compiler.options.name === 'client';\n if (!envValid)\n throw new Error(\n 'process.env.NEXT_PRIVATE_LOCAL_WEBPACK is not set to true, please set it to true, and \"npm install webpack\"',\n );\n return (\n compilerValid !== undefined &&\n pluginValid !== undefined &&\n validCompilerTarget\n );\n }\n\n private isServerCompiler(compiler: Compiler): boolean {\n return compiler.options.name === 'server';\n }\n\n private applyConditionalPlugins(compiler: Compiler, isServer: boolean) {\n compiler.options.output.uniqueName = this._options.name;\n compiler.options.output.environment = {\n ...compiler.options.output.environment,\n asyncFunction: true,\n };\n\n // Add layer rules for resource queries\n if (!compiler.options.module.rules) {\n compiler.options.module.rules = [];\n }\n\n // Add layer rules for RSC, client and SSR\n compiler.options.module.rules.push({\n resourceQuery: /\\?rsc/,\n layer: 'rsc',\n });\n\n compiler.options.module.rules.push({\n resourceQuery: /\\?client/,\n layer: 'client',\n });\n\n compiler.options.module.rules.push({\n resourceQuery: /\\?ssr/,\n layer: 'ssr',\n });\n\n applyPathFixes(compiler, this._options, this._extraOptions);\n if (this._extraOptions.debug) {\n compiler.options.devtool = false;\n }\n\n if (isServer) {\n configureServerCompilerOptions(compiler);\n configureServerLibraryAndFilename(this._options);\n applyServerPlugins(compiler, this._options);\n handleServerExternals(compiler, {\n ...this._options,\n shared: { ...retrieveDefaultShared(isServer), ...this._options.shared },\n });\n } else {\n applyClientPlugins(compiler, this._options, this._extraOptions);\n }\n }\n\n private getNormalFederationPluginOptions(\n compiler: Compiler,\n isServer: boolean,\n ): moduleFederationPlugin.ModuleFederationPluginOptions {\n const defaultShared = this._extraOptions.skipSharingNextInternals\n ? {}\n : retrieveDefaultShared(isServer);\n\n return {\n ...this._options,\n runtime: false,\n remoteType: 'script',\n runtimePlugins: [\n ...(isServer ? [resolveNodeRuntimePluginPath()] : []),\n resolveRuntimePluginPath(),\n ...(this._options.runtimePlugins || []),\n ].map((plugin) => plugin + '?runtimePlugin'),\n //@ts-ignore\n exposes: {\n ...this._options.exposes,\n ...(this._extraOptions.exposePages\n ? exposeNextjsPages(compiler.options.context as string)\n : {}),\n },\n remotes: {\n ...this._options.remotes,\n },\n shared: {\n ...defaultShared,\n ...this._options.shared,\n },\n manifest: {\n ...(this._options.manifest ?? {}),\n filePath: isServer ? '' : '/static/chunks',\n },\n // nextjs project needs to add config.watchOptions = ['**/node_modules/**', '**/@mf-types/**'] to prevent loop types update\n dts: this._options.dts ?? false,\n shareStrategy: this._options.shareStrategy ?? 'loaded-first',\n experiments: {\n asyncStartup: true,\n },\n };\n }\n\n private getNoopPath(): string {\n return resolveNoopPath();\n }\n}\n\nexport default NextFederationPlugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAkCA,MAAM,iCAGA,QAAQ,QAAQ,2EAA2E;AAEjG,MAAM,wBAGA,QAAQ,QAAQ,2DAA2D;AAEjF,MAAM,qCAA6C;CACjD,MAAM,kBAAkB,aAAK,QAC3B,QAAQ,QAAQ,uCAAuC,CACxD;AAED,QAAO,QAAQ,QACb,aAAK,KACH,iBAGI,4BACL,CACF;;;;;AAKH,IAAa,uBAAb,MAAkC;;;;;;CAShC,YAAY,SAAsC;EAChD,MAAM,EAAE,aAAa,iBAAiBA,+BAAW,QAAQ;AACzD,OAAK,WAAW;AAChB,OAAK,gBAAgB;AACrB,OAAK,OAAO;;;;;;CAOd,MAAM,UAAoB;AACxB,mDAAqBC,wBAAQ,UAAU,uBAAuB;AAC9D,UAAQ,IAAI,6BACV,QAAQ,IAAI,gGACG,UAAU,EAAE,WAAW,UAAU,CAAC;AACnD,MAAI,CAAC,KAAK,gBAAgB,SAAS,CAAE;EACrC,MAAM,WAAW,KAAK,iBAAiB,SAAS;AAChD,MAAIC,qCAAqB,SAAS,CAAC,MAAM,SAAS;EAClD,MAAM,gCAAgC,KAAK,iCACzC,UACA,SACD;AACD,OAAK,WAAW;AAChB,OAAK,wBAAwB,UAAU,SAAS;AAEhD,MAAIC,2DAAuB,8BAA8B,CAAC,MAAM,SAAS;EAEzE,MAAM,OAAO,KAAK,aAAa;AAE/B,MAAI,CAAC,KAAK,cAAc,yBACtB,UAAS,MAAM,KAAK,SAClB,yBACC,aAAa,aAAa;GACzB,MAAM,MAAM,SAAS,QAAQ,YAAY,iBACvC,MACA,OACD;AACD,eAAY,SACV,SAAS,SACT,KACA,EAAE,MAAM,Q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wCAAe,UAAU,KAAK,UAAU,KAAK,cAAc;AAC3D,MAAI,KAAK,cAAc,MACrB,UAAS,QAAQ,UAAU;AAG7B,MAAI,UAAU;AACZ,+DAA+B,SAAS;AACxC,kEAAkC,KAAK,SAAS;AAChD,mDAAmB,UAAU,KAAK,SAAS;AAC3C,sDAAsB,UAAU;IAC9B,GAAG,KAAK;IACR,QAAQ;KAAE,GAAGC,6CAAsB,SAAS;KAAE,GAAG,KAAK,SAAS;KAAQ;IACxE,CAAC;QAEF,iDAAmB,UAAU,KAAK,UAAU,KAAK,cAAc;;CAInE,AAAQ,iCACN,UACA,UACsD;EACtD,MAAM,gBAAgB,KAAK,cAAc,2BACrC,EAAE,GACFA,6CAAsB,SAAS;AAEnC,SAAO;GACL,GAAG,KAAK;GACR,SAAS;GACT,YAAY;GACZ,gBAAgB;IACd,GAAI,WAAW,CAAC,8BAA8B,CAAC,GAAG,EAAE;IACpD,0BAA0B;IAC1B,GAAI,KAAK,SAAS,kBAAkB,EAAE;IACvC,CAAC,KAAK,WAAW,SAAS,iBAAiB;GAE5C,SAAS;IACP,GAAG,KAAK,SAAS;IACjB,GAAI,KAAK,cAAc,cACnBC,wDAAkB,SAAS,QAAQ,QAAkB,GACrD,EAAE;IACP;GACD,SAAS,EACP,GAAG,KAAK,SAAS,SAClB;GACD,QAAQ;IACN,GAAG;IACH,GAAG,KAAK,SAAS;IAClB;GACD,UAAU;IACR,GAAI,KAAK,SAAS,YAAY,EAAE;IAChC,UAAU,WAAW,KAAK;IAC3B;GAED,KAAK,KAAK,SAAS,OAAO;GAC1B,eAAe,KAAK,SAAS,iBAAiB;GAC9C,aAAa,EACX,cAAc,MACf;GACF;;CAGH,AAAQ,cAAsB;AAC5B,SAAO,iBAAiB"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["setOptions","logger","CopyFederationPlugin","ModuleFederationPlugin","validateCompilerOptions","validatePluginOptions","retrieveDefaultShared","exposeNextjsPages"],"sources":["../../../../src/plugins/NextFederationPlugin/index.ts"],"sourcesContent":["/**\n * MIT License http://www.opensource.org/licenses/mit-license.php\n * Author Zackary Jackson @ScriptedAlchemy\n * This module contains the NextFederationPlugin class which is a webpack plugin that handles Next.js application federation using Module Federation.\n */\n'use strict';\n\nimport type {\n NextFederationPluginExtraOptions,\n NextFederationPluginOptions,\n} from './next-fragments';\nimport type { Compiler, WebpackPluginInstance } from 'webpack';\nimport path from 'path';\nimport { getWebpackPath } from '@module-federation/sdk/normalize-webpack-path';\nimport CopyFederationPlugin from '../CopyFederationPlugin';\nimport { exposeNextjsPages } from '../../loaders/nextPageMapLoader';\nimport { retrieveDefaultShared, applyPathFixes } from './next-fragments';\nimport { setOptions } from './set-options';\nimport {\n validateCompilerOptions,\n validatePluginOptions,\n} from './validate-options';\nimport {\n applyServerPlugins,\n configureServerCompilerOptions,\n configureServerLibraryAndFilename,\n handleServerExternals,\n} from './apply-server-plugins';\nimport { applyClientPlugins } from './apply-client-plugins';\nimport { ModuleFederationPlugin } from '@module-federation/enhanced/webpack';\nimport { bindLoggerToCompiler } from '@module-federation/sdk';\nimport type { moduleFederationPlugin } from '@module-federation/sdk';\nimport logger from '../../logger';\n\nconst resolveRuntimePluginPath = (): string =>\n process.env.IS_ESM_BUILD === 'true'\n ? require.resolve('@module-federation/nextjs-mf/dist/src/plugins/container/runtimePlugin.mjs')\n : require.resolve('@module-federation/nextjs-mf/dist/src/plugins/container/runtimePlugin.js');\n\nconst resolveNoopPath = (): string =>\n process.env.IS_ESM_BUILD === 'true'\n ? require.resolve('@module-federation/nextjs-mf/dist/src/federation-noop.mjs')\n : require.resolve('@module-federation/nextjs-mf/dist/src/federation-noop.js');\n\nconst resolveNodeRuntimePluginPath = (): string => {\n const nodePackageRoot = path.dirname(\n require.resolve('@module-federation/node/package.json'),\n );\n\n return require.resolve(\n path.join(\n nodePackageRoot,\n process.env.IS_ESM_BUILD === 'true'\n ? 'dist/src/runtimePlugin.mjs'\n : 'dist/src/runtimePlugin.js',\n ),\n );\n};\n/**\n * NextFederationPlugin is a webpack plugin that handles Next.js application federation using Module Federation.\n */\nexport class NextFederationPlugin {\n private _options: moduleFederationPlugin.ModuleFederationPluginOptions;\n private _extraOptions: NextFederationPluginExtraOptions;\n public name: string;\n /**\n * Constructs the NextFederationPlugin with the provided options.\n *\n * @param options The options to configure the plugin.\n */\n constructor(options: NextFederationPluginOptions) {\n const { mainOptions, extraOptions } = setOptions(options);\n this._options = mainOptions;\n this._extraOptions = extraOptions;\n this.name = 'ModuleFederationPlugin';\n }\n\n /**\n * The apply method is called by the webpack compiler and allows the plugin to hook into the webpack process.\n * @param compiler The webpack compiler object.\n */\n apply(compiler: Compiler) {\n bindLoggerToCompiler(logger, compiler, 'NextFederationPlugin');\n process.env['FEDERATION_WEBPACK_PATH'] =\n process.env['FEDERATION_WEBPACK_PATH'] ||\n getWebpackPath(compiler, { framework: 'nextjs' });\n if (!this.validateOptions(compiler)) return;\n const isServer = this.isServerCompiler(compiler);\n new CopyFederationPlugin(isServer).apply(compiler);\n const normalFederationPluginOptions = this.getNormalFederationPluginOptions(\n compiler,\n isServer,\n );\n this._options = normalFederationPluginOptions;\n this.applyConditionalPlugins(compiler, isServer);\n\n new ModuleFederationPlugin(normalFederationPluginOptions).apply(compiler);\n\n const noop = this.getNoopPath();\n\n if (!this._extraOptions.skipSharingNextInternals) {\n compiler.hooks.make.tapAsync(\n 'NextFederationPlugin',\n (compilation, callback) => {\n const dep = compiler.webpack.EntryPlugin.createDependency(\n noop,\n 'noop',\n );\n compilation.addEntry(\n compiler.context,\n dep,\n { name: 'noop' },\n (err, module) => {\n if (err) {\n return callback(err);\n }\n callback();\n },\n );\n },\n );\n }\n\n if (!compiler.options.ignoreWarnings) {\n compiler.options.ignoreWarnings = [\n //@ts-ignore\n (message) => /your target environment does not appear/.test(message),\n ];\n }\n }\n\n private validateOptions(compiler: Compiler): boolean {\n const manifestPlugin = compiler.options.plugins.find(\n (p): p is WebpackPluginInstance =>\n p?.constructor?.name === 'BuildManifestPlugin',\n );\n\n if (manifestPlugin) {\n //@ts-ignore\n if (manifestPlugin?.appDirEnabled) {\n throw new Error(\n 'App Directory is not supported by nextjs-mf. Use only pages directory, do not open git issues about this',\n );\n }\n }\n\n const compilerValid = validateCompilerOptions(compiler);\n const pluginValid = validatePluginOptions(this._options);\n const envValid = process.env['NEXT_PRIVATE_LOCAL_WEBPACK'];\n if (compilerValid === undefined) logger.error('Compiler validation failed');\n if (pluginValid === undefined) logger.error('Plugin validation failed');\n const validCompilerTarget =\n compiler.options.name === 'server' || compiler.options.name === 'client';\n if (!envValid)\n throw new Error(\n 'process.env.NEXT_PRIVATE_LOCAL_WEBPACK is not set to true, please set it to true, and \"npm install webpack\"',\n );\n return (\n compilerValid !== undefined &&\n pluginValid !== undefined &&\n validCompilerTarget\n );\n }\n\n private isServerCompiler(compiler: Compiler): boolean {\n return compiler.options.name === 'server';\n }\n\n private applyConditionalPlugins(compiler: Compiler, isServer: boolean) {\n compiler.options.output.uniqueName = this._options.name;\n compiler.options.output.environment = {\n ...compiler.options.output.environment,\n asyncFunction: true,\n };\n\n // Add layer rules for resource queries\n if (!compiler.options.module.rules) {\n compiler.options.module.rules = [];\n }\n\n // Add layer rules for RSC, client and SSR\n compiler.options.module.rules.push({\n resourceQuery: /\\?rsc/,\n layer: 'rsc',\n });\n\n compiler.options.module.rules.push({\n resourceQuery: /\\?client/,\n layer: 'client',\n });\n\n compiler.options.module.rules.push({\n resourceQuery: /\\?ssr/,\n layer: 'ssr',\n });\n\n applyPathFixes(compiler, this._options, this._extraOptions);\n if (this._extraOptions.debug) {\n compiler.options.devtool = false;\n }\n\n if (isServer) {\n configureServerCompilerOptions(compiler);\n configureServerLibraryAndFilename(this._options);\n applyServerPlugins(compiler, this._options);\n handleServerExternals(compiler, {\n ...this._options,\n shared: { ...retrieveDefaultShared(isServer), ...this._options.shared },\n });\n } else {\n applyClientPlugins(compiler, this._options, this._extraOptions);\n }\n }\n\n private getNormalFederationPluginOptions(\n compiler: Compiler,\n isServer: boolean,\n ): moduleFederationPlugin.ModuleFederationPluginOptions {\n const defaultShared = this._extraOptions.skipSharingNextInternals\n ? {}\n : retrieveDefaultShared(isServer);\n const manifestOptions =\n typeof this._options.manifest === 'object' &&\n this._options.manifest !== null\n ? this._options.manifest\n : {};\n\n return {\n ...this._options,\n runtime: false,\n remoteType: 'script',\n runtimePlugins: [\n ...(isServer ? [resolveNodeRuntimePluginPath()] : []),\n resolveRuntimePluginPath(),\n ...(this._options.runtimePlugins || []),\n ].map((plugin) => plugin + '?runtimePlugin'),\n //@ts-ignore\n exposes: {\n ...this._options.exposes,\n ...(this._extraOptions.exposePages\n ? exposeNextjsPages(compiler.options.context as string)\n : {}),\n },\n remotes: {\n ...this._options.remotes,\n },\n shared: {\n ...defaultShared,\n ...(this._options.shared as Record<string, unknown>),\n },\n manifest: {\n ...manifestOptions,\n filePath: isServer ? '' : '/static/chunks',\n },\n // nextjs project needs to add config.watchOptions = ['**/node_modules/**', '**/@mf-types/**'] to prevent loop types update\n dts: this._options.dts ?? false,\n shareStrategy: this._options.shareStrategy ?? 'loaded-first',\n experiments: {\n asyncStartup: true,\n },\n };\n }\n\n private getNoopPath(): string {\n return resolveNoopPath();\n }\n}\n\nexport default NextFederationPlugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAkCA,MAAM,iCAGA,QAAQ,QAAQ,2EAA2E;AAEjG,MAAM,wBAGA,QAAQ,QAAQ,2DAA2D;AAEjF,MAAM,qCAA6C;CACjD,MAAM,kBAAkB,aAAK,QAC3B,QAAQ,QAAQ,uCAAuC,CACxD;AAED,QAAO,QAAQ,QACb,aAAK,KACH,iBAGI,4BACL,CACF;;;;;AAKH,IAAa,uBAAb,MAAkC;;;;;;CAShC,YAAY,SAAsC;EAChD,MAAM,EAAE,aAAa,iBAAiBA,+BAAW,QAAQ;AACzD,OAAK,WAAW;AAChB,OAAK,gBAAgB;AACrB,OAAK,OAAO;;;;;;CAOd,MAAM,UAAoB;AACxB,mDAAqBC,wB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,EAAE;IACpD,0BAA0B;IAC1B,GAAI,KAAK,SAAS,kBAAkB,EAAE;IACvC,CAAC,KAAK,WAAW,SAAS,iBAAiB;GAE5C,SAAS;IACP,GAAG,KAAK,SAAS;IACjB,GAAI,KAAK,cAAc,cACnBC,wDAAkB,SAAS,QAAQ,QAAkB,GACrD,EAAE;IACP;GACD,SAAS,EACP,GAAG,KAAK,SAAS,SAClB;GACD,QAAQ;IACN,GAAG;IACH,GAAI,KAAK,SAAS;IACnB;GACD,UAAU;IACR,GAAG;IACH,UAAU,WAAW,KAAK;IAC3B;GAED,KAAK,KAAK,SAAS,OAAO;GAC1B,eAAe,KAAK,SAAS,iBAAiB;GAC9C,aAAa,EACX,cAAc,MACf;GACF;;CAGH,AAAQ,cAAsB;AAC5B,SAAO,iBAAiB"}
|
|
@@ -116,6 +116,7 @@ var NextFederationPlugin = class {
|
|
|
116
116
|
}
|
|
117
117
|
getNormalFederationPluginOptions(compiler, isServer) {
|
|
118
118
|
const defaultShared = this._extraOptions.skipSharingNextInternals ? {} : retrieveDefaultShared(isServer);
|
|
119
|
+
const manifestOptions = typeof this._options.manifest === "object" && this._options.manifest !== null ? this._options.manifest : {};
|
|
119
120
|
return {
|
|
120
121
|
...this._options,
|
|
121
122
|
runtime: false,
|
|
@@ -135,7 +136,7 @@ var NextFederationPlugin = class {
|
|
|
135
136
|
...this._options.shared
|
|
136
137
|
},
|
|
137
138
|
manifest: {
|
|
138
|
-
...
|
|
139
|
+
...manifestOptions,
|
|
139
140
|
filePath: isServer ? "" : "/static/chunks"
|
|
140
141
|
},
|
|
141
142
|
dts: this._options.dts ?? false,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["CopyFederationPlugin"],"sources":["../../../../src/plugins/NextFederationPlugin/index.ts"],"sourcesContent":["/**\n * MIT License http://www.opensource.org/licenses/mit-license.php\n * Author Zackary Jackson @ScriptedAlchemy\n * This module contains the NextFederationPlugin class which is a webpack plugin that handles Next.js application federation using Module Federation.\n */\n'use strict';\n\nimport type {\n NextFederationPluginExtraOptions,\n NextFederationPluginOptions,\n} from './next-fragments';\nimport type { Compiler, WebpackPluginInstance } from 'webpack';\nimport path from 'path';\nimport { getWebpackPath } from '@module-federation/sdk/normalize-webpack-path';\nimport CopyFederationPlugin from '../CopyFederationPlugin';\nimport { exposeNextjsPages } from '../../loaders/nextPageMapLoader';\nimport { retrieveDefaultShared, applyPathFixes } from './next-fragments';\nimport { setOptions } from './set-options';\nimport {\n validateCompilerOptions,\n validatePluginOptions,\n} from './validate-options';\nimport {\n applyServerPlugins,\n configureServerCompilerOptions,\n configureServerLibraryAndFilename,\n handleServerExternals,\n} from './apply-server-plugins';\nimport { applyClientPlugins } from './apply-client-plugins';\nimport { ModuleFederationPlugin } from '@module-federation/enhanced/webpack';\nimport { bindLoggerToCompiler } from '@module-federation/sdk';\nimport type { moduleFederationPlugin } from '@module-federation/sdk';\nimport logger from '../../logger';\n\nconst resolveRuntimePluginPath = (): string =>\n process.env.IS_ESM_BUILD === 'true'\n ? require.resolve('@module-federation/nextjs-mf/dist/src/plugins/container/runtimePlugin.mjs')\n : require.resolve('@module-federation/nextjs-mf/dist/src/plugins/container/runtimePlugin.js');\n\nconst resolveNoopPath = (): string =>\n process.env.IS_ESM_BUILD === 'true'\n ? require.resolve('@module-federation/nextjs-mf/dist/src/federation-noop.mjs')\n : require.resolve('@module-federation/nextjs-mf/dist/src/federation-noop.js');\n\nconst resolveNodeRuntimePluginPath = (): string => {\n const nodePackageRoot = path.dirname(\n require.resolve('@module-federation/node/package.json'),\n );\n\n return require.resolve(\n path.join(\n nodePackageRoot,\n process.env.IS_ESM_BUILD === 'true'\n ? 'dist/src/runtimePlugin.mjs'\n : 'dist/src/runtimePlugin.js',\n ),\n );\n};\n/**\n * NextFederationPlugin is a webpack plugin that handles Next.js application federation using Module Federation.\n */\nexport class NextFederationPlugin {\n private _options: moduleFederationPlugin.ModuleFederationPluginOptions;\n private _extraOptions: NextFederationPluginExtraOptions;\n public name: string;\n /**\n * Constructs the NextFederationPlugin with the provided options.\n *\n * @param options The options to configure the plugin.\n */\n constructor(options: NextFederationPluginOptions) {\n const { mainOptions, extraOptions } = setOptions(options);\n this._options = mainOptions;\n this._extraOptions = extraOptions;\n this.name = 'ModuleFederationPlugin';\n }\n\n /**\n * The apply method is called by the webpack compiler and allows the plugin to hook into the webpack process.\n * @param compiler The webpack compiler object.\n */\n apply(compiler: Compiler) {\n bindLoggerToCompiler(logger, compiler, 'NextFederationPlugin');\n process.env['FEDERATION_WEBPACK_PATH'] =\n process.env['FEDERATION_WEBPACK_PATH'] ||\n getWebpackPath(compiler, { framework: 'nextjs' });\n if (!this.validateOptions(compiler)) return;\n const isServer = this.isServerCompiler(compiler);\n new CopyFederationPlugin(isServer).apply(compiler);\n const normalFederationPluginOptions = this.getNormalFederationPluginOptions(\n compiler,\n isServer,\n );\n this._options = normalFederationPluginOptions;\n this.applyConditionalPlugins(compiler, isServer);\n\n new ModuleFederationPlugin(normalFederationPluginOptions).apply(compiler);\n\n const noop = this.getNoopPath();\n\n if (!this._extraOptions.skipSharingNextInternals) {\n compiler.hooks.make.tapAsync(\n 'NextFederationPlugin',\n (compilation, callback) => {\n const dep = compiler.webpack.EntryPlugin.createDependency(\n noop,\n 'noop',\n );\n compilation.addEntry(\n compiler.context,\n dep,\n { name: 'noop' },\n (err, module) => {\n if (err) {\n return callback(err);\n }\n callback();\n },\n );\n },\n );\n }\n\n if (!compiler.options.ignoreWarnings) {\n compiler.options.ignoreWarnings = [\n //@ts-ignore\n (message) => /your target environment does not appear/.test(message),\n ];\n }\n }\n\n private validateOptions(compiler: Compiler): boolean {\n const manifestPlugin = compiler.options.plugins.find(\n (p): p is WebpackPluginInstance =>\n p?.constructor?.name === 'BuildManifestPlugin',\n );\n\n if (manifestPlugin) {\n //@ts-ignore\n if (manifestPlugin?.appDirEnabled) {\n throw new Error(\n 'App Directory is not supported by nextjs-mf. Use only pages directory, do not open git issues about this',\n );\n }\n }\n\n const compilerValid = validateCompilerOptions(compiler);\n const pluginValid = validatePluginOptions(this._options);\n const envValid = process.env['NEXT_PRIVATE_LOCAL_WEBPACK'];\n if (compilerValid === undefined) logger.error('Compiler validation failed');\n if (pluginValid === undefined) logger.error('Plugin validation failed');\n const validCompilerTarget =\n compiler.options.name === 'server' || compiler.options.name === 'client';\n if (!envValid)\n throw new Error(\n 'process.env.NEXT_PRIVATE_LOCAL_WEBPACK is not set to true, please set it to true, and \"npm install webpack\"',\n );\n return (\n compilerValid !== undefined &&\n pluginValid !== undefined &&\n validCompilerTarget\n );\n }\n\n private isServerCompiler(compiler: Compiler): boolean {\n return compiler.options.name === 'server';\n }\n\n private applyConditionalPlugins(compiler: Compiler, isServer: boolean) {\n compiler.options.output.uniqueName = this._options.name;\n compiler.options.output.environment = {\n ...compiler.options.output.environment,\n asyncFunction: true,\n };\n\n // Add layer rules for resource queries\n if (!compiler.options.module.rules) {\n compiler.options.module.rules = [];\n }\n\n // Add layer rules for RSC, client and SSR\n compiler.options.module.rules.push({\n resourceQuery: /\\?rsc/,\n layer: 'rsc',\n });\n\n compiler.options.module.rules.push({\n resourceQuery: /\\?client/,\n layer: 'client',\n });\n\n compiler.options.module.rules.push({\n resourceQuery: /\\?ssr/,\n layer: 'ssr',\n });\n\n applyPathFixes(compiler, this._options, this._extraOptions);\n if (this._extraOptions.debug) {\n compiler.options.devtool = false;\n }\n\n if (isServer) {\n configureServerCompilerOptions(compiler);\n configureServerLibraryAndFilename(this._options);\n applyServerPlugins(compiler, this._options);\n handleServerExternals(compiler, {\n ...this._options,\n shared: { ...retrieveDefaultShared(isServer), ...this._options.shared },\n });\n } else {\n applyClientPlugins(compiler, this._options, this._extraOptions);\n }\n }\n\n private getNormalFederationPluginOptions(\n compiler: Compiler,\n isServer: boolean,\n ): moduleFederationPlugin.ModuleFederationPluginOptions {\n const defaultShared = this._extraOptions.skipSharingNextInternals\n ? {}\n : retrieveDefaultShared(isServer);\n\n return {\n ...this._options,\n runtime: false,\n remoteType: 'script',\n runtimePlugins: [\n ...(isServer ? [resolveNodeRuntimePluginPath()] : []),\n resolveRuntimePluginPath(),\n ...(this._options.runtimePlugins || []),\n ].map((plugin) => plugin + '?runtimePlugin'),\n //@ts-ignore\n exposes: {\n ...this._options.exposes,\n ...(this._extraOptions.exposePages\n ? exposeNextjsPages(compiler.options.context as string)\n : {}),\n },\n remotes: {\n ...this._options.remotes,\n },\n shared: {\n ...defaultShared,\n ...this._options.shared,\n },\n manifest: {\n ...(this._options.manifest ?? {}),\n filePath: isServer ? '' : '/static/chunks',\n },\n // nextjs project needs to add config.watchOptions = ['**/node_modules/**', '**/@mf-types/**'] to prevent loop types update\n dts: this._options.dts ?? false,\n shareStrategy: this._options.shareStrategy ?? 'loaded-first',\n experiments: {\n asyncStartup: true,\n },\n };\n }\n\n private getNoopPath(): string {\n return resolveNoopPath();\n }\n}\n\nexport default NextFederationPlugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAkCA,MAAM,2CAEQ,QAAQ,4EAA4E;AAGlG,MAAM,kCAEQ,QAAQ,4DAA4D;AAGlF,MAAM,qCAA6C;CACjD,MAAM,kBAAkB,KAAK,kBACnB,QAAQ,uCAAuC,CACxD;AAED,kBAAe,QACb,KAAK,KACH,iBAEI,6BAEL,CACF;;;;;AAKH,IAAa,uBAAb,MAAkC;;;;;;CAShC,YAAY,SAAsC;EAChD,MAAM,EAAE,aAAa,iBAAiB,WAAW,QAAQ;AACzD,OAAK,WAAW;AAChB,OAAK,gBAAgB;AACrB,OAAK,OAAO;;;;;;CAOd,MAAM,UAAoB;AACxB,uBAAqB,QAAQ,UAAU,uBAAuB;AAC9D,UAAQ,IAAI,6BACV,QAAQ,IAAI,8BACZ,eAAe,UAAU,EAAE,WAAW,UAAU,CAAC;AACnD,MAAI,CAAC,KAAK,gBAAgB,SAAS,CAAE;EACrC,MAAM,WAAW,KAAK,iBAAiB,SAAS;AAChD,MAAIA,sBAAqB,SAAS,CAAC,MAAM,SAAS;E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K,SAAS,YAAY,EAAE;IAChC,UAAU,WAAW,KAAK;IAC3B;GAED,KAAK,KAAK,SAAS,OAAO;GAC1B,eAAe,KAAK,SAAS,iBAAiB;GAC9C,aAAa,EACX,cAAc,MACf;GACF;;CAGH,AAAQ,cAAsB;AAC5B,SAAO,iBAAiB"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["CopyFederationPlugin"],"sources":["../../../../src/plugins/NextFederationPlugin/index.ts"],"sourcesContent":["/**\n * MIT License http://www.opensource.org/licenses/mit-license.php\n * Author Zackary Jackson @ScriptedAlchemy\n * This module contains the NextFederationPlugin class which is a webpack plugin that handles Next.js application federation using Module Federation.\n */\n'use strict';\n\nimport type {\n NextFederationPluginExtraOptions,\n NextFederationPluginOptions,\n} from './next-fragments';\nimport type { Compiler, WebpackPluginInstance } from 'webpack';\nimport path from 'path';\nimport { getWebpackPath } from '@module-federation/sdk/normalize-webpack-path';\nimport CopyFederationPlugin from '../CopyFederationPlugin';\nimport { exposeNextjsPages } from '../../loaders/nextPageMapLoader';\nimport { retrieveDefaultShared, applyPathFixes } from './next-fragments';\nimport { setOptions } from './set-options';\nimport {\n validateCompilerOptions,\n validatePluginOptions,\n} from './validate-options';\nimport {\n applyServerPlugins,\n configureServerCompilerOptions,\n configureServerLibraryAndFilename,\n handleServerExternals,\n} from './apply-server-plugins';\nimport { applyClientPlugins } from './apply-client-plugins';\nimport { ModuleFederationPlugin } from '@module-federation/enhanced/webpack';\nimport { bindLoggerToCompiler } from '@module-federation/sdk';\nimport type { moduleFederationPlugin } from '@module-federation/sdk';\nimport logger from '../../logger';\n\nconst resolveRuntimePluginPath = (): string =>\n process.env.IS_ESM_BUILD === 'true'\n ? require.resolve('@module-federation/nextjs-mf/dist/src/plugins/container/runtimePlugin.mjs')\n : require.resolve('@module-federation/nextjs-mf/dist/src/plugins/container/runtimePlugin.js');\n\nconst resolveNoopPath = (): string =>\n process.env.IS_ESM_BUILD === 'true'\n ? require.resolve('@module-federation/nextjs-mf/dist/src/federation-noop.mjs')\n : require.resolve('@module-federation/nextjs-mf/dist/src/federation-noop.js');\n\nconst resolveNodeRuntimePluginPath = (): string => {\n const nodePackageRoot = path.dirname(\n require.resolve('@module-federation/node/package.json'),\n );\n\n return require.resolve(\n path.join(\n nodePackageRoot,\n process.env.IS_ESM_BUILD === 'true'\n ? 'dist/src/runtimePlugin.mjs'\n : 'dist/src/runtimePlugin.js',\n ),\n );\n};\n/**\n * NextFederationPlugin is a webpack plugin that handles Next.js application federation using Module Federation.\n */\nexport class NextFederationPlugin {\n private _options: moduleFederationPlugin.ModuleFederationPluginOptions;\n private _extraOptions: NextFederationPluginExtraOptions;\n public name: string;\n /**\n * Constructs the NextFederationPlugin with the provided options.\n *\n * @param options The options to configure the plugin.\n */\n constructor(options: NextFederationPluginOptions) {\n const { mainOptions, extraOptions } = setOptions(options);\n this._options = mainOptions;\n this._extraOptions = extraOptions;\n this.name = 'ModuleFederationPlugin';\n }\n\n /**\n * The apply method is called by the webpack compiler and allows the plugin to hook into the webpack process.\n * @param compiler The webpack compiler object.\n */\n apply(compiler: Compiler) {\n bindLoggerToCompiler(logger, compiler, 'NextFederationPlugin');\n process.env['FEDERATION_WEBPACK_PATH'] =\n process.env['FEDERATION_WEBPACK_PATH'] ||\n getWebpackPath(compiler, { framework: 'nextjs' });\n if (!this.validateOptions(compiler)) return;\n const isServer = this.isServerCompiler(compiler);\n new CopyFederationPlugin(isServer).apply(compiler);\n const normalFederationPluginOptions = this.getNormalFederationPluginOptions(\n compiler,\n isServer,\n );\n this._options = normalFederationPluginOptions;\n this.applyConditionalPlugins(compiler, isServer);\n\n new ModuleFederationPlugin(normalFederationPluginOptions).apply(compiler);\n\n const noop = this.getNoopPath();\n\n if (!this._extraOptions.skipSharingNextInternals) {\n compiler.hooks.make.tapAsync(\n 'NextFederationPlugin',\n (compilation, callback) => {\n const dep = compiler.webpack.EntryPlugin.createDependency(\n noop,\n 'noop',\n );\n compilation.addEntry(\n compiler.context,\n dep,\n { name: 'noop' },\n (err, module) => {\n if (err) {\n return callback(err);\n }\n callback();\n },\n );\n },\n );\n }\n\n if (!compiler.options.ignoreWarnings) {\n compiler.options.ignoreWarnings = [\n //@ts-ignore\n (message) => /your target environment does not appear/.test(message),\n ];\n }\n }\n\n private validateOptions(compiler: Compiler): boolean {\n const manifestPlugin = compiler.options.plugins.find(\n (p): p is WebpackPluginInstance =>\n p?.constructor?.name === 'BuildManifestPlugin',\n );\n\n if (manifestPlugin) {\n //@ts-ignore\n if (manifestPlugin?.appDirEnabled) {\n throw new Error(\n 'App Directory is not supported by nextjs-mf. Use only pages directory, do not open git issues about this',\n );\n }\n }\n\n const compilerValid = validateCompilerOptions(compiler);\n const pluginValid = validatePluginOptions(this._options);\n const envValid = process.env['NEXT_PRIVATE_LOCAL_WEBPACK'];\n if (compilerValid === undefined) logger.error('Compiler validation failed');\n if (pluginValid === undefined) logger.error('Plugin validation failed');\n const validCompilerTarget =\n compiler.options.name === 'server' || compiler.options.name === 'client';\n if (!envValid)\n throw new Error(\n 'process.env.NEXT_PRIVATE_LOCAL_WEBPACK is not set to true, please set it to true, and \"npm install webpack\"',\n );\n return (\n compilerValid !== undefined &&\n pluginValid !== undefined &&\n validCompilerTarget\n );\n }\n\n private isServerCompiler(compiler: Compiler): boolean {\n return compiler.options.name === 'server';\n }\n\n private applyConditionalPlugins(compiler: Compiler, isServer: boolean) {\n compiler.options.output.uniqueName = this._options.name;\n compiler.options.output.environment = {\n ...compiler.options.output.environment,\n asyncFunction: true,\n };\n\n // Add layer rules for resource queries\n if (!compiler.options.module.rules) {\n compiler.options.module.rules = [];\n }\n\n // Add layer rules for RSC, client and SSR\n compiler.options.module.rules.push({\n resourceQuery: /\\?rsc/,\n layer: 'rsc',\n });\n\n compiler.options.module.rules.push({\n resourceQuery: /\\?client/,\n layer: 'client',\n });\n\n compiler.options.module.rules.push({\n resourceQuery: /\\?ssr/,\n layer: 'ssr',\n });\n\n applyPathFixes(compiler, this._options, this._extraOptions);\n if (this._extraOptions.debug) {\n compiler.options.devtool = false;\n }\n\n if (isServer) {\n configureServerCompilerOptions(compiler);\n configureServerLibraryAndFilename(this._options);\n applyServerPlugins(compiler, this._options);\n handleServerExternals(compiler, {\n ...this._options,\n shared: { ...retrieveDefaultShared(isServer), ...this._options.shared },\n });\n } else {\n applyClientPlugins(compiler, this._options, this._extraOptions);\n }\n }\n\n private getNormalFederationPluginOptions(\n compiler: Compiler,\n isServer: boolean,\n ): moduleFederationPlugin.ModuleFederationPluginOptions {\n const defaultShared = this._extraOptions.skipSharingNextInternals\n ? {}\n : retrieveDefaultShared(isServer);\n const manifestOptions =\n typeof this._options.manifest === 'object' &&\n this._options.manifest !== null\n ? this._options.manifest\n : {};\n\n return {\n ...this._options,\n runtime: false,\n remoteType: 'script',\n runtimePlugins: [\n ...(isServer ? [resolveNodeRuntimePluginPath()] : []),\n resolveRuntimePluginPath(),\n ...(this._options.runtimePlugins || []),\n ].map((plugin) => plugin + '?runtimePlugin'),\n //@ts-ignore\n exposes: {\n ...this._options.exposes,\n ...(this._extraOptions.exposePages\n ? exposeNextjsPages(compiler.options.context as string)\n : {}),\n },\n remotes: {\n ...this._options.remotes,\n },\n shared: {\n ...defaultShared,\n ...(this._options.shared as Record<string, unknown>),\n },\n manifest: {\n ...manifestOptions,\n filePath: isServer ? '' : '/static/chunks',\n },\n // nextjs project needs to add config.watchOptions = ['**/node_modules/**', '**/@mf-types/**'] to prevent loop types update\n dts: this._options.dts ?? false,\n shareStrategy: this._options.shareStrategy ?? 'loaded-first',\n experiments: {\n asyncStartup: true,\n },\n };\n }\n\n private getNoopPath(): string {\n return resolveNoopPath();\n }\n}\n\nexport default NextFederationPlugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAkCA,MAAM,2CAEQ,QAAQ,4EAA4E;AAGlG,MAAM,kCAEQ,QAAQ,4DAA4D;AAGlF,MAAM,qCAA6C;CACjD,MAAM,kBAAkB,KAAK,kBACnB,QAAQ,uCAAuC,CACxD;AAED,kB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Ac,2BACrC,EAAE,GACF,sBAAsB,SAAS;EACnC,MAAM,kBACJ,OAAO,KAAK,SAAS,aAAa,YAClC,KAAK,SAAS,aAAa,OACvB,KAAK,SAAS,WACd,EAAE;AAER,SAAO;GACL,GAAG,KAAK;GACR,SAAS;GACT,YAAY;GACZ,gBAAgB;IACd,GAAI,WAAW,CAAC,8BAA8B,CAAC,GAAG,EAAE;IACpD,0BAA0B;IAC1B,GAAI,KAAK,SAAS,kBAAkB,EAAE;IACvC,CAAC,KAAK,WAAW,SAAS,iBAAiB;GAE5C,SAAS;IACP,GAAG,KAAK,SAAS;IACjB,GAAI,KAAK,cAAc,cACnB,kBAAkB,SAAS,QAAQ,QAAkB,GACrD,EAAE;IACP;GACD,SAAS,EACP,GAAG,KAAK,SAAS,SAClB;GACD,QAAQ;IACN,GAAG;IACH,GAAI,KAAK,SAAS;IACnB;GACD,UAAU;IACR,GAAG;IACH,UAAU,WAAW,KAAK;IAC3B;GAED,KAAK,KAAK,SAAS,OAAO;GAC1B,eAAe,KAAK,SAAS,iBAAiB;GAC9C,aAAa,EACX,cAAc,MACf;GACF;;CAGH,AAAQ,cAAsB;AAC5B,SAAO,iBAAiB"}
|
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import type { Compiler } from 'webpack';
|
|
2
|
+
import type { moduleFederationPlugin } from '@module-federation/sdk';
|
|
3
|
+
/**
|
|
4
|
+
* Set up default shared values based on the environment.
|
|
5
|
+
* @param {boolean} isServer - Boolean indicating if the code is running on the server.
|
|
6
|
+
* @returns {SharedObject} The default share scope based on the environment.
|
|
7
|
+
*/
|
|
8
|
+
export declare const retrieveDefaultShared: (isServer: boolean) => moduleFederationPlugin.SharedObject;
|
|
9
|
+
export declare const applyPathFixes: (compiler: Compiler, pluginOptions: moduleFederationPlugin.ModuleFederationPluginOptions, options: any) => void;
|
|
10
|
+
export interface NextFederationPluginExtraOptions {
|
|
11
|
+
enableImageLoaderFix?: boolean;
|
|
12
|
+
enableUrlLoaderFix?: boolean;
|
|
13
|
+
exposePages?: boolean;
|
|
14
|
+
skipSharingNextInternals?: boolean;
|
|
15
|
+
automaticPageStitching?: boolean;
|
|
16
|
+
debug?: boolean;
|
|
12
17
|
}
|
|
13
|
-
interface NextFederationPluginOptions extends moduleFederationPlugin.ModuleFederationPluginOptions {
|
|
14
|
-
|
|
18
|
+
export interface NextFederationPluginOptions extends moduleFederationPlugin.ModuleFederationPluginOptions {
|
|
19
|
+
extraOptions: NextFederationPluginExtraOptions;
|
|
15
20
|
}
|
|
16
|
-
//#endregion
|
|
17
|
-
export { NextFederationPluginOptions };
|
|
18
|
-
//# sourceMappingURL=next-fragments.d.mts.map
|
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
import { Compiler } from
|
|
2
|
-
import { moduleFederationPlugin } from
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import type { Compiler } from 'webpack';
|
|
2
|
+
import type { moduleFederationPlugin } from '@module-federation/sdk';
|
|
3
|
+
/**
|
|
4
|
+
* Set up default shared values based on the environment.
|
|
5
|
+
* @param {boolean} isServer - Boolean indicating if the code is running on the server.
|
|
6
|
+
* @returns {SharedObject} The default share scope based on the environment.
|
|
7
|
+
*/
|
|
8
|
+
export declare const retrieveDefaultShared: (isServer: boolean) => moduleFederationPlugin.SharedObject;
|
|
9
|
+
export declare const applyPathFixes: (compiler: Compiler, pluginOptions: moduleFederationPlugin.ModuleFederationPluginOptions, options: any) => void;
|
|
10
|
+
export interface NextFederationPluginExtraOptions {
|
|
11
|
+
enableImageLoaderFix?: boolean;
|
|
12
|
+
enableUrlLoaderFix?: boolean;
|
|
13
|
+
exposePages?: boolean;
|
|
14
|
+
skipSharingNextInternals?: boolean;
|
|
15
|
+
automaticPageStitching?: boolean;
|
|
16
|
+
debug?: boolean;
|
|
12
17
|
}
|
|
13
|
-
interface NextFederationPluginOptions extends moduleFederationPlugin.ModuleFederationPluginOptions {
|
|
14
|
-
|
|
18
|
+
export interface NextFederationPluginOptions extends moduleFederationPlugin.ModuleFederationPluginOptions {
|
|
19
|
+
extraOptions: NextFederationPluginExtraOptions;
|
|
15
20
|
}
|
|
16
|
-
//#endregion
|
|
17
|
-
export { NextFederationPluginOptions };
|
|
18
|
-
//# sourceMappingURL=next-fragments.d.ts.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { RuleSetConditionAbsolute } from 'webpack';
|
|
2
|
+
/**
|
|
3
|
+
* Compares two regular expressions or other types of conditions to see if they are equal.
|
|
4
|
+
*
|
|
5
|
+
* @param x - The first condition to compare. It can be a string, a RegExp, a function that takes a string and returns a boolean, an array of RuleSetConditionAbsolute, or undefined.
|
|
6
|
+
* @param y - The second condition to compare. It is always a RegExp.
|
|
7
|
+
* @returns True if the conditions are equal, false otherwise.
|
|
8
|
+
*
|
|
9
|
+
* @remarks
|
|
10
|
+
* This function compares two conditions to see if they are equal in terms of their source,
|
|
11
|
+
* global, ignoreCase, and multiline properties. It is used to check if two conditions match
|
|
12
|
+
* the same pattern. If the first condition is not a RegExp, the function will always return false.
|
|
13
|
+
*/
|
|
14
|
+
export declare const regexEqual: (x: string | RegExp | ((value: string) => boolean) | RuleSetConditionAbsolute[] | undefined, y: RegExp) => boolean;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { RuleSetConditionAbsolute } from 'webpack';
|
|
2
|
+
/**
|
|
3
|
+
* Compares two regular expressions or other types of conditions to see if they are equal.
|
|
4
|
+
*
|
|
5
|
+
* @param x - The first condition to compare. It can be a string, a RegExp, a function that takes a string and returns a boolean, an array of RuleSetConditionAbsolute, or undefined.
|
|
6
|
+
* @param y - The second condition to compare. It is always a RegExp.
|
|
7
|
+
* @returns True if the conditions are equal, false otherwise.
|
|
8
|
+
*
|
|
9
|
+
* @remarks
|
|
10
|
+
* This function compares two conditions to see if they are equal in terms of their source,
|
|
11
|
+
* global, ignoreCase, and multiline properties. It is used to check if two conditions match
|
|
12
|
+
* the same pattern. If the first condition is not a RegExp, the function will always return false.
|
|
13
|
+
*/
|
|
14
|
+
export declare const regexEqual: (x: string | RegExp | ((value: string) => boolean) | RuleSetConditionAbsolute[] | undefined, y: RegExp) => boolean;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Function to remove unnecessary shared keys from the default share scope.
|
|
3
|
+
* It iterates over each key in the shared object and checks against the default share scope.
|
|
4
|
+
* If a key is found in the default share scope, a warning is logged and the key is removed from the shared object.
|
|
5
|
+
*
|
|
6
|
+
* @param {Record<string, unknown>} shared - The shared object to be checked.
|
|
7
|
+
*/
|
|
8
|
+
export declare function removeUnnecessarySharedKeys(shared: Record<string, unknown>): void;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Function to remove unnecessary shared keys from the default share scope.
|
|
3
|
+
* It iterates over each key in the shared object and checks against the default share scope.
|
|
4
|
+
* If a key is found in the default share scope, a warning is logged and the key is removed from the shared object.
|
|
5
|
+
*
|
|
6
|
+
* @param {Record<string, unknown>} shared - The shared object to be checked.
|
|
7
|
+
*/
|
|
8
|
+
export declare function removeUnnecessarySharedKeys(shared: Record<string, unknown>): void;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { moduleFederationPlugin } from '@module-federation/sdk';
|
|
2
|
+
export interface NextFederationPluginExtraOptions {
|
|
3
|
+
enableImageLoaderFix?: boolean;
|
|
4
|
+
enableUrlLoaderFix?: boolean;
|
|
5
|
+
exposePages?: boolean;
|
|
6
|
+
skipSharingNextInternals?: boolean;
|
|
7
|
+
automaticPageStitching?: boolean;
|
|
8
|
+
debug?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface NextFederationPluginOptions extends moduleFederationPlugin.ModuleFederationPluginOptions {
|
|
11
|
+
extraOptions: NextFederationPluginExtraOptions;
|
|
12
|
+
}
|
|
13
|
+
export declare function setOptions(options: NextFederationPluginOptions): {
|
|
14
|
+
mainOptions: moduleFederationPlugin.ModuleFederationPluginOptions;
|
|
15
|
+
extraOptions: NextFederationPluginExtraOptions;
|
|
16
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { moduleFederationPlugin } from '@module-federation/sdk';
|
|
2
|
+
export interface NextFederationPluginExtraOptions {
|
|
3
|
+
enableImageLoaderFix?: boolean;
|
|
4
|
+
enableUrlLoaderFix?: boolean;
|
|
5
|
+
exposePages?: boolean;
|
|
6
|
+
skipSharingNextInternals?: boolean;
|
|
7
|
+
automaticPageStitching?: boolean;
|
|
8
|
+
debug?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface NextFederationPluginOptions extends moduleFederationPlugin.ModuleFederationPluginOptions {
|
|
11
|
+
extraOptions: NextFederationPluginExtraOptions;
|
|
12
|
+
}
|
|
13
|
+
export declare function setOptions(options: NextFederationPluginOptions): {
|
|
14
|
+
mainOptions: moduleFederationPlugin.ModuleFederationPluginOptions;
|
|
15
|
+
extraOptions: NextFederationPluginExtraOptions;
|
|
16
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Compiler } from 'webpack';
|
|
2
|
+
import type { moduleFederationPlugin } from '@module-federation/sdk';
|
|
3
|
+
/**
|
|
4
|
+
* Validates the compiler options.
|
|
5
|
+
*
|
|
6
|
+
* @param {Compiler} compiler - The Webpack compiler instance.
|
|
7
|
+
* @returns {boolean} - Returns true if the compiler options are valid, false otherwise.
|
|
8
|
+
*
|
|
9
|
+
* @throws Will throw an error if the name option is not defined in the options.
|
|
10
|
+
* @remarks
|
|
11
|
+
* This function validates the options passed to the Webpack compiler. It checks if the name option is set to either "server" or
|
|
12
|
+
* "client", as Module Federation is only applied to the main server and client builds in Next.js.
|
|
13
|
+
*/
|
|
14
|
+
export declare function validateCompilerOptions(compiler: Compiler): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Validates the NextFederationPlugin options.
|
|
17
|
+
*
|
|
18
|
+
* @param {moduleFederationPlugin.ModuleFederationPluginOptions} options - The ModuleFederationPluginOptions instance.
|
|
19
|
+
*
|
|
20
|
+
* @throws Will throw an error if the filename option is not defined in the options or if the name option is not specified.
|
|
21
|
+
* @remarks
|
|
22
|
+
* This function validates the options passed to NextFederationPlugin. It ensures that the filename and name options are defined,
|
|
23
|
+
* as they are required for using Module Federation.
|
|
24
|
+
*/
|
|
25
|
+
export declare function validatePluginOptions(options: moduleFederationPlugin.ModuleFederationPluginOptions): boolean | void;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Compiler } from 'webpack';
|
|
2
|
+
import type { moduleFederationPlugin } from '@module-federation/sdk';
|
|
3
|
+
/**
|
|
4
|
+
* Validates the compiler options.
|
|
5
|
+
*
|
|
6
|
+
* @param {Compiler} compiler - The Webpack compiler instance.
|
|
7
|
+
* @returns {boolean} - Returns true if the compiler options are valid, false otherwise.
|
|
8
|
+
*
|
|
9
|
+
* @throws Will throw an error if the name option is not defined in the options.
|
|
10
|
+
* @remarks
|
|
11
|
+
* This function validates the options passed to the Webpack compiler. It checks if the name option is set to either "server" or
|
|
12
|
+
* "client", as Module Federation is only applied to the main server and client builds in Next.js.
|
|
13
|
+
*/
|
|
14
|
+
export declare function validateCompilerOptions(compiler: Compiler): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Validates the NextFederationPlugin options.
|
|
17
|
+
*
|
|
18
|
+
* @param {moduleFederationPlugin.ModuleFederationPluginOptions} options - The ModuleFederationPluginOptions instance.
|
|
19
|
+
*
|
|
20
|
+
* @throws Will throw an error if the filename option is not defined in the options or if the name option is not specified.
|
|
21
|
+
* @remarks
|
|
22
|
+
* This function validates the options passed to NextFederationPlugin. It ensures that the filename and name options are defined,
|
|
23
|
+
* as they are required for using Module Federation.
|
|
24
|
+
*/
|
|
25
|
+
export declare function validatePluginOptions(options: moduleFederationPlugin.ModuleFederationPluginOptions): boolean | void;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
declare const RuntimeModule: typeof import("node_modules/webpack/types").RuntimeModule;
|
|
2
|
+
interface InvertedContainerRuntimeModuleOptions {
|
|
3
|
+
name?: string;
|
|
4
|
+
containers: Set<any>;
|
|
5
|
+
}
|
|
6
|
+
declare class InvertedContainerRuntimeModule extends RuntimeModule {
|
|
7
|
+
private options;
|
|
8
|
+
constructor(options: InvertedContainerRuntimeModuleOptions);
|
|
9
|
+
generate(): string;
|
|
10
|
+
}
|
|
11
|
+
export default InvertedContainerRuntimeModule;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
declare const RuntimeModule: typeof import("node_modules/webpack/types").RuntimeModule;
|
|
2
|
+
interface InvertedContainerRuntimeModuleOptions {
|
|
3
|
+
name?: string;
|
|
4
|
+
containers: Set<any>;
|
|
5
|
+
}
|
|
6
|
+
declare class InvertedContainerRuntimeModule extends RuntimeModule {
|
|
7
|
+
private options;
|
|
8
|
+
constructor(options: InvertedContainerRuntimeModuleOptions);
|
|
9
|
+
generate(): string;
|
|
10
|
+
}
|
|
11
|
+
export default InvertedContainerRuntimeModule;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InvertedContainerRuntimeModule.js","names":[],"sources":["../../../../src/plugins/container/InvertedContainerRuntimeModule.ts"],"sourcesContent":["import { normalizeWebpackPath } from '@module-federation/sdk/normalize-webpack-path';\
|
|
1
|
+
{"version":3,"file":"InvertedContainerRuntimeModule.js","names":[],"sources":["../../../../src/plugins/container/InvertedContainerRuntimeModule.ts"],"sourcesContent":["import { normalizeWebpackPath } from '@module-federation/sdk/normalize-webpack-path';\nconst { RuntimeModule, Template, RuntimeGlobals } = require(\n normalizeWebpackPath('webpack'),\n) as typeof import('webpack') & {\n RuntimeGlobals: Record<string, string>;\n};\n\ninterface InvertedContainerRuntimeModuleOptions {\n name?: string;\n containers: Set<any>; // Adjust the type as necessary\n}\n\ntype ContainerEntryModule = NonNullable<\n ReturnType<CompilationModuleGraph['getModule']>\n> & {\n _name?: string;\n};\n\ntype CompilationModuleGraph = {\n getModule: (dependency: unknown) => unknown;\n};\n\nclass InvertedContainerRuntimeModule extends RuntimeModule {\n private options: InvertedContainerRuntimeModuleOptions;\n\n constructor(options: InvertedContainerRuntimeModuleOptions) {\n super('inverted container startup', RuntimeModule.STAGE_TRIGGER);\n this.options = options;\n }\n\n override generate(): string {\n const { compilation, chunk, chunkGraph } = this;\n if (!compilation || !chunk || !chunkGraph) {\n return '';\n }\n if (chunk.runtime === 'webpack-api-runtime') {\n return '';\n }\n\n const runtimeChunk = compilation.options.optimization?.runtimeChunk;\n if (typeof runtimeChunk === 'object' && runtimeChunk !== null) {\n const logger = compilation.getLogger('InvertedContainerRuntimeModule');\n logger.info(\n 'Runtime chunk is configured. Consider adding runtime: false to your ModuleFederationPlugin configuration to prevent runtime conflicts.',\n );\n }\n\n let containerEntryModule;\n for (const containerDep of this.options.containers) {\n const mod = compilation.moduleGraph.getModule(containerDep);\n if (!mod) continue;\n if (chunkGraph.isModuleInChunk(mod, chunk)) {\n containerEntryModule = mod as ContainerEntryModule;\n }\n }\n\n if (!containerEntryModule) return '';\n\n if (\n compilation.chunkGraph.isEntryModuleInChunk(containerEntryModule, chunk)\n ) {\n // Don't apply to the remote entry itself\n return '';\n }\n const initRuntimeModuleGetter = compilation.runtimeTemplate.moduleRaw({\n module: containerEntryModule,\n chunkGraph,\n weak: false,\n runtimeRequirements: new Set(),\n });\n\n //@ts-ignore\n const nameJSON = JSON.stringify(containerEntryModule._name);\n\n return Template.asString([\n `var prevStartup = ${RuntimeGlobals.startup};`,\n `var hasRun = false;`,\n `var cachedRemote;`,\n `${RuntimeGlobals.startup} = ${compilation.runtimeTemplate.basicFunction(\n '',\n Template.asString([\n `if (!hasRun) {`,\n Template.indent(\n Template.asString([\n `hasRun = true;`,\n `if (typeof prevStartup === 'function') {`,\n Template.indent(Template.asString([`prevStartup();`])),\n `}`,\n `cachedRemote = ${initRuntimeModuleGetter};`,\n `var gs = ${RuntimeGlobals.global} || globalThis;`,\n `gs[${nameJSON}] = cachedRemote;`,\n ]),\n ),\n `} else if (typeof prevStartup === 'function') {`,\n Template.indent(`prevStartup();`),\n `}`,\n ]),\n )};`,\n ]);\n }\n}\n\nexport default InvertedContainerRuntimeModule;\n"],"mappings":";;;;AACA,MAAM,EAAE,eAAe,UAAU,mBAAmB,gFAC7B,UAAU,CAChC;AAmBD,IAAM,iCAAN,cAA6C,cAAc;CAGzD,YAAY,SAAgD;AAC1D,QAAM,8BAA8B,cAAc,cAAc;AAChE,OAAK,UAAU;;CAGjB,AAAS,WAAmB;EAC1B,MAAM,EAAE,aAAa,OAAO,eAAe;AAC3C,MAAI,CAAC,eAAe,CAAC,SAAS,CAAC,WAC7B,QAAO;AAET,MAAI,MAAM,YAAY,sBACpB,QAAO;EAGT,MAAM,eAAe,YAAY,QAAQ,cAAc;AACvD,MAAI,OAAO,iBAAiB,YAAY,iBAAiB,KAEvD,CADe,YAAY,UAAU,iCAAiC,CAC/D,KACL,yIACD;EAGH,IAAI;AACJ,OAAK,MAAM,gBAAgB,KAAK,QAAQ,YAAY;GAClD,MAAM,MAAM,YAAY,YAAY,UAAU,aAAa;AAC3D,OAAI,CAAC,IAAK;AACV,OAAI,WAAW,gBAAgB,KAAK,MAAM,CACxC,wBAAuB;;AAI3B,MAAI,CAAC,qBAAsB,QAAO;AAElC,MACE,YAAY,WAAW,qBAAqB,sBAAsB,MAAM,CAGxE,QAAO;EAET,MAAM,0BAA0B,YAAY,gBAAgB,UAAU;GACpE,QAAQ;GACR;GACA,MAAM;GACN,qCAAqB,IAAI,KAAK;GAC/B,CAAC;EAGF,MAAM,WAAW,KAAK,UAAU,qBAAqB,MAAM;AAE3D,SAAO,SAAS,SAAS;GACvB,qBAAqB,eAAe,QAAQ;GAC5C;GACA;GACA,GAAG,eAAe,QAAQ,KAAK,YAAY,gBAAgB,cACzD,IACA,SAAS,SAAS;IAChB;IACA,SAAS,OACP,SAAS,SAAS;KAChB;KACA;KACA,SAAS,OAAO,SAAS,SAAS,CAAC,iBAAiB,CAAC,CAAC;KACtD;KACA,kBAAkB,wBAAwB;KAC1C,YAAY,eAAe,OAAO;KAClC,MAAM,SAAS;KAChB,CAAC,CACH;IACD;IACA,SAAS,OAAO,iBAAiB;IACjC;IACD,CAAC,CACH,CAAC;GACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InvertedContainerRuntimeModule.mjs","names":[],"sources":["../../../../src/plugins/container/InvertedContainerRuntimeModule.ts"],"sourcesContent":["import { normalizeWebpackPath } from '@module-federation/sdk/normalize-webpack-path';\
|
|
1
|
+
{"version":3,"file":"InvertedContainerRuntimeModule.mjs","names":[],"sources":["../../../../src/plugins/container/InvertedContainerRuntimeModule.ts"],"sourcesContent":["import { normalizeWebpackPath } from '@module-federation/sdk/normalize-webpack-path';\nconst { RuntimeModule, Template, RuntimeGlobals } = require(\n normalizeWebpackPath('webpack'),\n) as typeof import('webpack') & {\n RuntimeGlobals: Record<string, string>;\n};\n\ninterface InvertedContainerRuntimeModuleOptions {\n name?: string;\n containers: Set<any>; // Adjust the type as necessary\n}\n\ntype ContainerEntryModule = NonNullable<\n ReturnType<CompilationModuleGraph['getModule']>\n> & {\n _name?: string;\n};\n\ntype CompilationModuleGraph = {\n getModule: (dependency: unknown) => unknown;\n};\n\nclass InvertedContainerRuntimeModule extends RuntimeModule {\n private options: InvertedContainerRuntimeModuleOptions;\n\n constructor(options: InvertedContainerRuntimeModuleOptions) {\n super('inverted container startup', RuntimeModule.STAGE_TRIGGER);\n this.options = options;\n }\n\n override generate(): string {\n const { compilation, chunk, chunkGraph } = this;\n if (!compilation || !chunk || !chunkGraph) {\n return '';\n }\n if (chunk.runtime === 'webpack-api-runtime') {\n return '';\n }\n\n const runtimeChunk = compilation.options.optimization?.runtimeChunk;\n if (typeof runtimeChunk === 'object' && runtimeChunk !== null) {\n const logger = compilation.getLogger('InvertedContainerRuntimeModule');\n logger.info(\n 'Runtime chunk is configured. Consider adding runtime: false to your ModuleFederationPlugin configuration to prevent runtime conflicts.',\n );\n }\n\n let containerEntryModule;\n for (const containerDep of this.options.containers) {\n const mod = compilation.moduleGraph.getModule(containerDep);\n if (!mod) continue;\n if (chunkGraph.isModuleInChunk(mod, chunk)) {\n containerEntryModule = mod as ContainerEntryModule;\n }\n }\n\n if (!containerEntryModule) return '';\n\n if (\n compilation.chunkGraph.isEntryModuleInChunk(containerEntryModule, chunk)\n ) {\n // Don't apply to the remote entry itself\n return '';\n }\n const initRuntimeModuleGetter = compilation.runtimeTemplate.moduleRaw({\n module: containerEntryModule,\n chunkGraph,\n weak: false,\n runtimeRequirements: new Set(),\n });\n\n //@ts-ignore\n const nameJSON = JSON.stringify(containerEntryModule._name);\n\n return Template.asString([\n `var prevStartup = ${RuntimeGlobals.startup};`,\n `var hasRun = false;`,\n `var cachedRemote;`,\n `${RuntimeGlobals.startup} = ${compilation.runtimeTemplate.basicFunction(\n '',\n Template.asString([\n `if (!hasRun) {`,\n Template.indent(\n Template.asString([\n `hasRun = true;`,\n `if (typeof prevStartup === 'function') {`,\n Template.indent(Template.asString([`prevStartup();`])),\n `}`,\n `cachedRemote = ${initRuntimeModuleGetter};`,\n `var gs = ${RuntimeGlobals.global} || globalThis;`,\n `gs[${nameJSON}] = cachedRemote;`,\n ]),\n ),\n `} else if (typeof prevStartup === 'function') {`,\n Template.indent(`prevStartup();`),\n `}`,\n ]),\n )};`,\n ]);\n }\n}\n\nexport default InvertedContainerRuntimeModule;\n"],"mappings":";;;;AACA,MAAM,EAAE,eAAe,UAAU,6BAC/B,qBAAqB,UAAU,CAChC;AAmBD,IAAM,iCAAN,cAA6C,cAAc;CAGzD,YAAY,SAAgD;AAC1D,QAAM,8BAA8B,cAAc,cAAc;AAChE,OAAK,UAAU;;CAGjB,AAAS,WAAmB;EAC1B,MAAM,EAAE,aAAa,OAAO,eAAe;AAC3C,MAAI,CAAC,eAAe,CAAC,SAAS,CAAC,WAC7B,QAAO;AAET,MAAI,MAAM,YAAY,sBACpB,QAAO;EAGT,MAAM,eAAe,YAAY,QAAQ,cAAc;AACvD,MAAI,OAAO,iBAAiB,YAAY,iBAAiB,KAEvD,CADe,YAAY,UAAU,iCAAiC,CAC/D,KACL,yIACD;EAGH,IAAI;AACJ,OAAK,MAAM,gBAAgB,KAAK,QAAQ,YAAY;GAClD,MAAM,MAAM,YAAY,YAAY,UAAU,aAAa;AAC3D,OAAI,CAAC,IAAK;AACV,OAAI,WAAW,gBAAgB,KAAK,MAAM,CACxC,wBAAuB;;AAI3B,MAAI,CAAC,qBAAsB,QAAO;AAElC,MACE,YAAY,WAAW,qBAAqB,sBAAsB,MAAM,CAGxE,QAAO;EAET,MAAM,0BAA0B,YAAY,gBAAgB,UAAU;GACpE,QAAQ;GACR;GACA,MAAM;GACN,qCAAqB,IAAI,KAAK;GAC/B,CAAC;EAGF,MAAM,WAAW,KAAK,UAAU,qBAAqB,MAAM;AAE3D,SAAO,SAAS,SAAS;GACvB,qBAAqB,eAAe,QAAQ;GAC5C;GACA;GACA,GAAG,eAAe,QAAQ,KAAK,YAAY,gBAAgB,cACzD,IACA,SAAS,SAAS;IAChB;IACA,SAAS,OACP,SAAS,SAAS;KAChB;KACA;KACA,SAAS,OAAO,SAAS,SAAS,CAAC,iBAAiB,CAAC,CAAC;KACtD;KACA,kBAAkB,wBAAwB;KAC1C,YAAY,eAAe,OAAO;KAClC,MAAM,SAAS;KAChB,CAAC,CACH;IACD;IACA,SAAS,OAAO,iBAAiB;IACjC;IACD,CAAC,CACH,CAAC;GACH,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { Compiler } from 'webpack';
|
|
2
|
+
/**
|
|
3
|
+
* This plugin removes eager modules from the runtime.
|
|
4
|
+
* @class RemoveEagerModulesFromRuntimePlugin
|
|
5
|
+
*/
|
|
6
|
+
declare class RemoveEagerModulesFromRuntimePlugin {
|
|
7
|
+
private container;
|
|
8
|
+
private debug;
|
|
9
|
+
private modulesToProcess;
|
|
10
|
+
/**
|
|
11
|
+
* Creates an instance of RemoveEagerModulesFromRuntimePlugin.
|
|
12
|
+
* @param {Object} options - The options for the plugin.
|
|
13
|
+
* @param {string} options.container - The container to remove modules from.
|
|
14
|
+
* @param {boolean} options.debug - Whether to log debug information.
|
|
15
|
+
*/
|
|
16
|
+
constructor(options: {
|
|
17
|
+
container?: string;
|
|
18
|
+
debug?: boolean;
|
|
19
|
+
});
|
|
20
|
+
/**
|
|
21
|
+
* Applies the plugin to the compiler.
|
|
22
|
+
* @param {Compiler} compiler - The webpack compiler.
|
|
23
|
+
*/
|
|
24
|
+
apply(compiler: Compiler): void;
|
|
25
|
+
/**
|
|
26
|
+
* Processes the modules in the chunk.
|
|
27
|
+
* @param {Compilation} compilation - The webpack compilation.
|
|
28
|
+
* @param {Chunk} chunk - The chunk to process.
|
|
29
|
+
* @param {Iterable<Module>} modules - The modules in the chunk.
|
|
30
|
+
*/
|
|
31
|
+
private processModules;
|
|
32
|
+
/**
|
|
33
|
+
* Removes the modules from the chunk.
|
|
34
|
+
* @param {Compilation} compilation - The webpack compilation.
|
|
35
|
+
* @param {Chunk} chunk - The chunk to remove modules from.
|
|
36
|
+
*/
|
|
37
|
+
private removeModules;
|
|
38
|
+
}
|
|
39
|
+
export default RemoveEagerModulesFromRuntimePlugin;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { Compiler } from 'webpack';
|
|
2
|
+
/**
|
|
3
|
+
* This plugin removes eager modules from the runtime.
|
|
4
|
+
* @class RemoveEagerModulesFromRuntimePlugin
|
|
5
|
+
*/
|
|
6
|
+
declare class RemoveEagerModulesFromRuntimePlugin {
|
|
7
|
+
private container;
|
|
8
|
+
private debug;
|
|
9
|
+
private modulesToProcess;
|
|
10
|
+
/**
|
|
11
|
+
* Creates an instance of RemoveEagerModulesFromRuntimePlugin.
|
|
12
|
+
* @param {Object} options - The options for the plugin.
|
|
13
|
+
* @param {string} options.container - The container to remove modules from.
|
|
14
|
+
* @param {boolean} options.debug - Whether to log debug information.
|
|
15
|
+
*/
|
|
16
|
+
constructor(options: {
|
|
17
|
+
container?: string;
|
|
18
|
+
debug?: boolean;
|
|
19
|
+
});
|
|
20
|
+
/**
|
|
21
|
+
* Applies the plugin to the compiler.
|
|
22
|
+
* @param {Compiler} compiler - The webpack compiler.
|
|
23
|
+
*/
|
|
24
|
+
apply(compiler: Compiler): void;
|
|
25
|
+
/**
|
|
26
|
+
* Processes the modules in the chunk.
|
|
27
|
+
* @param {Compilation} compilation - The webpack compilation.
|
|
28
|
+
* @param {Chunk} chunk - The chunk to process.
|
|
29
|
+
* @param {Iterable<Module>} modules - The modules in the chunk.
|
|
30
|
+
*/
|
|
31
|
+
private processModules;
|
|
32
|
+
/**
|
|
33
|
+
* Removes the modules from the chunk.
|
|
34
|
+
* @param {Compilation} compilation - The webpack compilation.
|
|
35
|
+
* @param {Chunk} chunk - The chunk to remove modules from.
|
|
36
|
+
*/
|
|
37
|
+
private removeModules;
|
|
38
|
+
}
|
|
39
|
+
export default RemoveEagerModulesFromRuntimePlugin;
|
|
@@ -1,7 +1,2 @@
|
|
|
1
|
-
import { ModuleFederationRuntimePlugin } from
|
|
2
|
-
|
|
3
|
-
//#region src/plugins/container/runtimePlugin.d.ts
|
|
4
|
-
declare function export_default(): ModuleFederationRuntimePlugin;
|
|
5
|
-
//#endregion
|
|
6
|
-
export { export_default as default };
|
|
7
|
-
//# sourceMappingURL=runtimePlugin.d.mts.map
|
|
1
|
+
import { ModuleFederationRuntimePlugin } from '@module-federation/runtime';
|
|
2
|
+
export default function (): ModuleFederationRuntimePlugin;
|
|
@@ -1,6 +1,2 @@
|
|
|
1
|
-
import { ModuleFederationRuntimePlugin } from
|
|
2
|
-
|
|
3
|
-
//#region src/plugins/container/runtimePlugin.d.ts
|
|
4
|
-
declare function export_default(): ModuleFederationRuntimePlugin;
|
|
5
|
-
export = export_default;
|
|
6
|
-
//# sourceMappingURL=runtimePlugin.d.ts.map
|
|
1
|
+
import { ModuleFederationRuntimePlugin } from '@module-federation/runtime';
|
|
2
|
+
export default function (): ModuleFederationRuntimePlugin;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export declare interface WatchOptions {
|
|
2
|
+
/**
|
|
3
|
+
* Delay the rebuilt after the first change. Value is a time in ms.
|
|
4
|
+
*/
|
|
5
|
+
aggregateTimeout?: number;
|
|
6
|
+
/**
|
|
7
|
+
* Resolve symlinks and watch symlink and real file. This is usually not needed as webpack already resolves symlinks ('resolve.symlinks').
|
|
8
|
+
*/
|
|
9
|
+
followSymlinks?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Ignore some files from watching (glob pattern or regexp).
|
|
12
|
+
*/
|
|
13
|
+
ignored?: string | RegExp | string[];
|
|
14
|
+
/**
|
|
15
|
+
* Enable polling mode for watching.
|
|
16
|
+
*/
|
|
17
|
+
poll?: number | boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Stop watching when stdin stream has ended.
|
|
20
|
+
*/
|
|
21
|
+
stdin?: boolean;
|
|
22
|
+
}
|
|
23
|
+
export declare interface CallbackFunction<T> {
|
|
24
|
+
(err?: null | Error, result?: T): any;
|
|
25
|
+
}
|
|
26
|
+
declare global {
|
|
27
|
+
var usedChunks: Set<string>;
|
|
28
|
+
}
|