Importing virtual:pwa-register in +layout.svelte causes bug during build:
[vite-plugin-pwa:sveltekit:build] The 'swSrc' file can't be read. ENOENT: no such file or directory, open '.svelte-kit/output/client/service-worker.js'
error during build:
Error: The 'swSrc' file can't be read. ENOENT: no such file or directory, open '.svelte-kit/output/client/service-worker.js'
at injectManifest (node_modules/.pnpm/workbox-build@7.0.0/node_modules/workbox-build/build/inject-manifest.js:71:15)
at async Object.handler (file://node_modules/.pnpm/@vite-pwa+sveltekit@0.2.5_@sveltejs+kit@1.22.4_vite-plugin-pwa@0.16.4/node_modules/@vite-pwa/sveltekit/dist/index.mjs:189:31)
at async PluginDriver.hookParallel (file://node_modules/.pnpm/rollup@3.27.1/node_modules/rollup/dist/es/shared/node-entry.js:25338:17)
at async file://node_modules/.pnpm/rollup@3.27.1/node_modules/rollup/dist/es/shared/node-entry.js:26578:13
at async catchUnfinishedHookActions (file://node_modules/.pnpm/rollup@3.27.1/node_modules/rollup/dist/es/shared/node-entry.js:25782:16)
at async rollupInternal (file://node_modules/.pnpm/rollup@3.27.1/node_modules/rollup/dist/es/shared/node-entry.js:26565:5)
at async build (file://node_modules/.pnpm/vite@4.4.8_@types+node@20.4.6_sass@1.64.2/node_modules/vite/dist/node/chunks/dep-75f53616.js:47956:18)
at async CAC.<anonymous> (file://node_modules/.pnpm/vite@4.4.8_@types+node@20.4.6_sass@1.64.2/node_modules/vite/dist/node/cli.js:822:9)
ELIFECYCLE Command failed with exit code 1.
Inspecting .svelte-kit/output/client/ i can see that there is no service-worker.js or sw.js file when the error is thrown.
It works running locally and if i comment out the import
import { registerSW } from 'virtual:pwa-register';
Importing
virtual:pwa-register
in+layout.svelte
causes bug during build:Inspecting .svelte-kit/output/client/ i can see that there is no service-worker.js or sw.js file when the error is thrown.
It works running locally and if i comment out the import
it works to build the app.
vite.config.ts:
sw.ts:
svelte.config.js
Versions: