Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
1 of 2 tasks
salmin89 opened this issue Oct 2, 2024 · 3 comments
Open
1 of 2 tasks
Labels

Comments

@salmin89
Copy link

salmin89 commented Oct 2, 2024

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

Copy link
Contributor

github-actions bot commented Feb 5, 2025

Thanks for contributing to CRXJS! This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs within 7 days.

@github-actions github-actions bot added the Stale label Feb 5, 2025
@salmin89
Copy link
Author

salmin89 commented Feb 9, 2025

this is still an issue for us. The workaround is to create a local file that you can import from background.ts, and let that local file import @scope/content/injected/myFeature

Importing from a package with ?script doesn't work in our monorepo setup.

Copy link
Contributor

github-actions bot commented Feb 9, 2025

⚠️ Important Notice: CRXJS is seeking new maintainers.

  • New issues and PRs may not receive immediate attention
  • A new maintenance team must establish itself by March 31, 2025 or this repository will be archived on June 1, 2025
  • Learn more about the transition

This is an automated message. Please do not reply to this comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant