Allow plugins to indicate dependencies on random files
See original GitHub issueFeature Request
In contexts where Babel is running alongside a filesystem watcher, there are cases where a plugin may load an arbitrary file. Take a plugin like https://www.npmjs.com/package/babel-plugin-inline-import for example. Or some usecases of babel-plugin-macros.
It would be ideal if Babel had a way for plugins to indicate that these dependencies exist, so that if callers of Babel wanted to take that into account, they could. For example, Webpack has .addDependency
, so that changes to that file will cause the loader to re-execute when the dependency is changed. We could easily use this API in babel-loader
to handle this. Implementing a similar API in @babel/cli
’s watcher wouldn’t be too bad either.
I don’t know how other Babel wrappers would fair, but if someone wanted to help investigate that, it would certainly help. Off the top off my head we’d want to check, at the very least, if the following have ways to register additional files to watch:
- Meteor
- Jest
- Browserify
- Gulp
Edit
We may also want to include in this work logic to help us take dependency file content into account for the purposes of cache invalidation. For example, babel-loader
’s cacheDirectory
option will not invalidate caches, if say a .browserlistrc
file changes preset-env
’s plugin list: https://github.com/babel/babel-loader/issues/690
Issue Analytics
- State:
- Created 5 years ago
- Reactions:45
- Comments:18 (10 by maintainers)
Top GitHub Comments
Going to aim to get it fixed for
babel-loader
specifically, at least to start. I’ll do a little writeup on my plan to fix and see if I can get some feedback here before moving forward.Sadly, no update yet - I have this queued but it keeps sinking down the priorities for other things. In the meantime we are disabling the babel cache and getting by, albeit a bit more slowly.