How to identify a macros
See original GitHub issueRight now we identify a macros if the import/require source string matches this regex: /[./]macros(\.js)?$/
The only thing I don’t quite like is the
.macros
naming, maybe we can come up with an alternative suffix.
The ideal solution would be to have separate syntax, e.g.
importMacros
, but that’s likely never going to happen Another option is to use a webpack inspired ‘babel-macros?css’, but that straight up looks alien Alternate words off the top of my head - mods, plugs, socks(?), defines
So then I said:
I want to make sure that existing tooling will work as much as I can so I want to avoid anything too weird looking… 🤔
I don’t mind macros myself, but happy to consider other names 👍
The thing is, it also need to be explicit enough that you wouldn’t mistake it from a regular import. Because otherwise it’ll be a debugging nightmare for the person who doesn’t know what’s going on.
Flow has
import type
, and sweet.js usesimport ... for syntax
. Is adding a similar syntax extension to babylon going too far for something like this?
And finally I said:
I’d be fine with it if babylon supported it via a plugin, then people could just include a preset we make (and CRA could include it in its own config theoretically). I like:
import macros glam from 'glam.macros'
But I’m open to pretty much anything else.
So now that we’re all caught up, let’s discuss the options. Other people I’d love to get input from are: @hzoo, @loganfsmyth, and @jlongster 😄
Here are the options as I see them:
- babylon plugin for new syntax
- matching imports where the source matches a regex
Any other ideas?
Issue Analytics
- State:
- Created 6 years ago
- Comments:14 (9 by maintainers)
Yeah, I think that we should probably only have one (
macro
) and stick with that… Otherwise it will make things confusing.I guess the ecosystem need something named CT39 - Compile-Time 39 😁