Skip to content
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

Add ESM Support #661

Closed
wants to merge 1 commit into from
Closed

Add ESM Support #661

wants to merge 1 commit into from

Conversation

evanplaice
Copy link

@evanplaice evanplaice commented Feb 20, 2019

This PR adds preliminary ES module support with the absolute minimum changes to the existing codebase.

Changes:

  • adds a second grunt-concat aliases to concat_esm
  • removed the traditional loaders.js from the .esm.js config to avoid conflicts with module.exports
  • assigns the IIFE to a variable and assigns it to the default export
  • removes the this binding to global scope, ESM enforces strict mode by default so binding to global this is not allowed.
  • generated new dist files
  • added 'grunt build-esm' to trigger the build
  • add grunt build-esm to the prerelease steps

Usage

This assumes the module is being used in a browser (ie hence no bare import specifier) that includes ESM support.

import Showdown from '/node_modules/showdown/dist/showdown.esm.js';

const raw = '' // <- assume some raw markdown here
const md = new Showdown.Converter().makeHtml(raw);
document.getElementById('some-element').innerHTML = md;

Ref: #660

Added another grunt-concat config that generates a .esm.js file.

Replaced references to this.document/this.window with document/window due to errors. Functionality should remain the same.
@evanplaice
Copy link
Author

evanplaice commented Mar 9, 2019

Note: Changed extension from .mjs to .esm.js. Even in Node .mjs is no longer required to use ECMAScript modules.

BTW. Feedback is welcome on this. I know it's not a part of the existing roadmap. I will own whatever additional work is necessary to make this acceptable.

@Marshal27
Copy link

It's unfortunate this wasn't consumed... maybe there is a legitimate reason by the maintainers I haven't been able to find?

Regardless, I have an Open-Wc lerna repo that is a pure ES build pipeline and received a feature request to parse HTML to markdown and vice versa... there are not any ES libraries that can do bi-directional; your dist in this PR helped me out a lot and I thank you for doing this work... so far works wonderfully to solve my issue!

@mansona
Copy link

mansona commented Sep 15, 2021

Hey @evanplaice 👋 just curious why you closed this PR? I know it was open for a little while but I wonder if we should open it again to help try to get it merged. What do you think?

@evanplaice
Copy link
Author

This PR sat for more than a year without a response from the Maintainers

As an Author, Maintainer, and Contributor of many many projects; tracking the status of a single PR that sat untouched for >1 year isn't really a good use of my time.

The minimal set of changes required to convert Showdown to ESM are available in this PR. Showdown's Maintainers can always pick up where I left off if they decide to make the change. I just did the work so if/when they decide to make the switch, it'll be an easy transition.

In that regard. Please do not ping me again from this project unless you are an active Maintainer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants