Skip to content

Allow plugins to indicate dependencies on random files #8497

@loganfsmyth

Description

@loganfsmyth

Feature 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: babel/babel-loader#690

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedoutdatedA closed issue/PR that is archived due to age. Recommended to make a new issuepkg: core

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions