Closed ekoeryanto closed 3 years ago
there is prior art for this as well. babel-loader does this, and a few other things i forgot about...
This seems pretty reasonable to me... any thoughts @pieh @KyleAMathews?
This is the module used by babel-loader
(and others): https://github.com/avajs/find-cache-dir
I do think we should pair such a change with gatsby clean
command
Yeah, seems like a reasonable/good change. One problem is that some of the ".cache" folder isn't actually a cache β it's where Gatsby copies runtime and other necessary files into the project folder so they're available for requiring at a predictable place. We'll need to keep that but other cache files we could move inside node_modules
.
Old issues will be closed after 30 days of inactivity. This issue has been quiet for 20 days and is being marked as stale. Reply here or add the label "not stale" to keep this issue open!
This issue is being closed due to inactivity. Is this a mistake? Please re-open this issue or create a new issue.
I'm trying to run gatsby on AWS Lambda and it's complaining because the only directory with write permission is /tmp
.
What about giving the possibility to specify the cache location with an option (either as an env variable or as a cli option)?
I'm happy to work on this
Hiya!
This issue has gone quiet. Spooky quiet. π»
We get a lot of issues, so we currently close issues after 30 days of inactivity. Itβs been at least 20 days since the last update here.
If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not stale" to keep this issue open!
Thanks for being a part of the Gatsby community! πͺπ
We should do this β it's kind of a breaking change though so we should do it in v3.
I realize babel-loader stores files in node_modules
but this is not a good idea here.
I would like to suggest serious consideration of standardizing on .cache/gatsby
instead.
Please consider these points:
.cache/namespace
.node_modules
. For example, things like postcss-loader and babel-loader will not run on files stored inside of node_modules by default. This creates problems if you wish to cache intermediate files or runtimes. An example of this is static extraction of CSS from Javascript that needs to be further processed by postcss-loader.rm -rf .cache
for all the things vs rm -rf node_modules/.cache
.Gatsby should move from .cache
to .cache/gatsby
. This way, other tools can store their cache in their own subfolder, and Gatsby wouldn't have exclusive rights to a generic folder name.
Would it be possible to make this configurable, or use https://github.com/avajs/find-cache-dir? This would give us some control over where the cache directory is located.
For my use case (and I believe this might be true for most CI users), having a single, common cache directory means we can restore/preserve the cache independently from our sources without introducing any exceptional cases.
Not every Gatsby setup will have a node_modules directory e.g if you use Yarn v2.
There is not much value in allowing different .cache folders from our perspective. We haven't got many requests for it and it would make our code harder to maintain to make sure we write to the right folder.
Thank you for suggesting it!
Summary
Just what title says
Motivation
on most CI we can save node_modules directory to the cache I think it is better to put the cache inside node_modules because it need not more setup, and also on we can speed up netlify build