Skip to content

Rectify ESM modules

Boris Budini requested to merge esm into master

I did several things in this PR:

  • I fixed the Rollup ESM bundling (npm modules were not bundled)
  • an ESM module is generated for the polyfill
  • I updated the documentation

The latter can be revised, I'm not sure if all the changes fit in the scope. At least it illustrates the ESM syntax.

$ npm run build

> pagedjs@0.1.31 build /Users/oncletom/workspace/pagedjs
> rollup -c

dist/paged.esm.js → dist/paged.js, ./dist/paged.esm.js...
created dist/paged.js, ./dist/paged.esm.js in 1.2s

./src/polyfill/polyfill.js → ./dist/paged.polyfill.js, ./dist/paged.polyfill.esm.js...
created ./dist/paged.polyfill.js, ./dist/paged.polyfill.esm.js in 1.7s

The source of the bundled file now reflects npm dependencies have been included:

$ head dist/paged.esm.js
(function(l, i, v, e) { v = l.createElement(i); v.async = 1; v.src = '//' + ( || 'localhost').split(':')[0] + ':35729/livereload.js?snipver=1'; e = l.getElementsByTagName(i)[0]; e.parentNode.insertBefore(v, e);})(document, 'script');
function getBoundingClientRect(element) {
	if (!element) {
	let rect;
	if (typeof element.getBoundingClientRect !== "undefined") {
		rect = element.getBoundingClientRect();
	} else {
		let range = document.createRange();
Edited by Boris Budini

Merge request reports