webpack-extension-reloader: Manifest V3 Service worker registration failed

Type:

  • [x ] bug
  • feature
  • enhancement
  • question

Environment:

  • OS:
  • Browser: Chrome
  • Library Version:

I’m going to open a PR:

  • yes
  • [ x] no

Description: Getting error: “Service worker registration failed” , "background": { "service_worker": "background.js" }, is highlighted in the error. When I build for production, the error goes away. I think it has to do with all of the code that this library adds to the background.js file when it is output.

This is from my config file:

      // Chrome extension hot reloading.
      isEnvDevelopment &&
        new ChromeExtensionReloader({
          reloadPage: true, // Force the reload of the page also
          entries: {
            // The entries used for the content/background scripts
            background: "background",
            contentScript: "content-script", // Use the entry names, not the file name or the path
          },
        }),
    ].filter(Boolean),

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Reactions: 9
  • Comments: 17

Most upvoted comments

I am experiencing same issue. It’s because it injects the “webpack-extension-reloader” code in compiled background.js. That prevents the service worker from working.

Thanks makes sense!

@khlevon Great! I found another bug which I had to fix in my webpack config. I’d create a PR soon on your repo.

@zdenham I have fixed this issue and opened a pull request, but I think the maintainer will not merge it because the project support stoped. You can clone code from this brunch build it locally and use bundle file dist/webpack-extension-reloader.js