paulocoutinhox / pdfium-lib

PDFium - Project to compile PDFium library to multiple platforms.
https://pdfviewer.github.io/
MIT License
925 stars 90 forks source link

fix ESM wasm build #133

Closed hyzyla closed 2 months ago

hyzyla commented 2 months ago

I made a mistake in the ES WebAssembly build by using the flag -sWASM=0. I initially thought this flag would simply prevent the generation of a WebAssembly binary, but I was wrong. Instead, it embedded everything into a large JavaScript file using wasm2js. In this PR, I removed that flag, and now it generates two WebAssembly files:

drwxr-xr-x  7 hyzyla  staff      224 Aug 31 13:11 .
drwxr-xr-x  6 hyzyla  staff      192 Aug 31 13:11 ..
-rw-r--r--  1 hyzyla  staff    46380 Aug 31 13:11 index.html
-rw-r--r--  1 hyzyla  staff   159408 Aug 31 13:11 pdfium.esm.js
-rwxr-xr-x  1 hyzyla  staff  3899985 Aug 31 13:11 pdfium.esm.wasm
-rw-r--r--  1 hyzyla  staff   159451 Aug 31 13:11 pdfium.js
-rwxr-xr-x  1 hyzyla  staff  3899985 Aug 31 13:11 pdfium.wasm

Both pdfium.wasm and pdfium.esm.wasm are identical, but the pdfium.esm.js module links to pdfium.esm.wasm, and pdfium.js links to pdfium.wasm. I'm not sure if it's currently possible to configure em++ to point to the same file for both, but I think this solution is acceptable for now.