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

Move cache dir from /.cache to /node_modules/.cache #5880

Closed
ekoeryanto opened this issue Jun 13, 2018 · 14 comments
Closed

Move cache dir from /.cache to /node_modules/.cache #5880

ekoeryanto opened this issue Jun 13, 2018 · 14 comments
Milestone

Comments

@ekoeryanto
Copy link

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

@jquense
Copy link
Contributor

jquense commented Jun 13, 2018

there is prior art for this as well. babel-loader does this, and a few other things i forgot about...

@m-allanson m-allanson added the type: question or discussion Issue discussing or asking a question about Gatsby label Jun 18, 2018
@m-allanson
Copy link
Contributor

This seems pretty reasonable to me... any thoughts @pieh @KyleAMathews?

@m-allanson
Copy link
Contributor

This is the module used by babel-loader (and others): https://github.com/avajs/find-cache-dir

@jquense
Copy link
Contributor

jquense commented Jun 18, 2018

I do think we should pair such a change with gatsby clean command

@KyleAMathews
Copy link
Contributor

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.

@gatsbot
Copy link

gatsbot bot commented Dec 5, 2018

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!

@gatsbot gatsbot bot added the stale? Issue that may be closed soon due to the original author not responding any more. label Dec 5, 2018
@gatsbot
Copy link

gatsbot bot commented Dec 16, 2018

This issue is being closed due to inactivity. Is this a mistake? Please re-open this issue or create a new issue.

@gatsbot gatsbot bot closed this as completed Dec 16, 2018
@mathieudutour
Copy link
Contributor

mathieudutour commented Mar 11, 2019

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

@mathieudutour mathieudutour reopened this Mar 11, 2019
@mathieudutour mathieudutour removed the stale? Issue that may be closed soon due to the original author not responding any more. label Mar 11, 2019
@gatsbot
Copy link

gatsbot bot commented Apr 1, 2019

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! 💪💜

@gatsbot gatsbot bot added the stale? Issue that may be closed soon due to the original author not responding any more. label Apr 1, 2019
@wardpeet wardpeet added not stale and removed stale? Issue that may be closed soon due to the original author not responding any more. labels Apr 2, 2019
@KyleAMathews
Copy link
Contributor

We should do this — it's kind of a breaking change though so we should do it in v3.

@brandonkal
Copy link

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:

  1. Storing in node_modules is npm specific. Instead, we should prefer standardizing on .cache/namespace.
  2. With tools like Yarn Plug'n'Play, the node_modules folder is no longer viable moving forward.
  3. Webpack by default gives special consideration for things in 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.
  4. It is not as elegant. 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.

@langri-sha
Copy link

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.

@huy-nguyen
Copy link

Not every Gatsby setup will have a node_modules directory e.g if you use Yarn v2.

@wardpeet
Copy link
Contributor

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!

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

No branches or pull requests