jsxtreme-markdown
jsxtreme-markdown copied to clipboard
Babel macros maybe?
Babel recently launched first party support for macros. It is still a relatively new feature and might have some things yet to be polished, but I can see ways it can improve our babel-plugin-transform-jsxtreme-markdown. We are already creating a fake import of md
to use this plugin, babel-plugin-macros
formalises this system and should make it easier to reason about.
Yes, that would be fantastic that should make it possible to use it with CRA without the need of react-app-rewrited :)
Looks like it might already exists https://github.com/mapbox/jsxtreme-markdown/issues/33 ?
@kepta what do you think of the prior discussion, about keeping the macro out of this repo?
Looks like it might already exists #33 ?
Ah, thanks for flagging that @weyert. I forgot babel-macros
has been lying around for a while now.
@kepta what do you think of the prior discussion,about keeping the macro out of this repo?
@davidtheclark reading https://github.com/mapbox/jsxtreme-markdown/issues/25 and especially this line
Seems "macro" is the right term for what this Babel plugin is doing!
I agree what this plugin is doing fits more in line with what Babel folks want us to call macros
. I like the explicitness of being able to import the macro without having to worry about tweaking .babelrc
or any other global configuration. I believe even users would benefit from consuming the macro by simply doing an npm install
and using it directly in their Javascript files (provided that they have properly setup babel-macros
).
I kind of inch towards keeping the macro inside the repo and maintain it ourself. Something like:
// Option 1: continue using the same package
import md from 'babel-plugin-transform-jsxtreme-markdown/md.macro';
// Option 2: if we want to have a separate package
import md from '@mapbox/jsxtreme-markdown.macro';
As Babel 7 ecosystem matures, we can make the macro the preferred way of consuming jsxtreme
and the plugin could continue to exist to prevent breaking existing repositories consuming it.
I have been trying to use this import md from 'babel-plugin-transform-jsxtreme-markdown/md.macro'
in my CRAv2 application but it's not working for me. Besides adding the package 'babel-plugin-transform-jsxtreme-markdown
to my dev dependencies?
Do I need to do something special to make this work?
@weyert There is no Babel macro implementation right now.
Hmm, that's confusing then!