Simplify gulp to just use 'tsc -b' to build, update to gulp@4 #29619
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This completely rewrites our gulpfile to support gulp@4 and drops 'gulp-typescript' in favor of just calling
tsc -b
for the various projects.NOTE: This requires you have an updated global install of gulp-cli:
Problems with Parallelism
The biggest issue with leveraging
tsc -b
is that parallel tasks would result in multiple running instances oftsc -b
for top-level projects (such astsc
,run.js
, etc.). Since these processes do not communicate with each other, its highly likely that each instance would attempt to build the same upstream project at the same time.To avoid this, each call to
tsc -b
is queued for a period of time (currently 100ms) and then all projects to be built are passed to a single instance oftsc -b
. This way, upstream projects are only built once. However, this has the downside of having all downstream projects in the same process, meaning the process consumes more memory and we cannot leverage parallel compilation.We may in the future want to consider how to allow for better parallelism and coordination with
tsc -b
, even something as simple as an option totsc -b
that writes out a project-specific lock file before building a project. Other options might include leveraging unix sockets/named pipes for inter-process communication."Watch" mode
The other unsolved issue is how to best handle "watch mode". Gulp's
watch
function knows only about file system changes. Even if we pass multiple projects totsc -b --watch
, Gulp'swatch
could trigger on one output being written for a downstream project even while other downstream projects are still being built. Because there is no coordination, this would result in a test run starting prematurely. While we can have gulp watch the sources and runtsc -b
without the--watch
option, we then lose the incremental build-time benefits oftsc -b --watch
. For now, our only option is to tinker with the delay passed togulp.watch
until we find one that is "good enough" for most purposes.