Skip to content

Commit

Permalink
fix(dts-plugin): cache file should have name as its unique path
Browse files Browse the repository at this point in the history
  • Loading branch information
2heal1 committed Feb 20, 2025
1 parent 5ebc53f commit b136334
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/orange-days-kiss.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@module-federation/dts-plugin': patch
---

fix(dts-plugin): cache file should have name as its unique path
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ describe('hostPlugin', () => {
incremental: true,
tsBuildInfoFile: resolve(
remoteOptions.context,
'node_modules/.cache/.tsbuildinfo',
`node_modules/.cache/${remoteOptions.moduleFederationConfig.name}/.tsbuildinfo`,
),
},
files: ['./src/components/button', './src/components/anotherButton'],
Expand All @@ -76,7 +76,7 @@ describe('hostPlugin', () => {
typesFolder: '@mf-types',
compiledTypesFolder: 'compiled-types',
hostRemoteTypesFolder: '@mf-types',
deleteTypesFolder: true,
deleteTypesFolder: false,
moduleFederationConfig,
compilerInstance: 'tsc',
compileInChildProcess: false,
Expand Down Expand Up @@ -126,7 +126,7 @@ describe('hostPlugin', () => {
incremental: true,
tsBuildInfoFile: resolve(
remoteOptions.context,
'node_modules/.cache/.tsbuildinfo',
`node_modules/.cache/${remoteOptions.moduleFederationConfig.name}/.tsbuildinfo`,
),
},
exclude: [],
Expand Down
16 changes: 14 additions & 2 deletions packages/dts-plugin/src/core/configurations/remotePlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ const readTsConfig = (
context,
additionalFilesToCompile,
outputDir,
moduleFederationConfig,
}: Required<RemoteOptions>,
mapComponentsToExpose: Record<string, string>,
): TsConfigJson => {
Expand Down Expand Up @@ -97,13 +98,16 @@ const readTsConfig = (
noEmit: false,
declaration: true,
outDir,
incremental: true,
tsBuildInfoFile: resolve(context, 'node_modules/.cache/.tsbuildinfo'),
};

rawTsConfigJson.compilerOptions = rawTsConfigJson.compilerOptions || {};

rawTsConfigJson.compilerOptions = {
incremental: true,
tsBuildInfoFile: resolve(
context,
`node_modules/.cache/${moduleFederationConfig.name}/.tsbuildinfo`,
),
...rawTsConfigJson.compilerOptions,
...defaultCompilerOptions,
};
Expand Down Expand Up @@ -183,6 +187,14 @@ export const retrieveRemoteConfig = (options: RemoteOptions) => {
const mapComponentsToExpose = resolveExposes(remoteOptions);
const tsConfig = readTsConfig(remoteOptions, mapComponentsToExpose);

if (
tsConfig.compilerOptions.incremental &&
tsConfig.compilerOptions.tsBuildInfoFile &&
options.deleteTypesFolder !== true
) {
remoteOptions.deleteTypesFolder = false;
}

return {
tsConfig,
mapComponentsToExpose,
Expand Down

0 comments on commit b136334

Please sign in to comment.