Skip to content

List of files modified during watch cycle is now accessible to plugins#9679

Merged
sokra merged 18 commits intowebpack:masterfrom
maxwoo-houzz:master
Nov 18, 2019
Merged

List of files modified during watch cycle is now accessible to plugins#9679
sokra merged 18 commits intowebpack:masterfrom
maxwoo-houzz:master

Conversation

@maxwoo-houzz
Copy link
Copy Markdown
Contributor

The motivation behind this PR is discussed in issue #9632, but to recap, before the only way to find out which changed files triggered a re-compilation was to use WatchPack's mtimes variable, but this variable has been removed since WatchPack 2.0.0 (beta), so this PR provides a replacement way of getting access to this list of changed files.

What kind of change does this PR introduce?

This PR adds a property to the compiler to expose the files modified during watch mode. It also fixes the test for removed files (RemoveFiles.test.js) and adds a new test ModifiedFiles.test.js

Did you add tests for your changes?

Yes, in ModifiedFiles.test.js

Does this PR introduce a breaking change?

No

What needs to be documented once your changes are merged?

the new compiler property modifiedFiles should be documented (though note that removedFiles isn't documented either). Also, it's important to note that currently, modifiedFiles includes all removed files. This is due to this line of NodeWatchFileSystem, which was introduced before my PR.

@jsf-clabot
Copy link
Copy Markdown

jsf-clabot commented Sep 10, 2019

CLA assistant check
All committers have signed the CLA.

@webpack-bot
Copy link
Copy Markdown
Contributor

For maintainers only:

  • This need to be documented (issue in webpack/webpack.js.org will be filed when merged)

@webpack-bot
Copy link
Copy Markdown
Contributor

Hi @maxwoo-houzz.

Just a little hint from a friendly bot about the best practice when submitting pull requests:

Don't submit pull request from your own master branch. It's recommended to create a feature branch for the PR.

You don't have to change it for this PR, just make sure to follow this hint the next time you submit a PR.

maxwoo-houzz added a commit to maxwoo-houzz/webpack that referenced this pull request Sep 13, 2019
we don't know when the watchRun hook is called, so if we define watchRunFinished
inside the hook, it could be undefined when it gets to the watchRunFinished.then(...) call
so we should define it outside the hook to ensure that it is defined by the time
watchRunFinished.then(...) is called

also use watcher.close() callback to call done(), to ensure that it's called after
the watcher is finished closed

see webpack#9679
    files/d5b421a408dc59ee0120019cc0947330f53fee2a#r322592231
@webpack-bot
Copy link
Copy Markdown
Contributor

@maxwoo-houzz Thanks for your update.

I labeled the Pull Request so reviewers will review it again.

@sokra Please review the new changes.

maxwoo-houzz added a commit to maxwoo-houzz/webpack that referenced this pull request Sep 13, 2019
see webpack#9679 (comment)

also renamed "ChangedFiles" to "ModifiedFiles" in test description
removed a stray log statement
@maxwoo-houzz maxwoo-houzz requested a review from sokra September 17, 2019 23:57
@sokra
Copy link
Copy Markdown
Member

sokra commented Sep 24, 2019

Looks good, I can merge it once you signed the CLA: https://cla.js.foundation/webpack/webpack?pullRequest=9679

@sokra sokra closed this Sep 26, 2019
@sokra sokra reopened this Sep 26, 2019
@maxwoo-houzz
Copy link
Copy Markdown
Contributor Author

@sokra sorry I had to double check with some people about the CLA but I just signed it!

@alexander-akait
Copy link
Copy Markdown
Member

@maxwoo-houzz CLA problem fixed

@alexander-akait
Copy link
Copy Markdown
Member

/cc @sokra

sokra pushed a commit to maxwoo-houzz/webpack that referenced this pull request Nov 6, 2019
we don't know when the watchRun hook is called, so if we define watchRunFinished
inside the hook, it could be undefined when it gets to the watchRunFinished.then(...) call
so we should define it outside the hook to ensure that it is defined by the time
watchRunFinished.then(...) is called

also use watcher.close() callback to call done(), to ensure that it's called after
the watcher is finished closed

see webpack#9679
    files/d5b421a408dc59ee0120019cc0947330f53fee2a#r322592231
sokra pushed a commit to maxwoo-houzz/webpack that referenced this pull request Nov 6, 2019
see webpack#9679 (comment)

also renamed "ChangedFiles" to "ModifiedFiles" in test description
removed a stray log statement
@thasmo
Copy link
Copy Markdown

thasmo commented Nov 6, 2019

It's done, just forgot to merge it...

Thanks! :D

@sokra
Copy link
Copy Markdown
Member

sokra commented Nov 6, 2019

It's done, just forgot to merge it...
Thanks! :D

CI is broken now... Working on it...

maxwoo-houzz and others added 15 commits November 15, 2019 13:49
avoid creating additional arrays by allowing Iterable on WatchFileSystem interface
… to modifiedFiles

this is just merging branch 'test-expose-modified-files' into master
we don't know when the watchRun hook is called, so if we define watchRunFinished
inside the hook, it could be undefined when it gets to the watchRunFinished.then(...) call
so we should define it outside the hook to ensure that it is defined by the time
watchRunFinished.then(...) is called

also use watcher.close() callback to call done(), to ensure that it's called after
the watcher is finished closed

see webpack#9679
    files/d5b421a408dc59ee0120019cc0947330f53fee2a#r322592231
see webpack#9679 (comment)

also renamed "ChangedFiles" to "ModifiedFiles" in test description
removed a stray log statement
@webpack-bot
Copy link
Copy Markdown
Contributor

It looks like this Pull Request doesn't include enough test cases (based on Code Coverage analysis of the PR diff).

A PR need to be covered by tests if you add a new feature (we want to make sure that your feature is working) or if you fix a bug (we want to make sure that we don't run into a regression in future).

@maxwoo-houzz Please check if this is appliable to your PR and if you can add more test cases.

Read the test readme for details how to write test cases.

@sokra sokra merged commit 0c7e135 into webpack:master Nov 18, 2019
@sokra
Copy link
Copy Markdown
Member

sokra commented Nov 18, 2019

Thanks

@maxwoo-houzz
Copy link
Copy Markdown
Contributor Author

@sokra thanks for all those fixes, I couldn't really figure out what the problem was so I'm glad you got it sorted!

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.

7 participants