Skip to content
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

webpack side file watching #516

Merged
merged 8 commits into from Oct 16, 2020
Merged

Conversation

piotr-oles
Copy link
Collaborator

This PR moves all watching logic to the webpack side.

Motivation

This change allows us to watch for files changes in the same way as tsc does. It means that we can watch for "type-only" files because they become a part of the webpack's compilation (they are added to the compilation.fileDependencies).

Implementation

Each reporter (typescript, eslint) is asked to provide a list of dependencies (files and dirs) which are then watched by webpack. Unfortunately, webpack's directory watching is not very flexible and we are not able to handle the "add new file" case. The solution is hacky and experimental (see InclusiveNodeWatchFileSystem) but it seems to work. I'm not happy with the fact that we re-load SolutionBuilder when we add or remove files. It seems highly inefficient but it works for now and I don't have a better idea.

Notes

I suspect that there will be some bugs/issues with this code as it hooks into some webpack internals. That's why I would like to publish it as alpha and test it in real life :)

In order to watch for new files and type-only files in the webpack's
compilation, we can use `fileDependencies` and 'contextDependencies`
sets. Unfortunately, watchpack will ignore new files by default. To
overcome this limitation, we are overwriting built-in
NodeWatchFileSystem with our custom implementation for directory
watching.
Now there should be no difference between all and webpack scope

BREAKING CHANGE: 🧨 Remove issue.scope option and use new watch architecture
@piotr-oles piotr-oles force-pushed the feature/webpack-side-file-watching branch 2 times, most recently from ff4e149 to 6fd0d27 Compare October 8, 2020 20:29
@johnnyreilly
Copy link
Member

Looking amazing - a lot of failing tests though!

@piotr-oles piotr-oles force-pushed the feature/webpack-side-file-watching branch from 6fd0d27 to a10d1e3 Compare October 10, 2020 14:10
@piotr-oles
Copy link
Collaborator Author

Yes, it's nice because it proves that they really work :D There are some quirks regarding case-sensitiveness in different operating systems and how it's handled by libraries (typescript, fsevents, webpack, chokidar...). I'm trying to make it work :D

@piotr-oles piotr-oles force-pushed the feature/webpack-side-file-watching branch from a10d1e3 to 6cf22d7 Compare October 10, 2020 16:07
@piotr-oles piotr-oles force-pushed the feature/webpack-side-file-watching branch from 6cf22d7 to 839026a Compare October 10, 2020 17:05
@piotr-oles
Copy link
Collaborator Author

Tests are passing, I'm going to ship this experimental version :)

@piotr-oles piotr-oles merged commit fb22e47 into alpha Oct 16, 2020
@piotr-oles piotr-oles deleted the feature/webpack-side-file-watching branch October 16, 2020 19:19
@piotr-oles
Copy link
Collaborator Author

🎉 This PR is included in version 6.0.0-alpha.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@piotr-oles
Copy link
Collaborator Author

🎉 This PR is included in version 6.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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.

None yet

2 participants