-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is there a CLI? #2270
Comments
Heya @Twipped! 👋
No, not currently
Thanks for sharing!
Yes and no. There is a It's also worth cross referencing here, this is some ongoing work for an |
How would that work? What is the input? What is the output? What does this CLI do exactly? |
My own, actually. It's a JSX template engine for use in a static site builder. I have MDX fixtures as part of my test suite and I wanted an easy way to convert them to js modules to be imported and evaluated in the tests. I did work out how to make babel do it, but a shell command would have saved me some time. (btw, @wooorm, your |
Why do you need babel, and why isn’t I see you’re also turning esm (mdx files are esm) into cjs, I guess Babel does that for you? That’s interesting though because our CLI could not do that (or at least, I’d think that would be out of scope). For the project you’re working on, two things that come to my mind:
|
Did you mean to ask why I need a CLI? I'm using babel because I didn't have another option.
Yes, that's exactly the reason. Why write a separate script to do what could be done in a single shell command? That's basically why I asked, because the idea seemed so obvious to me that I assumed I must be missing something. Have a tool that takes a string and spits out another string? It seemed natural to include a bin to do that with stdio.
True, which was something I did not notice until after I made this Issue. I would have had to pipe the output through babel anyway, but at least I could have used my existing babel config for converting the JSX, rather than adding another plugin.
Similar, yes. This is focused on static html compilation, however, with no browser DOM at all. My first approach was, indeed, building some sort of AST that could be stringified into HTML, but shortly into it I realized that was a completely unnecessary step. I didn't need to manipulate the AST once it was generated, it was just going straight to serialization, so why bother with the AST at all when I can serialize directly from the Element classes. I was initially inspired by |
I'm gonna close this, since the actual question has been answered. It would be nice if there was an official babel plugin published to do this, rather than just a guide on how to make your own. |
I am not sure why there needs to be an official babel plugin. It could live in userland too, for the folks that need it. Not everything has to be maintained by/in “core”. A lot of things can flourish in userland in my opinion! :) As for a CLI, I think that’s covered in mdx-js/mdx-analyzer#292. It’s still a vague idea tho, so more discussion on what it should look like can go there! |
Initial checklist
Problem
I wanted to create an npm script in one of my projects to compile some MDX files, but after digging through the docs and the issues, it seems there's no existing way to do this from the shell?
Solution
Some kind of really elementary
@mdx/cli
package would be very helpful.Alternatives
I did find the babel instructions, so I'll probably go that route. It'd be nice if that babel plugin in the example was available as a published package to make it easier to use as a drop-in.
The text was updated successfully, but these errors were encountered: