swissspidy / media-experiments

WordPress media experiments
GNU General Public License v2.0
84 stars 1 forks source link

Load wasm-vips locally for offline use (#292) #603

Closed kleisauke closed 1 month ago

kleisauke commented 1 month ago

Load wasm-vips locally instead of from a CDN, enabling its features to work offline.


Note: the patch is temporary, I'll include that in the next release of wasm-vips.

swissspidy commented 1 month ago

This is amazing, thank you so much! 🚀 Good idea too with the cache busting 👍

This seems to work great already. On my local site I just needed #604 to ensure the correct mime type for wasm files.

The only blocker is the publicPath setting. Unfortunately I can't make assumptions about that path, as the plugin could be hosted elsewhere.

In the past I defined __webpack_public_path__ on the fly to work around this limitation. But that's probably not very helpful here as @shopify/web-worker will load packages/vips/src/index.ts in an inline blob worker.

605 / b65907c1151a416909620aa7c9ff582980abea41 is an attempt at working around that by dynamically passing the the public path to the script. There might be better ways, but it seems to work.