Skip to content

Commit 85ef6c4

Browse files
authored
fix(manifest): stats should add prefetchInterface if enable dataPrefetch (#3327)
1 parent ee39a50 commit 85ef6c4

File tree

3 files changed

+23
-16
lines changed

3 files changed

+23
-16
lines changed

.changeset/shaggy-ligers-teach.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@module-federation/manifest': patch
3+
---
4+
5+
fix(manifest): stats should add prefetchInterface if enable dataPrefetch

packages/manifest/src/ManifestManager.ts

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import path from 'path';
21
import fs from 'fs';
32
import chalk from 'chalk';
43
import {
@@ -103,20 +102,6 @@ class ManifestManager {
103102
return sum;
104103
}, [] as ManifestRemote[]);
105104

106-
let prefetchInterface = false;
107-
const prefetchFilePath = path.resolve(
108-
compiler.options.context || process.cwd(),
109-
`node_modules/.mf/${encodeName(stats.name)}/${MFPrefetchCommon.fileName}`,
110-
);
111-
const existPrefetch = fs.existsSync(prefetchFilePath);
112-
if (existPrefetch) {
113-
const content = fs.readFileSync(prefetchFilePath).toString();
114-
if (content) {
115-
prefetchInterface = true;
116-
}
117-
}
118-
stats.metaData.prefetchInterface = prefetchInterface;
119-
120105
this._manifest = manifest;
121106

122107
const manifestFileName = this.fileName;

packages/manifest/src/StatsManager.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
/* eslint-disable max-lines-per-function */
22
/* eslint-disable @typescript-eslint/member-ordering */
33
/* eslint-disable max-depth */
4-
4+
import fs from 'fs';
5+
import path from 'path';
56
import {
67
StatsRemote,
78
StatsBuildInfo,
@@ -11,6 +12,8 @@ import {
1112
StatsAssets,
1213
moduleFederationPlugin,
1314
RemoteEntryType,
15+
encodeName,
16+
MFPrefetchCommon,
1417
} from '@module-federation/sdk';
1518
import {
1619
Compilation,
@@ -136,6 +139,20 @@ class StatsManager {
136139
pluginVersion: this._pluginVersion,
137140
};
138141

142+
let prefetchInterface = false;
143+
const prefetchFilePath = path.resolve(
144+
compiler.options.context || process.cwd(),
145+
`node_modules/.mf/${encodeName(name!)}/${MFPrefetchCommon.fileName}`,
146+
);
147+
const existPrefetch = fs.existsSync(prefetchFilePath);
148+
if (existPrefetch) {
149+
const content = fs.readFileSync(prefetchFilePath).toString();
150+
if (content) {
151+
prefetchInterface = true;
152+
}
153+
}
154+
metaData.prefetchInterface = prefetchInterface;
155+
139156
if (this._options.getPublicPath) {
140157
if ('publicPath' in metaData) {
141158
delete metaData.publicPath;

0 commit comments

Comments
 (0)