Closed pustovitDmytro closed 5 months ago
This looks to be an issue with workbox-background-sync
. When you inspect the code at https://www.npmjs.com/package/workbox-background-sync?activeTab=code, the main
entry of package.json points to index.js
and that uses import
statements, which shouldn't be there.
Perhaps you can configure vite (rollup) to process that package somehow, it seems likely that vite just uses import
because it's in there.
@wmertens does this issue still require a repro? or can it be closed?
Which component is affected?
Qwik Rollup / Vite plugin
Describe the bug
When using the popular 'workbox-background-sync' package by Workbox in combination with the @builder.io/qwik-city/service-worker package, an issue arises where the service worker bundle is not generated correctly.
The error message "Uncaught SyntaxError: Cannot use import statement outside a module" is encountered, and the problem seems to be related to the generated import statement in the service-worker.js file.
service-worker.txt
note the line
import{o as I}from"./q-IQTssp_s.js"
it should not appear in the service worker bundle.Reproduction
https://github.com/pustovitDmytro/qwik-sw-bug-reproduce
Steps to reproduce
next service worker fails:
in the repository run:
npm ci npm run build cat dist/service-worker.js | grep import
System Info
Additional Information
after removing the BackgroundSyncPlugin usage issue fixes
using some other 'workbox' packages works ('workbox-strategies', 'workbox-routing', 'workbox-precaching')