oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
73.11k stars 2.67k forks source link

`Uncaught SyntaxError` when importing certain PDFs via text loader #12981

Open inad9300 opened 1 month ago

inad9300 commented 1 month ago

What version of Bun is running?

1.1.21+70ca2b76c

What platform is your computer?

Darwin 21.6.0 x86_64 i386

What steps can reproduce the bug?

Bundling the following code:

import doc from './sample.pdf' with { type: 'text' }
console.log(doc.length)

And running it from a browser, it produces:

main.js:59 Uncaught SyntaxError: Invalid or unexpected token (at main.js:59:22)

Example of problematic PDFs:

Example of working PDFs:

What is the expected behavior?

No response

What do you see instead?

No response

Additional information

No response

paperdave commented 1 month ago

the bundled file contains a newline in a string. i looked at the first file and it seems that the \r that is 355069 characters in gets emitted as \n by bun build, but bundling the byte sequence nearby that does not cause the issue.