Closed conartist6 closed 5 years ago
Assuming it doesn't complicate things too much, I'm in favor and would accept a poll request for this.
:tada: This issue has been resolved in version 2.6.0 :tada:
The release is available on:
npm package (@latest dist-tag)
Your semantic-release bot :package::rocket:
Currently it is possible to configure macros through a configuration file. I propose additionally that it be possible to configure a macro through the babel configuration itself.
I would like to have this functionality because I am using babel plugin macros to split certain files into two similar but subtly different versions. Just for clarity, the versions are sync and async. This means that I always need to run the plugin twice, once per version. Previously I was using process.env to pass the sync/async flag, but now I wish to be able to transpile inside a watcher callback, which makes it unsafe to use a global.
Currently the only data which I can access from the transpile call is the filename, which I am loth to repurpose.
I think what should happen is that a macro should receive a slice of the babel-plugin-macros settings:
This would presumably be merged with the contents of the cosmiconfig settings file for the macro.
I also looked into using the new
caller
setting to sneak past babel-plugin-macros entirely, but it turns out this is not possible because it is only possible to accesscaller
prior to the start of the traversal, and babel-plugin-macros only instantiates its plugins inside its traversal.