Skip to content

Commit f7a6d3f

Browse files
authored
fix: download api types when types refresh (#2645)
1 parent 804cc3b commit f7a6d3f

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

.changeset/nervous-cougars-switch.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: download api types when types refresh

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

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,16 @@ class DTSManager {
444444
(i) => i.name === remoteName,
445445
);
446446

447+
const consumeTypes = async (
448+
requiredRemoteInfo: Required<RemoteInfo>,
449+
) => {
450+
const [_alias, destinationPath] = await this.consumeTargetRemotes(
451+
hostOptions,
452+
requiredRemoteInfo,
453+
);
454+
await this.downloadAPITypes(requiredRemoteInfo, destinationPath);
455+
};
456+
447457
if (!loadedRemoteInfo) {
448458
const remoteInfo = Object.values(mapRemotesToDownload).find(
449459
(item) => {
@@ -456,20 +466,11 @@ class DTSManager {
456466
await this.requestRemoteManifest(remoteInfo);
457467
this.remoteAliasMap[remoteInfo.alias] = requiredRemoteInfo;
458468
}
459-
await this.consumeTargetRemotes(
460-
hostOptions,
461-
this.remoteAliasMap[remoteInfo.alias],
462-
);
469+
await consumeTypes(this.remoteAliasMap[remoteInfo.alias]);
463470
} else if (updatedRemoteInfo) {
464471
const consumeDynamicRemoteTypes = async () => {
465-
const [_destinationFolder, destinationPath] =
466-
await this.consumeTargetRemotes(
467-
hostOptions,
468-
this.updatedRemoteInfos[updatedRemoteInfo.name],
469-
);
470-
await this.downloadAPITypes(
472+
await consumeTypes(
471473
this.updatedRemoteInfos[updatedRemoteInfo.name],
472-
destinationPath,
473474
);
474475
this.consumeAPITypes(hostOptions);
475476
};
@@ -498,7 +499,7 @@ class DTSManager {
498499
}
499500
}
500501
} else {
501-
await this.consumeTargetRemotes(hostOptions, loadedRemoteInfo);
502+
await consumeTypes(loadedRemoteInfo);
502503
}
503504
}
504505
} catch (err) {

0 commit comments

Comments
 (0)