Simplify gulp to just use 'tsc -b' to build, update to gulp@4#29619
Merged
Conversation
Contributor
Author
|
@ahejlsberg: This also adds a For comparison, in a clean workspace after
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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 -bfor the various projects.NOTE: This requires you have an updated global install of gulp-cli:
Problems with Parallelism
The biggest issue with leveraging
tsc -bis that parallel tasks would result in multiple running instances oftsc -bfor 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 -bis 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 -bthat 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
watchfunction knows only about file system changes. Even if we pass multiple projects totsc -b --watch, Gulp'swatchcould 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 -bwithout the--watchoption, we then lose the incremental build-time benefits oftsc -b --watch. For now, our only option is to tinker with the delay passed togulp.watchuntil we find one that is "good enough" for most purposes.