[DevEx Improvement] Remove default export#907
[DevEx Improvement] Remove default export#907pastacolsugo wants to merge 4 commits intoremarkjs:mainfrom
Conversation
Signed-off-by: Ugo Baroncini <ugobaroncini@gmail.com>
Signed-off-by: Ugo Baroncini <ugobaroncini@gmail.com>
Signed-off-by: Ugo Baroncini <ugobaroncini@gmail.com>
|
I also prefer named exports. But this is definitely a breaking change. I don’t think we should release a semver major just for this. |
Missing `Markdown` component reference Signed-off-by: Ugo Baroncini <ugobaroncini@gmail.com>
|
That's a fair concern. The decision is not mine to make, but you could consider that two months since the latest major is a small window of time: I would say that most people still haven't updated to it. Do you see another major in the next months? If not, I would consider doing it now and being done with it, instead of dragging it. :) |
|
hello! I would agree with you if there were few users. I am very strongly against this. You are asking 1 234 567 people to change their code. For no real benefit. Also, there are 10 years of examples out there: LLMs will keep outputting the old version that doesn’t work for years. As you show in your use case, many users of this package are beginners and will mix things up. backcompat is nice. We don’t have to break things. Sometimes the world isn’t perfect, that’s ok |
|
Hi! This was closed. Team: If this was merged, please describe when this is likely to be released. Otherwise, please add one of the |
Initial checklist
Description of changes
Hello everyone,
thank you for your work on
react-markdown!I'm submitting this PR to propose a Developer Experience improvement, by removing the default export in
index.js.The current code exports the
Markdowncomponent (synchronous version) as default.This default export makes it possible to import the module by doing:
In my case I then realised I needed
MarkdownHooks, thus changed my import as usual, to:And here lies the catch: I'm still importing the
Markdowncomponent!I forgot to add curly braces, and the default export happily worked to import the
Markdownin the confusingly namedMarkdownHooksvariable.Removing the default export would force the developer to import using curly braces from the beginning, avoiding this confusing mistake. It's also consistent with how most other packages work.
This PR removes the default export, and updates the docs accordingly.
This article explains other benefits of removing default exports better than I could.
Cheers! 🎲