Skip to content
This repository has been archived by the owner on Sep 11, 2018. It is now read-only.

What's generating hashed json.gzip files in the root dir? #579

Closed
a-axton opened this issue Feb 20, 2016 · 7 comments
Closed

What's generating hashed json.gzip files in the root dir? #579

a-axton opened this issue Feb 20, 2016 · 7 comments

Comments

@a-axton
Copy link

a-axton commented Feb 20, 2016

I have about 100 gzipped json files in my root dir, is this from HMR? Is there a way to clean this up?

@dvdzkwsk
Copy link
Owner

It's the cache directory from babel-loader:

https://github.com/babel/babel-loader#using-cachedirectory-fails-with-enoent-error

cacheDirectory: Default false. When set, the given directory will be used to cache the results of the loader. Future webpack builds will attempt to read from the cache to avoid needing to run the potentially expensive Babel recompilation process on each run. If the value is blank (loader: 'babel-loader?cacheDirectory') the loader will use the default OS temporary file directory.

https://github.com/davezuko/react-redux-starter-kit/blob/master/build/webpack.config.js#L112

Closing this just so I can prune some issues that aren't directly related to the starter kit, but I am also interested in finding ways to clean this up. The weird thing is that the only environment I can reproduce it in ("it" being "the gzip.json files are in my project directory") is Ubuntu. What about you?

@dvdzkwsk
Copy link
Owner

See: https://github.com/babel/babel-loader/blob/master/lib/fs-cache.js#L127-L129

I just tested on Ubuntu 14.04 and os.tmpdir() just spits out my current directory, so I believe it's related to that, if you can confirm your OS. Further reading suggests there are a few related issues open in Node, so this might not be immediately solvable.

@a-axton
Copy link
Author

a-axton commented Feb 21, 2016

Thanks for the info, I'm on OSX el capitan 10.11, node v5.4.0. I'm starting to think it's either a permissions issue or an issue with nvm. For now, I set cacheDirectory to a dir name and put that in the gitignore

@ghost
Copy link

ghost commented Apr 6, 2016

@a-axton Do you have an example so I can copy your setup? { test: /.js$/, exclude: /node_modules/, loaders: ["react-hot", "babel?cacheDirectory"] }

@a-axton
Copy link
Author

a-axton commented Apr 7, 2016

It's just a quick fix, never actually got around to solving the issue. You can assign a string to the cacheDirectory option to choose a dir to save the json files to. I'm using the query object for my setup, but for you it's probably something like "babel?cacheDirectory=cache". Lastly, I added the cache dir to my .gitignore

@ghost
Copy link

ghost commented Apr 7, 2016

sweet! that worked. Thank you. I created a folder called 'babel-cache' one directory up from my config.js file. Example: loaders: ["react-hot", "babel?cacheDirectory=__dirname/../babel-cache"]

@ubergarm
Copy link

I had this issue when running inside a docker container. The fix for me was to read the babel-loader docs:

cacheDirectory: Default false. When set, the given directory will be used to cache the results of the loader. Future webpack builds will attempt to read from the cache to avoid needing to run the potentially expensive Babel recompilation process on each run. If the value is blank (loader: 'babel-loader?cacheDirectory') the loader will use the default OS temporary file directory. https://github.com/babel/babel-loader

So depending on which version of this repo you have, update the cacheDirectory to be an actual directory instead of true. In my case the change was in: react-redux-starter-kit/config/index.js. Older version might use: build/webpack.config.js.

 compiler_babel : {
    cacheDirectory : '/tmp',
    plugins        : ['transform-runtime'],
    presets        : ['es2015', 'react', 'stage-0']

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants