Skip to content

importing ?script from package doesn't work in dev, but works in build #924

@salmin89

Description

@salmin89

Build tool

Vite

Where do you see the problem?

  • In the browser
  • In the terminal

Describe the bug

when running in dev mode this code produces:

Error: Could not load javascript '' for script.

import scriptPath from '@scope/content/injected/myFeature?script';

console.log('path', scriptPath);
chrome.scripting
  .registerContentScripts([
    {
      id: 'myscript',
      js: [scriptPath],
      matches: ['<all_urls>'],
      runAt: 'document_start',
    },
  ])
  .then(() => {
    console.log('success reg');
  })
  .catch(console.error);

Reproduction

n/a

Logs

No response

System Info

System:
    OS: macOS 14.7
    CPU: (12) arm64 Apple M2 Pro
    Memory: 749.72 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.5.0 - ~/.nvm/versions/node/v18.20.0/bin/npm
    bun: 1.1.21 - /opt/homebrew/bin/bun
  Browsers:
    Brave Browser: 129.1.70.119
    Chrome: 129.0.6668.71
    Chrome Canary: 131.0.6750.0
    Edge: 129.0.2792.65
    Safari: 18.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