shadowwalker / next-pwa

Zero config PWA plugin for Next.js, with workbox šŸ§°
MIT License
3.89k stars 325 forks source link

Next-pwa doesn't work with Sentry/nextjs plugin #213

Closed abordeau closed 3 years ago

abordeau commented 3 years ago

Summary

I tried to use next-pwa with the sentry integration but the service-worker is not register in this case.

Versions

How To Reproduce

Steps to reproduce the behavior:

  1. Clone this repo
  2. Install the app with yarn install and run it with yarn dev
  3. Open the navigator on http://localhost:3000/
  4. Check if a service worker is registered in the chrome dev tools

Expected Behaviors

The sw.js file and the workbox.js are created in the public folder but they are not registered by the browser

This is the next.config.js file I used :

const withPWA = require('next-pwa')
const runtimeCaching = require('next-pwa/cache')
const { withSentryConfig } = require('@sentry/nextjs')

const moduleExports = withPWA({
  pwa: {
    dest: 'public',
    runtimeCaching,
  },
})

const SentryWebpackPluginOptions = {
  // Additional config options for the Sentry Webpack plugin. Keep in mind that
  // the following options are set automatically, and overriding them is not
  // recommended:
  //   release, url, org, project, authToken, configFile, stripPrefix,
  //   urlPrefix, include, ignore
  // For all available options, see:
  // https://github.com/getsentry/sentry-webpack-plugin#options.
}

// With this config, the service worker  is not registered by the browser
module.exports = withSentryConfig(moduleExports, SentryWebpackPluginOptions)

// This config works
// module.exports = moduleExports
wonderlandpark commented 3 years ago

This happens to me too.

nihalanisumit commented 3 years ago

I'm having the same issue :/

although my next.config.js file looks a lil different

const withPlugins = require('next-compose-plugins')
const { withSentryConfig } = require('@sentry/nextjs')
const withPWA = require('next-pwa')
const runtimeCaching = require('next-pwa/cache')
const withSvgr = require('next-svgr')

const sentryWebpackPluginOptions = {
  // For all available options, see:
  // https://github.com/getsentry/sentry-webpack-plugin#options.
}
const PWAPluginOptions = {
  pwa: {
    dest: 'public',
    runtimeCaching,
  },
}

module.exports = withPlugins([withSvgr, [withPWA, PWAPluginOptions], [withSentryConfig, sentryWebpackPluginOptions]])
abordeau commented 3 years ago

I also tried with withPlugins and yes, same error.

nihalanisumit commented 3 years ago

@abordeau did you try any other solution or any other library?

abordeau commented 3 years ago

I close this issue since the bug was resolve by Sentry teams (https://github.com/getsentry/sentry-javascript/issues/3538) Thanks anyway šŸ‘ŒšŸ¼

mburri commented 3 years ago

Actually, the Issue was reopened again: https://github.com/getsentry/sentry-javascript/issues/3538#issuecomment-856896363