antfu-collective / vitesse-webext

⚡️ WebExtension Vite Starter Template

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

HMR on contentScript not working on Firefox

privatenumber opened this issue · comments

Description

HMR on content scripts isn't working for me in Firefox with the current setup.

This comment explains that Firefox caches the content script so this hack is necessary (contentScript removal & background script), but interestingly, content script HMR works fine if I remove this hack.

Reproduction

  1. Clone repo and pnpm i
  2. Run npm run dev in one shell
  3. Run npm run start:firefox in another shell
  4. Navigate to random site and open dev console
  5. Add console.log(1) to src/contentScripts/index.ts

Expectation is for 1 to be logged without refreshing the page, but it does not.

Environment

$ npx envinfo --system --binaries --browsers

  System:
    OS: macOS 11.6
    CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 181.58 MB / 64.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 14.16.1 - ~/.nvm/versions/node/v14.16.1/bin/node
    Yarn: 1.22.11 - ~/.nvm/versions/node/v14.16.1/bin/yarn
    npm: 6.14.12 - ~/.nvm/versions/node/v14.16.1/bin/npm
  Browsers:
    Chrome: 94.0.4606.81
    Firefox: 93.0
    Safari: 15.0

Could it be that Firefox no longer caches in the latest release?