-
Notifications
You must be signed in to change notification settings - Fork 604
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
[rush] Basic support of --watch
for BulkScriptAction (build, rebuild, etc.)
#2458
Merged
Conversation
This file contains 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
dmichon-msft
requested review from
apostolisms,
D4N14L,
halfnibble,
iclanton,
octogonz,
patmill and
sachinjoseph
as code owners
January 29, 2021 01:58
apostolisms
reviewed
Feb 3, 2021
apostolisms
approved these changes
Feb 9, 2021
@dmichon-msft As I recall
Might be useful to test these edge cases, and if they don't work, we can document that. |
octogonz
reviewed
Feb 9, 2021
octogonz
reviewed
Feb 9, 2021
octogonz
approved these changes
Feb 10, 2021
I updated the CLI docs, and fixed some wording in the change log that was referring to internal implementation details. If you're cool with my changes, let's merge this. 👍 Thanks for implementing this -- I can't wait to use it! |
octogonz
changed the title
[rush-lib] Basic support of
[rush] Basic support of Feb 10, 2021
--watch
for BulkScriptAction (build, rebuild, etc.)--watch
for BulkScriptAction (build, rebuild, etc.)
iclanton
reviewed
Feb 10, 2021
Awesome work!! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Globally adds
--watch
support to BulkScriptAction, thereby includingrush build
,rush rebuild
, and any user-defined commands that may do so more efficiently (for example someone may definerush build:incremental
).This allows any repository that defines
npm run build
to get the full benefit of automatic rebuild in response to source code changes, without regard to what tool is used for the individual project's build command.Works best if the
npm run build
(or alternative command) script is optimized for efficient incremental rebuild with disk caching. Consider TypeScript 4, Webpack 5, etc.Fixes #1122
Addresses "Feature 1" from #1202.
Details
Handling of
--watch
Support for
--watch
is implemented inBulkScriptAction
by evaluating the command line parameters to determine the selected projects, then invoking either a single execution or watch mode.Watch mode is implemented as a basic loop:
PackageChangeAnalyzer
). Initially there is no recorded state, so this returns immediately.Change detection is implemented as follows:
PackageChangeAnalyzer
and compare the hashes for the selected projects with the previous (in-memory) execution state. If any projects contain changed hashes, skip directly to (4).chokidar
for the root folders of all selected projects. Any changes trigger a debounced check identical to (1), until such time as one or more projects report changes.PackageChangeAnalyzer
) to hand toTaskSelector
Backwards compatibility concerns:
--watch
through aBulkScriptAction
to underlying npm scripts, that will no longer work.Currently includes the changes from #2422, will be rebased if that goes in. TheSelection
manipulation and refactoring ofTaskSelector
were relevant to implementation.Alternatives considered:
npm run build
, and may produce faster results in certain optimal environments, but limits the general utility of the feature.rush build:watch
. This makes parameter forwarding a bit awkward and would require either architectural changes incommand-line.json
for invoking an npm command with a different name than the rush command or for developers to supply an additional npm command definition tobuild
. Not infeasible, but is a separate issue and alters the ergonomics of the command line. The current implementation conforms to the contract thatrush build --foo --bar
has the same behavior asrush build --foo --bar --watch
with respect to building each project.Future improvements:
TaskRunner
, which currently has no precedence in therushstack
repo. Also requires the file system watcher to continue running during the build process, though this has not been shown to cause any particular problems.TaskSelector
andTaskRunner
and should require no additional work with this implementationHow it was tested
Invoked
rush build --to @microsoft/rush-lib --watch
against rushstack repo and observed rebuild of the changed project and downstream projects when changes were saved to disk.Performing further file system changes during execution results in execution occurring immediately after the previous build pass completes.
Edit: Now that #2422 is in, contains only the directly relevant changes.