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.
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.Would be nice if there was an ES modules build, so then you could import it directly:
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 ofuglify
for ES modules. See this issue.