FluidFramework icon indicating copy to clipboard operation
FluidFramework copied to clipboard

improvement(fluid-build): Ignore some tsconfig fields when determining incremental build

Open tylerbutler opened this issue 1 year ago • 2 comments

When building, fluid-build checks that the cached buildInfo options -- that is, the tsconfig options used to build originally -- match the current tsconfig. If they don't match, then the cache is outdated and a rebuild is needed.

However, there are some tsconfig settings that TypeScript doesn't seem to include in the tsbuildinfo. This makes any builds including these settings always fail this check. We now special-case the properties in this set -- any differences in those fields are ignored. Those fields are:

  • allowJs
  • checkJs

IMPORTANT: This is a somewhat unsafe action. Technically speaking, we don't know for sure the incremental build status when there is ANY difference between these settings. Thus the safest thing to do is to assume a rebuild is needed. Projects using the ignored settings may exhibit strange incremental build behavior.

For that reason, this behavior can be disabled completely using the _FLUID_BUILD_DISABLE_IGNORE_TSC_OPTIONS_ environment variable. If that variable is set to any non-empty value, the list of ignored options will not be checked.

Projects in the client release group that use these settings:

  • property-properties
  • ai-collab

tylerbutler avatar Nov 23 '24 23:11 tylerbutler

Reviving this because I still think it's valuable. Need to address the feedback.

tylerbutler avatar Mar 20 '25 22:03 tylerbutler

Marking draft while I incorporate feedback.

tylerbutler avatar Jun 13 '25 00:06 tylerbutler

The alternative approach would be to modify the one object that might have the to be ignored properties and delete them. Then use existing deep equality check (isEqual before).

I switched to this approach. Good idea.

tylerbutler avatar Jun 19 '25 23:06 tylerbutler

~~Would it be better to detect if the flag changes and trigger the incremental build by writing those out as an additional separate done file?~~

Actually, what is happening is that tsc has a bug, where on incremental build even if the switch allowJs and checkJs changes, the tsbuildinfo file doesn't get updated if no other file changes. So incremental build check would always fail and block skipping the build.

When doing a clean build, those flags would be included in the tsbuildinfo, so I believe incremental build would continue to work if those flags doesn't change.

The newest version 5.8.3 of tsc does it correctly (looks like it got fixed started in 5.6.2), so fluid-build incremental behavior will be corrected if these flags changes when typescript compiler version is updated.

It's probably fine to have this escape hatch to work around the tsc bug, but might want to update comment.

curtisman avatar Jul 02 '25 13:07 curtisman

This PR has been automatically marked as stale because it has had no activity for 60 days. It will be closed if no further activity occurs within 8 days of this comment. Thank you for your contributions to Fluid Framework!