Skip to content

Commit 7a37360

Browse files
authored
fix(dts-plugin): consume api types if adding new one (#3536)
1 parent c9ac295 commit 7a37360

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

.changeset/dry-geese-drum.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@module-federation/dts-plugin': patch
3+
---
4+
5+
fix(dts-plugin): consume api types if adding new one

packages/dts-plugin/src/core/lib/DTSManager.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,8 +264,10 @@ class DTSManager {
264264
);
265265
const filePath = path.join(destinationPath, REMOTE_API_TYPES_FILE_NAME);
266266
fs.writeFileSync(filePath, apiTypeFile);
267+
const existed = this.loadedRemoteAPIAlias.has(remoteInfo.alias);
267268
this.loadedRemoteAPIAlias.add(remoteInfo.alias);
268269
fileLog(`success`, 'downloadAPITypes', 'info');
270+
return existed;
269271
} catch (err) {
270272
fileLog(
271273
`Unable to download "${remoteInfo.name}" api types, ${err}`,
@@ -471,7 +473,13 @@ class DTSManager {
471473
zipUrl: remoteTarPath || requiredRemoteInfo.zipUrl,
472474
},
473475
);
474-
await this.downloadAPITypes(requiredRemoteInfo, destinationPath);
476+
const addNew = await this.downloadAPITypes(
477+
requiredRemoteInfo,
478+
destinationPath,
479+
);
480+
if (addNew) {
481+
this.consumeAPITypes(hostOptions);
482+
}
475483
fileLog(`consumeTypes end`, 'updateTypes', 'info');
476484
};
477485
fileLog(
@@ -502,7 +510,6 @@ class DTSManager {
502510
await consumeTypes(
503511
this.updatedRemoteInfos[updatedRemoteInfo.name],
504512
);
505-
this.consumeAPITypes(hostOptions);
506513
};
507514
if (!this.updatedRemoteInfos[updatedRemoteInfo.name]) {
508515
const parsedRemoteInfo = retrieveRemoteInfo({

0 commit comments

Comments
 (0)