Open vursen opened 2 years ago
At this moment, Vite has an issue that results in generating an error whenever you try to re-build the service worker after the deps have been pre-bundled.
[vite] Internal server error: Could not load /Users/vursen/dev/vaadin/flow/flow-tests/test-frontend/vite-pwa/node_modules/.pnpm/workbox-core@6.4.2/node_modules/workbox-core/index.mjs?v=5e1803bc (imported by frontend/sw.ts): ENOENT: no such file or directory, open '/Users/vursen/dev/vaadin/flow/flow-tests/test-frontend/vite-pwa/node_modules/.pnpm/workbox-core@6.4.2/node_modules/workbox-core/index.mjs?v=5e1803bc'
The build succeeds if you are running it before the first pre-bundling.
Describe your motivation
A follow-up to #12928, #12383
When developing a custom service worker, it would be good to have Vite re-build the service worker on source code change, saving the user from having to restart the server.
Describe the solution you'd like
Watch the service worker's source code and cause re-building when a change occurs. A possible place for the watcher could be
buildSWPlugin
:https://github.com/vaadin/flow/blob/66b46b60be259df9d1f8c6603e22bff917a653a5/flow-server/src/main/resources/vite.generated.ts#L50-L100