Babel-loader: Can't disable cache with BABEL_DISABLE_CACHE=1

Created on 18 May 2017  路  7Comments  路  Source: babel/babel-loader

I'm submitting a bug report

Webpack Version:
2.5.1

Babel Core Version:
6.22.1

Babel Loader Version:
6.2.10

Please tell us about your environment:
OS X

Current behavior:
Babel-loader will cache the results from the first build and continue to read from them for future builds, even when BABEL_DISABLE_CACHE=1 is defined.

e.g.: "dev": "BABEL_DISABLE_CACHE=1 webpack-dev-server"

Expected/desired behavior:
No cache should be used at all. All code should be re-compiled every time.

  • If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem along with a gist/jsbin of your webpack configuration.

BABEL_DISABLE_CACHE=1 webpack-dev-server

  • What is the expected behavior?
    No cache to be used on future builds.

  • What is the motivation / use case for changing the behavior?
    I don't want my stuff cached.

Most helpful comment

All 7 comments

Caching isn't enabled by default, it only happens if you explicitly set cacheDirectory. Are you saying you want to both explicitly enable it, and explicitly disable it? You can check process.env.BABEL_DISABLE_CACHE inside your Webpack config to use that to toggle cacheDirectory if you'd like.

Babel certainly creates a cache even when I leave the options blank. Something along the way is caching it; perhaps webpack-dev-server in that case?

What specifically are you seeing, and what makes you say the issue is Babel-related? You haven't given much to go on yet.

https://github.com/dwjft/easy-import

I'm using this module. I'm wondering if it is the module caching the package map in memory somewhere; though these cache issues don't exist when transpiling Node.js code, only webpack.

When I add a new package, webpack reloads, but doesn't read the new // @package declaration, so it cannot be imported until a full restart of webpack.

I think a more intuitive behavior would be:

if BABEL_DISABLE_CACHE is set, and nothing else is set, then .babel.json is not created or used at all.

We end up removing .babel.json every time in order to force transpiling to happen every time.

Currently Babel will invalidate the cache when you change your config or the file content, but otherwise deleting the cache folder is the best way to entirely clear it. As I noted in https://github.com/babel/babel-loader/issues/453#issuecomment-302295145, babel-loader just depends on the cacheDirectory value so you can always use that + an environment variable to toggle caching on your own.

I've also filed https://github.com/babel/babel/issues/8497 which we'll explore for the preval case.

Was this page helpful?
0 / 5 - 0 ratings