showdown
showdown copied to clipboard
Add ESM Import Compatibility
ESM is coming. It is already supported in most browsers and is coming to Node 1.
With that said, there are few libraries that have native support for it yet. As far as Markdown parsers go:
- markdown-it is very heavily invested in CommonJS, ESM support will likely never happen there
- marked - had a contributor implement ESM support and the maintainers rejected the PR
- remark - also heavily invested in CommonJS
- markdown-js - looks like it's no longer being maintained
Long-story-short, unless somebody starts a 'clean room' implementation of a Markdown parser in ES this is going to be a pain point for FE devs working in native ESM.
I've been experimenting a bit and managed to create a PR that adds support with very minimal impact on the existing codebase.
1 I'm a participant on the Node/Modules work group. If all goes well, we may see unflagged support before the end of the year.
Thanks for your contribution. I will have a look as soon as possible, when I have the time.
It still seems there is not ESM compatibility for Showdown in 2020.
Is this coming?
Any updates on ESM compatability?
Another vote for ESM here. I love Showdown, but had to switch away from it for my modules because I can't distribute libraries that leak into the global scope. 😞
I'm also waiting for this and starting to think about switching library.
yeah i think i may have to switch if this doesnt happen soon, which is a shame as i like this library, no idea what to change to either
Does anyone have an alternative that has ESM Import compat? It's 2023 and I can't seem to find any. :(
@LeaVerou what did you switch to?
Here is the way to import this lib in an ESM:
import Showdown from 'showdown';
Hello!
If I downloaded showdown.min.js, on an Expressjs server, how can I do the import?
Currently I have a script /static/script/ticketManager.js
that needs showdown.
Showdown is located in the same directory as ticketManager.
When I try to import import showdown from "/static/script/showdown.min.js"
, it says that it doesn't have default export. (the same happens if I do import showdown from "./showdown.min.js"
.
Is there no esm support for browser?