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

Service Worker "import" error when sourcemapping #641

Open
ArnauKokoro opened this issue Jan 10, 2024 · 7 comments
Open

Service Worker "import" error when sourcemapping #641

ArnauKokoro opened this issue Jan 10, 2024 · 7 comments

Comments

@ArnauKokoro
Copy link

Hi,

I'm addressing this issue to you.

getsentry/sentry-javascript-bundler-plugins#460

Thanks!

@userquin
Copy link
Member

can you add type: 'module' in PWA devOptions entry? Since sentry is adding an import to the sw in dev mode, this plugin doesn't include anything in the sw (it is build by workbox-build module):

;import "/@id/__x00__sentry-release-injection-file";

@ArnauKokoro
Copy link
Author

Adding type: 'module' on VitePWA devOptions I'm having same error on dev mode.

Thanks!

@userquin
Copy link
Member

can you provide a minimal repro?

@ArnauKokoro
Copy link
Author

Just running yarn dev

This is what chrome console says:
Uncaught SyntaxError: Cannot use import statement outside a module (at dev-sw.js?dev-sw:96:2)

And these are the lines of dev-sw.js:

define(['./workbox-9637eeee'], (function(workbox) {
    'use strict';

    self.addEventListener('message', event=>{
        if (event.data && event.data.type === 'SKIP_WAITING') {
            self.skipWaiting();
        }
    }
    );

    /**
   * The precacheAndRoute() method efficiently caches and responds to
   * requests for URLs in the manifest.
   * See https://goo.gl/S9QRab
   */
    workbox.precacheAndRoute([{
        "url": "index.html",
        "revision": "0.fp20qtanrkg"
    }], {});
    workbox.cleanupOutdatedCaches();
    workbox.registerRoute(new workbox.NavigationRoute(workbox.createHandlerBoundToURL("index.html"),{
        allowlist: [/^\/$/]
    }));

}
));
//# sourceMappingURL=sw.js.map

;import "/@id/__x00__sentry-release-injection-file";
//# sourceMappingURL=data:application/json;base64;xxx

@yuri-ellfort
Copy link

Any updates here? @ArnauKokoro have you found a solution?

@ArnauKokoro
Copy link
Author

Hi @yuri-ellfort,

When is development mode i'm setting globPatterns to [].

@userquin
Copy link
Member

userquin commented Apr 26, 2024

sentry an pwa plugin or pwa plugin integrations cannot be used with generateSW strategy, check: vite-pwa/nuxt#132

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants