Merged
Conversation
Owner
|
This looks good! Thank you for the work.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Publish library as ESM. This PR adds Rollup as a bundler which runs
build/rasterizeHTML.concat.jsthrough a transpile step that outputs ESM and UMD (to ensure backward compatibility).The UMD export is available at
dist/rasterizeHTML.js. You can see that it contains code at the top to check formodule.exports(CJS),define(for AMD) and ultimately setswindow.rasterizeHTMLif none of the first conditions pass.The ESM bundle is available at
dist/rasterizeHTML.mjs.This isn't a breaking change as I've intentionally left the output paths the same.
dist/rasterizeHTML.jsis still UMD as before. The only addition is that we now have adist/rasterizeHTML.mjswhich is an ESM build.I've also intentionally left the minified bundles (and added one for ESM). We can remove this when we do breaking changes as it isn't necessary. For users who want to minify, it makes more sense to do it when bundling the application that includes this library instead of including the minified library.
To test this, I've created this branch that contains a Webpack application to test ESM, UMD and CJS. Importing ESM directly (e.g., using
<script type="module">plus import maps) doesn't work because the dependencies ofrasterizeHTMLaren't published as ESM. You can test this method by opening this index.html (doesn't require a webpack build, unlike the other options).Let me know if you have any questions. I'm diffed the current and new output and everything seems fine, but I'm not an expert in JS module systems, so something might be wrong.