Skip to content

Dynamic Scripts break with vite build --watch #990

@salmin89

Description

@salmin89

Build tool

rollup

Where do you see the problem?

  • In the browser
  • In the terminal

Describe the bug

When developing for Firefox and Safari I use vite build --watch
The initial build works, but once you make a change and save, it breaks in terminal.

[crx:content-scripts] Plugin error - Unable to get file name for unknown file "CjI6$MfX".

Reproduction

  • everything vanilla
  • package.json
"scripts": {
    "dev": "vite build --watch",
},
  • content.ts (content script or background doesn't matter).
import foo from './foo?script'

run once, then edit a file and save.

Logs

System Info

System:
    OS: macOS 14.7.4
    CPU: (12) arm64 Apple M2 Pro
    Memory: 178.16 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.20.0 - ~/.nvm/versions/node/v18.20.0/bin/node
    Yarn: 1.22.22 - ~/.nvm/versions/node/v18.20.0/bin/yarn
    npm: 10.9.0 - ~/.nvm/versions/node/v18.20.0/bin/npm
    pnpm: 10.4.1 - ~/.nvm/versions/node/v18.20.0/bin/pnpm
    bun: 1.1.21 - /opt/homebrew/bin/bun
  Browsers:
    Brave Browser: 133.1.75.181
    Chrome: 133.0.6943.142
    Chrome Canary: 135.0.7043.0
    Edge: 133.0.3065.92
    Safari: 18.3
  npmPackages:
    @crxjs/vite-plugin: ^2.0.0-beta.31 => 2.0.0-beta.31 
    vite: ^6.1.0 => 6.2.0

Severity

annoyance

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions