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

feat(gatsby): Switch over to watchpack #15854

Closed
wants to merge 1 commit into from

Conversation

sidharthachatterjee
Copy link
Contributor

@sidharthachatterjee sidharthachatterjee commented Jul 17, 2019

Elevator Pitch

Everyone who uses Gatsby uses gatsby develop and this change will make it faster and perform with fewer system resources on lower end machines by making file watching more efficient.

Why?

We've seen several issues with chokidar where changes aren't triggered in CI, on Docker, on Vagrant etc and it can be very expensive to have multiple file watchers across webpack and Gatsby's own query watchers. This PR replaces chokidar in query-watcher.js with watchpack (what webpack uses)

Advantages include:

  • Gets changes from directories and not individual files so faster and scales better with large projects with lots of files
  • Shares a single instance across Gatsby (so shares it with webpack) resulting in reduced resource usage
  • Always gets triggered consistently (check out the test in this PR that we had to
    skip until this change because it refused to trigger change when writing to disk on a CircleCI job worker)
  • Includes a aggregated options which lets us batch changes together meaning we can wait till successive changes till say 1 second rather invoking query compilation on every single individual change (this is what happens now)
Goodbye, Chokidar

https://www.youtube.com/watch?v=DQAKY1ntM9o

Know it sounds funny
But I just can't stand the pain
Girl I'm leaving you tomorrow
Seems to me girl
You know I've done all I can
You see I begged, stole
And I borrowed

Ooh, that's why I'm easy
I'm easy like Sunday morning
That's why I'm easy
I'm easy like Sunday morning

Why in the world
Would anybody put chains on me?
I've paid my dues to make it
Everybody wants me to be
What they want me to be
I'm not happy when I try to fake it!
No!

Ooh, that's why I'm easy
I'm easy like Sunday morning
That's why I'm easy
I'm easy like Sunday morning

I wanna be high, so high
I wanna be free to know
The things I do are right
I wanna be free
Just me, babe!

That's why I'm easy
I'm easy like Sunday morning
That's why I'm easy
I'm easy like Sunday morning
Because I'm easy
Easy like Sunday morning
Because I'm easy
Easy like Sunday morning

Disclaimer

chokidar is awesome and watchpack is a wrapper on top of it (at least at v1) so this doesn't imply by any means that chokidar isn't valuable, just that watchpack seems like a more appropriate level of abstraction

Related

#6207

@sidharthachatterjee
Copy link
Contributor Author

Closing this for now because a lot more work will be needed to move all other instances of chokidar to watchpack

Let's pick this up again later

@sidharthachatterjee
Copy link
Contributor Author

@vladar

@MichaelDeBoey MichaelDeBoey deleted the rip-chokidar branch January 20, 2020 18:17
@sidharthachatterjee sidharthachatterjee restored the rip-chokidar branch April 2, 2020 18:47
@sidharthachatterjee
Copy link
Contributor Author

@MichaelDeBoey Restoring the branch because this is valuable exploration work that we might use sometime in the future 🙂

@LekoArts LekoArts deleted the rip-chokidar branch November 9, 2020 08:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant