postlight / parser

📜 Extract meaningful content from the chaos of a web page
https://reader.postlight.com
Apache License 2.0
5.41k stars 442 forks source link

Feature Request: Support an ES Modules Dist Build #570

Closed jimniels closed 2 years ago

jimniels commented 4 years ago

Today, if you want to user mercury in the browser, you can pull it in via a <script> tag from a CDN like unpkg as an iife.

<script src="https://unpkg.com/@postlight/mercury-parser@2.2.0/dist/mercury.web.js"></script>

Would be nice if there was an ES modules build, so then you could import it directly:

import Mercury from "https://unpkg.com/@postlight/mercury-parser@2.3.0/dist/mercury.esm.js"

It seems like this would be pretty straightforward. I'm not entirely sure how the build is set up, but mimicking what I saw with the build:web scripts, I added one for ES Modules. Tested locally and it produced a build file (dist/mercury.esm.js) which I could import myself in a local project.

Note: I had to use terser instead of uglify for ES modules. See this issue.

jimniels commented 4 years ago

CI is failing, but doesn't appear to be my fault...

Screen Shot 2020-07-09 at 10 44 39 AM