showdown icon indicating copy to clipboard operation
showdown copied to clipboard

Add ESM Import Compatibility

Open evanplaice opened this issue 5 years ago • 14 comments

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.

evanplaice avatar Feb 20 '19 07:02 evanplaice

Thanks for your contribution. I will have a look as soon as possible, when I have the time.

tivie avatar Mar 16 '19 13:03 tivie

It still seems there is not ESM compatibility for Showdown in 2020.

Justsnoopy30 avatar May 23 '20 20:05 Justsnoopy30

Is this coming?

Gillardo avatar Nov 03 '20 11:11 Gillardo

Any updates on ESM compatability?

tirithen avatar Jun 18 '21 08:06 tirithen

+1

the dist in closed PR 661 so far works well.

Marshal27 avatar Jul 19 '21 14:07 Marshal27

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. 😞

LeaVerou avatar Nov 24 '21 13:11 LeaVerou

I'm also waiting for this and starting to think about switching library.

wojteko22 avatar Jul 26 '22 10:07 wojteko22

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

Gillardo avatar Jul 26 '22 11:07 Gillardo

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?

jessejohnson avatar Jan 23 '23 18:01 jessejohnson

Here is the way to import this lib in an ESM:

import Showdown from 'showdown';

taorepoara avatar Feb 18 '23 12:02 taorepoara

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".

TheDogHusky avatar Apr 05 '24 18:04 TheDogHusky

Is there no esm support for browser?

TheDogHusky avatar Apr 07 '24 13:04 TheDogHusky