fix(media): serve the image-compression worker's script ourselves #12
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/image-compression-worker"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #11
Changes
client/src/media.ts:prepareImagepasseslibURLtobrowser-image-compression, pointing at the library's own UMD build (dist/browser-image-compression.js) imported with Vite's?url, so it is emitted under/assets/and served from our origin. The URL is made absolute because the library's worker runs from ablob:URL, where relative URLs do not resolve. Without this, the workerimportScripts()the library fromcdn.jsdelivr.net.Verification
dist/assets/browser-image-compression-<hash>.js, byte-identical to the package'sdist/browser-image-compression.js, and the bundle passes/assets/browser-image-compression-<hash>.jsas the worker's script.https://pr-12.preview.genji1024.com/, the first real one from #9): post a picture and confirm in the browser's devtools that the worker loads the script from the preview's own/assets/with no CSP violation and no fallback to the main thread.LGTM!