mdx-js / mdx

Markdown for the component era
https://mdxjs.com
MIT License
17.43k stars 1.14k forks source link

Create React App instructions shouldn't recommend "rewired" #358

Closed gaearon closed 5 years ago

gaearon commented 5 years ago

https://mdxjs.com/getting-started/create-react-app#create-react-app

The "rewired" package has never been supported. CRA 2.0 supports Babel Macros and MDX was one of the reasons we added it — would be nice if the guide recommended the official solution. Thanks!

jamesknelson commented 5 years ago

Hey there, I made the mdx.macro package, but I'm really not sure that the docs should point to it because it doesn't currently work properly, and won't unless a new feature is added to babel itself. You can see more details on this in these two issues on create-react-app.

The gist is, if a macro reads a separate file, there's currently no way to watch that file for changes. This means that it's possible to load an MDX file with mdx.macro, but you then have to manually restart the server each time that you change it. I've spent a day trying various hacks because I really want this feature myself, but haven't come up with anything that works.

I honestly think that CRA jumped the gun by advertising MDX support via babel-macros. I've spent a lot of time trying to make it work, but for anything production related it's just not ready. Imo, "rewired" with CRA1 or the unsupported loader syntax with CRA2 (i.e. !babel-loader!mdx-loader!) provide a far better dev experience.

johno commented 5 years ago

Thanks for the added details @jamesknelson, I'm going to reopen this until the missing features are added and we get live reload support on imported files.

johno commented 5 years ago

I'm going to go ahead and close this for now since there's not much actionable I can do on MDX's end right now. I've subscribed to the other issues linked so I can keep an eye on them. Right now I don't have the time/bandwidth to attempt a fix in babel core or mdx.macro myself.