Skip to content

Commit 6ee10aa

Browse files
authored
fix(dts-plugin): replace sourceEntry with index if the value is '.' (#2624)
1 parent a129fca commit 6ee10aa

File tree

3 files changed

+21
-7
lines changed

3 files changed

+21
-7
lines changed

.changeset/nine-queens-ring.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: replace sourceEntry with index if the value is '.'

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

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import {
3030
HOST_API_TYPES_FILE_NAME,
3131
} from '../constant';
3232
import { fileLog } from '../../server';
33-
import { axiosGet } from './utils';
33+
import { axiosGet, isDebugMode } from './utils';
3434

3535
export const MODULE_DTS_MANAGER_IDENTIFIER = 'MF DTS Manager';
3636

@@ -157,11 +157,17 @@ class DTSManager {
157157
fs.writeFileSync(apiTypesPath, apiTypes);
158158
}
159159

160-
if (remoteOptions.deleteTypesFolder) {
161-
await rm(retrieveMfTypesPath(tsConfig, remoteOptions), {
162-
recursive: true,
163-
force: true,
164-
});
160+
try {
161+
if (remoteOptions.deleteTypesFolder) {
162+
await rm(retrieveMfTypesPath(tsConfig, remoteOptions), {
163+
recursive: true,
164+
force: true,
165+
});
166+
}
167+
} catch (err) {
168+
if (isDebugMode()) {
169+
console.error(err);
170+
}
165171
}
166172
console.log(ansiColors.green('Federated types created correctly'));
167173
} catch (error) {

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,10 @@ const createHost = (
8989
);
9090

9191
for (const sourceFile of sourceFiles || []) {
92-
const sourceEntry = mapExposeToEntry[normalize(sourceFile.fileName)];
92+
let sourceEntry = mapExposeToEntry[normalize(sourceFile.fileName)];
93+
if (sourceEntry === '.') {
94+
sourceEntry = 'index';
95+
}
9396
if (sourceEntry) {
9497
const mfeTypeEntry = join(
9598
mfTypePath,

0 commit comments

Comments
 (0)