Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support incremental build when composite is true #416

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Timeless0911
Copy link
Collaborator

@Timeless0911 Timeless0911 commented Nov 12, 2024

Summary

Our current logic using the Typescript compiler API is:

build mode

  1. dts.build: false: basic compiler with createCompilerHost and createProgram
  2. dts.build: true: incremental build with project references, using createSolutionBuilderHost and createSolutionBuilder

watch mode

  1. dts.build: false: incremental program watcher with createWatchCompilerHost and createWatchProgram
  2. dts.build: true: incremental build with project references, using createSolutionBuilderWithWatchHost and createSolutionBuilderWithWatch

In this PR, we add createIncrementalCompilerHost and createIncrementalProgram in build mode to support incremental and deal with projects that with composite: true(incremental: true) and do not to build references dependencies. The watch mode API originally support incremental, so we do not to deal with it in this scenerio.

Our logic is beyond what fork-ts-checker-webpack-plugin do

https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/blob/0fab463b21c6edc4d94834568a3f440241d57887/src/typescript/worker/get-issues-worker.ts#L66-L73

For compiler API that not use SolutionBuilder, it seems the buildinfo not actually takes effect, it just generate buildinfo files. And for tsbuildinfo, due to various issues caused by buildinfo such as remove distPath and monorepo sceniro, we decide to delete buildinfo before generating dts in the next PR which is aligned with Modern.js Module. And our dts processing behaviour such as redirect alias, modify dts extensions and adding banner/footer are also not compatitle with ts cache.

For users who want to keep most align with the default behaviour with tsc in incremetal scenerio, they can enable dts.build: true but I think there's no need to do this if they do not want to build dependencies.

Hopefully there won’t be a day where we switch to using tsc bin files directly, and the ts compiler api will be easier to use with more extensive documentation and able to align related behaviors with tsc more easily.

Related Links

close: #404

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

Copy link

netlify bot commented Nov 12, 2024

Deploy Preview for rslib ready!

Name Link
🔨 Latest commit fce4f8e
🔍 Latest deploy log https://app.netlify.com/sites/rslib/deploys/6735a6214c9c6e0008f9a549
😎 Deploy Preview https://deploy-preview-416--rslib.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

codspeed-hq bot commented Nov 12, 2024

CodSpeed Performance Report

Merging #416 will not alter performance

Comparing feat/incremental-when-composite (fce4f8e) with main (d3c1c16)

Summary

✅ 5 untouched benchmarks

@Timeless0911
Copy link
Collaborator Author

Damn! It's really hard to align buildinfo behaviour with tsc command line

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Failed to generate DTS when running build twice
1 participant