Skip to content

Commit

Permalink
fix: replace sourceEntry with index if the value is '.'
Browse files Browse the repository at this point in the history
  • Loading branch information
2heal1 committed Jun 17, 2024
1 parent e758715 commit a173888
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/nine-queens-ring.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@module-federation/dts-plugin': patch
---

fix: replace sourceEntry with index if the value is '.'
18 changes: 12 additions & 6 deletions packages/dts-plugin/src/core/lib/DTSManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import {
HOST_API_TYPES_FILE_NAME,
} from '../constant';
import { fileLog } from '../../server';
import { axiosGet } from './utils';
import { axiosGet, isDebugMode } from './utils';

export const MODULE_DTS_MANAGER_IDENTIFIER = 'MF DTS Manager';

Expand Down Expand Up @@ -157,11 +157,17 @@ class DTSManager {
fs.writeFileSync(apiTypesPath, apiTypes);
}

if (remoteOptions.deleteTypesFolder) {
await rm(retrieveMfTypesPath(tsConfig, remoteOptions), {
recursive: true,
force: true,
});
try {
if (remoteOptions.deleteTypesFolder) {
await rm(retrieveMfTypesPath(tsConfig, remoteOptions), {
recursive: true,
force: true,
});
}
} catch (err) {
if (isDebugMode()) {
console.error(err);
}
}
console.log(ansiColors.green('Federated types created correctly'));
} catch (error) {
Expand Down
5 changes: 4 additions & 1 deletion packages/dts-plugin/src/core/lib/typeScriptCompiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,10 @@ const createHost = (
);

for (const sourceFile of sourceFiles || []) {
const sourceEntry = mapExposeToEntry[normalize(sourceFile.fileName)];
let sourceEntry = mapExposeToEntry[normalize(sourceFile.fileName)];
if (sourceEntry === '.') {
sourceEntry = 'index';
}
if (sourceEntry) {
const mfeTypeEntry = join(
mfTypePath,
Expand Down

0 comments on commit a173888

Please sign in to comment.