DevelopingMagic / pdfassembler

MIT License
183 stars 34 forks source link

ES6/Webpack/etc Import issue #6

Open brianmhunt opened 5 years ago

brianmhunt commented 5 years ago

I am getting undefined from import PDFAssembler from 'pdfassembler' using Webpack (with a config that works with most libraries e.g. moment, pdfjs, jss, knockout/tko, file-saver, lodash).

I'm happy to put together a MWE to demonstrate, though I suspect the problem may be fairly apparent or trivial to solve.

An alternative would be to copy the pdfassembler.ts to dist/ since some folks (like myself) might be just as happy to use that directly.

Cheers.

brianmhunt commented 5 years ago

Just for ease of reference, here are some CLI options for tsc:

https://gist.github.com/jayphelps/51bafb4505558736fdba0aaf8bfe69d3

brianmhunt commented 5 years ago

...owing to the hefty size of the libraries (pdf.js notably) included, it might be worthwhile to distribute a version that links to global or provided options for these e.g. pdfAssembler.setup({ pdfjs: window.pdfjs }) or some such.

brianmhunt commented 5 years ago

I also noted that the dist/pdfassembler.js includes require statements to a variety of imports e.g.

head -c 350 node_modules/pdfassembler/dist/pdfassembler.js "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var pdf_manager_1=require("pdfjs-dist/lib/core/pdf_manager"),primitives_1=require("pdfjs-dist/lib/core/primitives"),stream_1=require("pdfjs-dist/lib/core/stream"),util_1=require("pdfjs-dist/lib/shared/util"),pako_1=require("pako"),queue=require("promise-queue"),

I believe pdfassembler would be easier to consume if those modules were actually included, as opposed to require'd.

brianmhunt commented 5 years ago

... relatedly, I'm sure folks would enjoy a CDN version.