Skip to content

Commit

Permalink
Merge branch 'main' into use-eval-require
Browse files Browse the repository at this point in the history
  • Loading branch information
ScriptedAlchemy committed Nov 17, 2024
2 parents 451fcad + 9ec1003 commit eb61e96
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
6 changes: 6 additions & 0 deletions packages/nextjs-mf/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @module-federation/nextjs-mf

## 8.8.0

### Minor Changes

- 5ad75fd: Enabled JSON manifest remote protocol for NextJS plugin

## 8.7.10

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/nextjs-mf/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@module-federation/nextjs-mf",
"version": "8.7.10",
"version": "8.8.0",
"license": "MIT",
"main": "dist/src/index.js",
"types": "dist/src/index.d.ts",
Expand Down
36 changes: 36 additions & 0 deletions packages/nextjs-mf/src/plugins/container/runtimePlugin.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { FederationRuntimePlugin } from '@module-federation/runtime/types';
import {
ModuleInfo,
ConsumerModuleInfoWithPublicPath,
} from '@module-federation/sdk';

export default function (): FederationRuntimePlugin {
return {
Expand Down Expand Up @@ -182,7 +186,39 @@ export default function (): FederationRuntimePlugin {

return args;
},
loadRemoteSnapshot(args) {
const { from, remoteSnapshot, manifestUrl, manifestJson, options } = args;

// ensure snapshot is loaded from manifest
if (
from !== 'manifest' ||
!manifestUrl ||
!manifestJson ||
!('publicPath' in remoteSnapshot)
) {
return args;
}

// re-assign publicPath based on remoteEntry location
if (options.inBrowser) {
remoteSnapshot.publicPath = remoteSnapshot.publicPath.substring(
0,
remoteSnapshot.publicPath.lastIndexOf('/_next/') + 7,
);
} else {
const serverPublicPath = manifestUrl.substring(
0,
manifestUrl.indexOf('mf-manifest.json'),
);

remoteSnapshot.publicPath = serverPublicPath;
if ('publicPath' in manifestJson.metaData) {
manifestJson.metaData.publicPath = serverPublicPath;
}
}

return args;
},
resolveShare: function (args: any) {
if (
args.pkgName !== 'react' &&
Expand Down

0 comments on commit eb61e96

Please sign in to comment.