Skip to content

Commit 7fde21f

Browse files
Merge branch 'main' into fix-reduce-csp-false-positives
2 parents ee0a638 + de350f3 commit 7fde21f

File tree

5 files changed

+22
-8
lines changed

5 files changed

+22
-8
lines changed

.changeset/weak-spoons-begin.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@module-federation/modern-js': patch
3+
---
4+
5+
fix(modern-js-plugin): adjust fetch type

apps/website-new/docs/en/guide/basic/runtime.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ init({
4646
entry: "http://localhost:3006/remoteEntry.js",
4747
alias: "app2"
4848
},
49-
{
49+
{
5050
name: "@demo/app4",
5151
entry: "http://localhost:3006/remoteEntry.mjs",
5252
alias: "app2",

apps/website-new/docs/en/practice/frameworks/modern/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ Modern.js also supports dependency management with `yarn` and `npm`.
5555
:::
5656

5757

58-
## 创建项目
58+
## Create Project
5959

6060
`@modern-js/create` provides an interactive Q & A interface to initialize the project based on the results, with initialization performed according to the default settings:
6161

packages/modernjs/src/cli/mfRuntimePlugins/auto-fetch-data.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,18 +63,26 @@ const autoFetchData: () => FederationRuntimePlugin = () => ({
6363
}
6464

6565
const dataFetchMap = getDataFetchMap();
66-
const downgradeType = remoteSnapshot.modules.find(
67-
(module) =>
68-
module.moduleName === `${dataFetchName}${DATA_FETCH_CLIENT_SUFFIX}`,
69-
)
66+
const hasSSRAsset = Boolean(remoteSnapshot.ssrRemoteEntry);
67+
const hasDataFetchClient = Boolean(
68+
remoteSnapshot.modules.find(
69+
(module) =>
70+
module.moduleName === `${dataFetchName}${DATA_FETCH_CLIENT_SUFFIX}`,
71+
),
72+
);
73+
const downgradeType = hasDataFetchClient
7074
? MF_DATA_FETCH_TYPE.FETCH_CLIENT
71-
: MF_DATA_FETCH_TYPE.FETCH_SERVER;
75+
: hasSSRAsset
76+
? MF_DATA_FETCH_TYPE.FETCH_SERVER
77+
: MF_DATA_FETCH_TYPE.FETCH_CLIENT;
7278
let finalDataFetchId = dataFetchId;
7379

7480
if (typeof window !== 'undefined') {
7581
finalDataFetchId =
7682
downgradeType === MF_DATA_FETCH_TYPE.FETCH_CLIENT
77-
? `${dataFetchId}${DATA_FETCH_CLIENT_SUFFIX}`
83+
? hasDataFetchClient
84+
? `${dataFetchId}${DATA_FETCH_CLIENT_SUFFIX}`
85+
: dataFetchId
7886
: dataFetchId;
7987
}
8088

packages/node/src/runtimePlugin.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ export const resolveUrl = (
177177
} catch {
178178
const entryUrl =
179179
returnFromCache(remoteName) || returnFromGlobalInstances(remoteName);
180+
180181
if (!entryUrl) return null;
181182

182183
const url = new URL(entryUrl);

0 commit comments

Comments
 (0)