bpampuch / pdfmake

Client/server side PDF printing in pure JavaScript
http://pdfmake.org
Other
11.71k stars 2.04k forks source link

Crashes when imported using Bun #2648

Closed jldc2 closed 11 months ago

jldc2 commented 1 year ago

repro: install bun as here https://bun.sh/docs/installation

import PdfPrint from "pdfmake";

bun file.js

Stack trace im getting

22 | function getLens (b64) { 23 | var len = b64.length 24 | 25 | if (len % 4 > 0) { 26 | throw new Error('Invalid string. Length must be a multiple of 4') ^ error: Invalid string. Length must be a multiple of 4 at getLens (/Users/user/code/app/node_modules/@foliojs-fork/linebreak/node_modules/base64-js/index.js:26:10) at toByteArray (/Users/user/code/app/node_modules/@foliojs-fork/linebreak/node_modules/base64-js/index.js:55:13) at /Users/user/code/app/node_modules/@foliojs-fork/linebreak/src/linebreaker.js:7:13 at globalThis (/Users/user/code/app/node_modules/@foliojs-fork/linebreak/src/linebreaker.js:200:17) at overridableRequire (:1:20) at /Users/user/code/app/node_modules/@foliojs-fork/pdfkit/js/pdfkit.js:9:4 at globalThis (/Users/user/code/app/node_modules/@foliojs-fork/pdfkit/js/pdfkit.js:6441:17) at overridableRequire (:1:20) at /Users/user/code/app/node_modules/pdfmake/src/pdfKitEngine.js:7:13 at globalThis (/Users/user/code/app/node_modules/pdfmake/src/pdfKitEngine.js:21:0) at overridableRequire (:1:20) at /Users/user/code/app/node_modules/pdfmake/src/printer.js:4:4 at globalThis (/Users/user/code/app/node_modules/pdfmake/src/printer.js:709:17) at processTicksAndRejections (:61:76)

liborm85 commented 11 months ago

According to https://github.com/oven-sh/bun/pull/7405 it is bug in Bun. I close here.

adarshmadrecha commented 3 months ago

The issue mentioned by @liborm85 is now solved in bun js So, anyone now trying it out can use bunjs.