diff --git a/README.md b/README.md index a4a0915..dda9c4f 100644 --- a/README.md +++ b/README.md @@ -89,7 +89,7 @@ Requirements: "name": "microapp-42", "exposes": { "./Button": "./src/view-layer/components/Button", - "./Portal": "./src/view-layer/index" + "./Portal": "./src/view-layer/index", "./Http": "./src/wmf-expose/Http" } } @@ -146,6 +146,7 @@ To enable verbose logging add folowing in webpack config: | `remoteEntryUrls` | `RemoteEntryUrls` | `{}` | Base URLs for types. These should target compiled bundles that also contain the types. E.g. with `{ mfeApp: 'https://assets.mydomain.com/mfe-app' }` the types will be downloaded from `'https://assets.mydomain.com/mfe-app/@types/index.d.ts'`. More details available in [this section](#templated-remote-urls) | | `remoteManifestUrls` | `RemoteManifestUrls` | `{}` | URLs to remote manifest files. A manifest contains a URL to a remote entry that is substituted in runtime.

More details available in [this section](#templated-remote-urls) | | `cloudbedsRemoteManifestsBaseUrl` | `string` | `'/remotes/dev-ga'` | Base URL for remote `remote-entries.json` manifest file that is specific to Cloudbeds microapps

_Examples:_
`http://localhost:4480/remotes/dev` (or `/dev-docker`)
`https://cb-front.cloudbeds-dev.com/remotes/[env]`.

`remoteManifestUrls` is ignored when this setting has a value other than `undefined`. | +| `mfPluginName` | `string` | `ModuleFederationPlugin` | The name of the module federation plugin. Change this to "NextFederationPlugin" if you are using this plugin with @module-federation/nextjs-mf | ## Consuming remote types diff --git a/src/plugin.ts b/src/plugin.ts index 0aa7e91..b3f6999 100644 --- a/src/plugin.ts +++ b/src/plugin.ts @@ -24,6 +24,8 @@ import { let isCompiledOnce = false; let isDownloadedOnce = false; +const DEFAULT_MODULE_FEDERATION_PLUGIN_NAME = 'ModuleFederationPlugin'; + export class ModuleFederationTypesPlugin implements WebpackPluginInstance { constructor(public options?: ModuleFederationTypesPluginOptions) {} @@ -55,9 +57,12 @@ export class ModuleFederationTypesPlugin implements WebpackPluginInstance { return; } + // Allow for other module federation plugins such as this "NextFederationPlugin" + const mfPluginName = this.options?.mfPluginName ?? DEFAULT_MODULE_FEDERATION_PLUGIN_NAME; + // Get ModuleFederationPlugin config const federationOptions = compiler.options.plugins.find((plugin) => { - return plugin!.constructor.name === 'ModuleFederationPlugin'; + return plugin!.constructor.name === mfPluginName; }); const federationPluginOptions: ModuleFederationPluginOptions = (federationOptions as any)?._options; if (!federationPluginOptions?.name) { diff --git a/src/types.ts b/src/types.ts index cda1c47..02bc3ae 100644 --- a/src/types.ts +++ b/src/types.ts @@ -37,6 +37,7 @@ export type ModuleFederationTypesPluginOptions = { remoteEntryUrls?: RemoteEntryUrls, remoteManifestUrls?: RemoteManifestUrls, remoteManifestUrl?: string, + mfPluginName?: string cloudbedsRemoteManifestsBaseUrl?: string | '' | 'dev' | 'dev-ga'