vihanb / babel-plugin-wildcard

Wildcard imports import a directories JS files
MIT License
186 stars 27 forks source link

cacheDirectory is breaking functionality #20

Closed dkrutsko closed 6 years ago

dkrutsko commented 6 years ago

Hey there, great plugin, however I'm having some issues using this with my webpack framework. When using babel-loader with the cacheDirectory option and deleting some files within that directory, I get module not found errors. Deleting my babel-loader cache (node_modules/.cache/babel-loader) or setting cacheDirectory to false fixes this problem.

vihanb commented 6 years ago

The plugin has no option whether babel caches or not so likely the only option would be to have a config option which dynamically generates imports.

gaurav- commented 6 years ago

@vihanb it would be great if there's a fix for this. Other similar plugins have been unable to fix the same issue:

vihanb commented 6 years ago

I suppose we could attempt to rm -r node_modules/.cache/babel-loader I'll look into it though, as I am not sure about the location in global vs local installs

vihanb commented 6 years ago

now, if you install the plugin globally (or in a NPM script), you can use bpwc clear-cache and it'll locate cache files and delete them. If you are using babel-loader for testing or something, you can add this command in your test script

gaurav- commented 6 years ago

@vihanb is it clearing the entire babel cache or only the parts specific to wildcard imports? Ideally the latter is desirable (if possible) IMO because then it wouldn't drastically slow down the transpilation after calling clear-cache.

vihanb commented 6 years ago

@gaurav- If you are in the root directory of your project it will delete the cache for that project. That said, Babel seems to often keep most of the cache for all files in one file and there doesn’t seem to be docs for the format which it’s kept in, also I’m not sure if that format will be stable across Babel versions. For that reason it will sometimes clear the global Babel cache too.