extension-cli icon indicating copy to clipboard operation
extension-cli copied to clipboard

javascript files for popup being built as service worker

Open l1ionelw opened this issue 2 years ago • 0 comments

Describe the bug javascript files for popup being built as service worker

To Reproduce Steps to reproduce the behavior:

  1. Create new project
  2. In src folder, copy and paste code below
  3. Build and select dist folder to load unpacked in browser
  4. Error is thrown

Expected behavior

  • Extension should load without errors

**Desktop: **

  • OS: Building on MacOS
  • Browser: Chrome 121.0.6167.160
  • Node JS 20.11.0

Manifest JSON:

"action": {
        "default_popup": "popup.html"
    },
    "permissions": [
        "storage",
        "bookmarks"
    ],
    "background": {
        "service_worker": "background.js",
        "type": "module"
    }

background.js:

console.log("background js service worker")

popup.js

console.log("popup js script")

Service Worker logs: background js service worker popup js script

Scripts in popup.html file which includes document.getelement(element), which throws an error (document not found) when it is built as a service worker, requiring scripts in popup to be inline.

l1ionelw avatar Feb 14 '24 23:02 l1ionelw