I was looking to use pdf.js today via something like import {pdfjs} from pdfjs-dist/pdf.js
and learned that all that is available is a require module.
Would it be possible to add es6 modules somewhere on npm?
In an ideal world, src
should be refactored as standard modules. If CJS is still needed, it could be automatically built (say, in a cjs
directory) using rollup or other similar tools, or better yet - left up to the user to generate (node users could easily use the esm
module to enable es module syntax in node apps). That would allow library users to choose if, when, and how to bundle or transpile.
If there's interest, I'd be happy to provide a PR.
As an interim workaround, we've published this:
https://github.com/bundled-es-modules/pdfjs-dist
https://www.npmjs.com/package/@bundled-es-modules/pdfjs-dist
Is this the bundled-es-modules/pdfjs-dist repo still relevant or has module functionality been rolled into this main distribution? There seem to be “components” in this repo.
the published pdfjs-dist
still seems to not have es modules?
or is there another distribution somewhere?
@timvandermeij any update on this?
node_modules/ng2-pdf-viewer/__ivy_ngcc__/fesm2015/ng2-pdf-viewer.js depends on 'pdfjs-dist/build/pdf'. CommonJS or AMD dependencies can cause optimization bailouts.
Most helpful comment
As an interim workaround, we've published this:
https://github.com/bundled-es-modules/pdfjs-dist
https://www.npmjs.com/package/@bundled-es-modules/pdfjs-dist