5

What is the .cache folder in parcel-bundler? Is it necessary to push the .cache folder to Github ?

Llawliet
  • 63
  • 2
  • 7

2 Answers2

6

The .cache folder (or .parcel-cache in parcel v2) stores information about your project when parcel builds it, so that when it rebuilds, it doesn't have to re-parse and re-analyze everything from scratch. It's a key reason why parcel can be so fast in development mode. I think committing it to git would be a bad idea - it would add a large number of (unnecessary) changes to your commit history, and it could easily get out-of-sync with the code that generated it.

From this article:

Be sure to add .cache and dist to your .gitignore file to prevent committing these folders to Git. The .cache folder is used by Parcel as a temporary cache directory when building your app for development and production.

Andrew Stegmaier
  • 2,835
  • 2
  • 11
  • 23
  • My small new project's `.parcel-cache` folder is over `10gb` ‎ – vsync Feb 08 '21 at 09:33
  • 1
    You can safely delete it and start over if you feel like it might be bloated due to a bug - this might be a good idea especially if you were upgrading parcel versions. – Andrew Stegmaier Nov 08 '21 at 21:31
  • @AndrewStegmaier is there a way to remove those from history to reduce repo size? – Ray Cheng May 04 '22 at 16:25
  • I'd check out [this question](https://stackoverflow.com/questions/10067848/remove-folder-and-its-contents-from-git-githubs-history) which asks a similar thing (although WRT a node_modules folder that accidentally got committed). – Andrew Stegmaier May 04 '22 at 17:37
2

A slight update on this answer, although it is practically the same response, would be that the command you now need to enter for parcel@^2.0.0-beta.1 is:

.parcel-cache

Add this to your .gitignore file and all the Blobs will be removed from your Untracked listed of files when you hit git status again.

Thank you for helping me resolve this issue!

  • Yes, parcel@^2.0.0-beta.1 now has .parcel-cache. I have .cache added to my .gitignore in my one-year old project bundled with parcel but I have .parcel-cache. – Sulaiman Abiodun Jun 29 '21 at 10:50
  • I can see that parcel-bundler/.gitignore file at https://github.com/parcel-bundler/parcel/blob/v2/.gitignore still has both .parcel-cache and .cache, should we still keep .cache in our .gitignore? – Sulaiman Abiodun Jun 29 '21 at 10:53
  • I can't see any reason not to, as in my mind it would make the application backwards compatible, and ensure your Git commit are not full of cached files from your .cache file, but I would defer to somebody else to provide a technical in-depth answer on why you should keep it. – Dan Haddock Nov 13 '21 at 13:59