Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sw.js inline import ?url filecontent, it should be return a file url. #9256

Closed
shynome opened this issue Mar 1, 2023 · 2 comments · Fixed by #9285
Closed

sw.js inline import ?url filecontent, it should be return a file url. #9256

shynome opened this issue Mar 1, 2023 · 2 comments · Fixed by #9285
Labels
service worker Stuff related to service workers

Comments

@shynome
Copy link

shynome commented Mar 1, 2023

Describe the bug

sw.js inline import ?url filecontent, it should be return a file url.

Reproduction

npm create svelte sw-inline-reproduction
cd sw-inline-reproduction
echo 'import l from "./service-worker.js?url";console.log(l)' > src/service-worker.js
npm run build
cat .svelte-kit/output/client/service-worker.js

you will see the service-worker.js file include to the ?url filecontent

Logs

const a = "data:application/javascript;base64,aW1wb3J0IGwgZnJvbSAiLi9zZXJ2aWNlLXdvcmtlci5qcz91cmwiO2NvbnNvbGUubG9nKGwpCg==";
console.log(a);

System Info

System:
    OS: Linux 5.10 Debian GNU/Linux 11 (bullseye) 11 (bullseye)
    CPU: (16) x64 AMD Ryzen 7 5700G with Radeon Graphics
    Memory: 18.65 GB / 30.72 GB
    Container: Yes
    Shell: 5.1.4 - /bin/bash
  Binaries:
    Node: 18.14.2 - /usr/bin/node
    Yarn: 1.22.19 - /usr/bin/yarn
    npm: 9.5.0 - /usr/bin/npm
  Browsers:
    Chrome: 110.0.5481.177
    Firefox: 102.8.0esr
  npmPackages:
    @sveltejs/adapter-auto: ^2.0.0 => 2.0.0 
    @sveltejs/adapter-static: ^2.0.1 => 2.0.1 
    @sveltejs/kit: ^1.9.1 => 1.9.1 
    svelte: ^3.54.0 => 3.55.1 
    vite: ^4.1.4 => 4.1.4

Severity

serious, but I can work around it

Additional Information

I have import a large wasm file (size 1.6M) in sw.js, if inline the wasm file will make sw.js load slow. (assetsInlineLimit: 0 option is not working for sw.js)
My current solution is to copy the wasm files to the static directory and manually set the wasmUrl

@shynome
Copy link
Author

shynome commented Mar 1, 2023

I have updated the Reproduction step, now it easily reproduce

@Rich-Harris
Copy link
Member

Started investigating in #9285

Rich-Harris pushed a commit that referenced this issue Mar 30, 2023
@benmccann benmccann added the service worker Stuff related to service workers label Dec 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
service worker Stuff related to service workers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants