Floffah / esbuild-plugin-d.ts

🔌 Build Typescript declarations with ESBuild
http://npm.im/esbuild-plugin-d.ts
MIT License
57 stars 6 forks source link

Plugin doesn't generate the tsconfig.tsbuildinfo file used for incremental builds #6

Closed gablabelle closed 2 years ago

gablabelle commented 2 years ago

When running yarn tsc --build I get an output tsconfig.tsbuildinfo file used the the Typescript incremental builds. Subsequent builds are much faster.

This file doesn't get generated when using esbuild-plugin-d.ts

Even if I specify the tsBuildInfoFile option, same thing.

{
  "extends": "../../tsconfig.settings.json",
  "compilerOptions": {
    "composite": true,
    "tsBuildInfoFile": "tsconfig.tsbuildinfo",
    "outDir": "lib",
    "rootDir": "src"
  },
  "include": ["src/**/*"],
  "exclude": ["src/**/*.test.ts", "src/**/*.test.tsx"]
}
Floffah commented 2 years ago

I think the main cause for this is that I made a method that turns this on automatically and that may be messing with it. Ill have a look

gablabelle commented 2 years ago

I think the main cause for this is that I made a method that turns this on automatically and that may be messing with it. Ill have a look!

I might be wrong but I feel this could be a huge improvement for performances in our monorepo.

Floffah commented 2 years ago

I might be wrong but I feel this could be a huge improvement for performances in our monorepo.

I agree, for a monorepo this may be very benefitial. I had a look and it seems to do it here https://github.com/Floffah/esbuild-plugin-d.ts/blob/master/src/plugin.ts#L50-L58 if it is able to find your package.json although this may be broken and may be worth removing or making it toggleable. I will make a new release with these fixes soon

gablabelle commented 2 years ago

Also it seems that you should be using both createIncrementalProgram and createIncrementalCompilerHost in order to avoid the tsbuildinfo file to be ignore as explained here

According to the release notes

For creating incremental builds, users can leverage the createIncrementalProgram and createIncrementalCompilerHost APIs.

You seem to be missing the createIncrementalCompilerHost usage at https://github.com/Floffah/esbuild-plugin-d.ts/blob/master/src/plugin.ts#L61

Floffah commented 2 years ago

Also it seems that you should be using both createIncrementalProgram and createIncrementalCompilerHost in order to avoid the tsbuildinfo file to be ignore as explained here

According to the release notes

For creating incremental builds, users can leverage the createIncrementalProgram and createIncrementalCompilerHost APIs.

You seem to be missing the createIncrementalCompilerHost usage at https://github.com/Floffah/esbuild-plugin-d.ts/blob/master/src/plugin.ts#L61

I'll add these when I get time to implement the automatic tsbuildinfo system

Floffah commented 2 years ago

Took a while to get round to it but I have switched to incremental programs and hosts and saw the build time for the test go down to 50ms. Let me know if this broke anything after installing 1.1.0