Skip to content

Commit

Permalink
perf(dts-plugin): enable tsbuildinfo (#3506)
Browse files Browse the repository at this point in the history
  • Loading branch information
claneo authored Feb 20, 2025
1 parent 1448309 commit 5ebc53f
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/cuddly-turkeys-cry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@module-federation/dts-plugin': minor
---

feat: enable tsc incremental build
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ When compiling the exported (`exposes`) file TS type, the current project's `tsc

Execute the `cmd` command in the error message parameter in the terminal, and repair the file or `tsconfig` according to the error message.

If you want to ignore the type check error in ts, you can set [`compilerOptions.noCheck`](https://www.typescriptlang.org/tsconfig/#noCheck) to `true` in `tsconfig.json` (This option is only supported for ts 5.5 and above)

If the `cmd` command is executed without an error, but the error TS compilation fails is still reported, you need to check the `exposes` field in `ModuleFederationPlugin`:

```ts title="[modern|rspack|rsbuild|webpack].config.[js,ts]"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import ErrorCodeTitle from '@components/ErrorCodeTitle';

在 terminal 中执行报错信息参数中的 `cmd` 命令,根据错误信息对文件或者 `tsconfig` 进行修复。

若你希望忽略 ts 中的类型检查错误,可在 `tsconfig.json` 中设置 [`compilerOptions.noCheck`](https://www.typescriptlang.org/tsconfig/#noCheck)`true`(该选项仅支持 ts 5.5 及以上版本)

`cmd` 命令执行无报错,但仍然报错 TS 编译失败,需要检查 `ModuleFederationPlugin` 中的 `exposes`字段:

```ts title="[modern|rspack|rsbuild|webpack].config.[js,ts]"
Expand Down
10 changes: 10 additions & 0 deletions packages/dts-plugin/src/core/configurations/remotePlugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ describe('hostPlugin', () => {
'dist/@mf-types/compiled-types',
),
rootDir: resolve(__dirname),
incremental: true,
tsBuildInfoFile: resolve(
remoteOptions.context,
'node_modules/.cache/.tsbuildinfo',
),
},
files: ['./src/components/button', './src/components/anotherButton'],
include: [],
Expand Down Expand Up @@ -118,6 +123,11 @@ describe('hostPlugin', () => {
'dist/typesFolder/compiledTypesFolder',
),
rootDir: resolve(__dirname),
incremental: true,
tsBuildInfoFile: resolve(
remoteOptions.context,
'node_modules/.cache/.tsbuildinfo',
),
},
exclude: [],
include: [],
Expand Down
2 changes: 2 additions & 0 deletions packages/dts-plugin/src/core/configurations/remotePlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ const readTsConfig = (
noEmit: false,
declaration: true,
outDir,
incremental: true,
tsBuildInfoFile: resolve(context, 'node_modules/.cache/.tsbuildinfo'),
};

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

0 comments on commit 5ebc53f

Please sign in to comment.