jsxtreme-markdown icon indicating copy to clipboard operation
jsxtreme-markdown copied to clipboard

Babel macros maybe?

Open kepta opened this issue 5 years ago • 7 comments

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.

kepta avatar Oct 03 '18 04:10 kepta

Yes, that would be fantastic that should make it possible to use it with CRA without the need of react-app-rewrited :)

weyert avatar Oct 06 '18 22:10 weyert

Looks like it might already exists https://github.com/mapbox/jsxtreme-markdown/issues/33 ?

weyert avatar Oct 06 '18 22:10 weyert

@kepta what do you think of the prior discussion, about keeping the macro out of this repo?

davidtheclark avatar Oct 09 '18 16:10 davidtheclark

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.

kepta avatar Oct 10 '18 08:10 kepta

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 avatar Nov 06 '18 17:11 weyert

@weyert There is no Babel macro implementation right now.

davidtheclark avatar Nov 06 '18 17:11 davidtheclark

Hmm, that's confusing then!

weyert avatar Nov 13 '18 13:11 weyert