Do not run the polyfill automatically (BREAKING CHANGE)
I found out it was easier not to polyfill automatically when the script is included via ESM.
I use the "polyfill" because it's a no brainer for me, as I don't understand (yet) how to order the use of the chunker, parser etc. — that's an "advanced" scenario for me.
I also never use the polyfill out of the box because there is always something else to do (markdown to HTML, moving some content around, fetching dynamic data). And I use ECMAScript modules without a build toolchain for workshop purposes (nothing to configure, everything works with a plain HTML file).
ALTHOUGH — and this is not what is reflected by the PR but what came to my mind afterwards — I wonder if it would be simpler to:
- not have ESM modules for the polyfill script (it now sounds confusing to me)
- move the "manual" magic to the non-polyfill script
Which means, in terms of responsability, "polyfill" is about getting stuff done "magically" while the other script is about doing things manually.
<html>
<script type="module">
import {Polyfill} from 'https://unpkg.com/pagedjs/dist/paged.esm.js';
/* ... */
window.addEventListener('load', () => Polyfill.preview());
</script>
<link rel="stylesheet" href="...">
<body>
<!-- ... -->
</body>
</html>
<html>
<script src="https://unpkg.com/pagedjs/dist/paged.polyfill.js" defer></script>
<link rel="stylesheet" href="...">
<body>
<!-- ... -->
</body>
</html>
What do you think? I'm happy to rework things in a way which lowers the barrier to entry as well as the maintenance.