Skip to content

Commit

Permalink
feat(nextjs-mf): enable federation manifest (#2387)
Browse files Browse the repository at this point in the history
Co-authored-by: Rodrigo Yokota <[email protected]>
Co-authored-by: ScriptedAlchemy <[email protected]>
  • Loading branch information
3 people authored Apr 25, 2024
1 parent 9f32af9 commit cb1415f
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/gorgeous-boats-grab.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@module-federation/nextjs-mf': patch
---

enable manifest to be generated on client-side when setting publicPath
5 changes: 5 additions & 0 deletions .changeset/wise-tools-float.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@module-federation/nextjs-mf': patch
---

enable manifest for server
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ export function applyClientPlugins(
): void {
const { webpack } = compiler;
const { remotes, name } = options;
//@ts-ignore
compiler.options.output.publicPath = 'auto';

if (compiler.options.output.publicPath === '/_next/') {
compiler.options.output.publicPath = 'auto';
}
// Build will hang without this. Likely something in my plugin
compiler.options.optimization.splitChunks = undefined;

Expand Down
6 changes: 4 additions & 2 deletions packages/nextjs-mf/src/plugins/NextFederationPlugin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
'use strict';

import type {
ModuleFederationPluginOptions,
NextFederationPluginExtraOptions,
NextFederationPluginOptions,
} from '@module-federation/utilities';
Expand Down Expand Up @@ -141,7 +140,7 @@ export class NextFederationPlugin {
private getNormalFederationPluginOptions(
compiler: Compiler,
isServer: boolean,
): ModuleFederationPluginOptions {
): moduleFederationPlugin.ModuleFederationPluginOptions {
const defaultShared = this._extraOptions.skipSharingNextInternals
? {}
: retrieveDefaultShared(isServer);
Expand Down Expand Up @@ -178,6 +177,9 @@ export class NextFederationPlugin {
...defaultShared,
...this._options.shared,
},
...(isServer
? { manifest: { filePath: '' } }
: { manifest: { filePath: '/static/chunks' } }),
// nextjs project needs to add config.watchOptions = ['**/node_modules/**', '**/@mf-types/**'] to prevent loop types update
dts: this._options.dts ?? false,
};
Expand Down

0 comments on commit cb1415f

Please sign in to comment.