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

Automatically call browser.runtime.getURL when importing assets #1217

Closed
aklinker1 opened this issue Nov 26, 2024 · 1 comment
Closed

Automatically call browser.runtime.getURL when importing assets #1217

aklinker1 opened this issue Nov 26, 2024 · 1 comment
Labels
feature wontfix This will not be worked on

Comments

@aklinker1
Copy link
Collaborator

aklinker1 commented Nov 26, 2024

Feature Request

Change the example from the docs:

// entrypoints/content.ts
import iconUrl from '/icon/128.png';

export default defineContentScript({
  matches: ['*://*.google.com/*'],
  main() {
-   console.log(iconUrl); // "/icon/128.png"
-   console.log(browser.runtime.getURL(iconUrl)); // "chrome-extension://<id>/icon/128.png"
+   console.log(iconUrl); // "chrome-extension://<id>/icon/128.png"
  },
});

Is your feature request related to a bug?

N/A

What are the alternatives?

Having developers manually call browser.runtime.getURL.

Additional context

Noticed while trying to decide where to put the new web_accessible_resources warning in #1216

@aklinker1
Copy link
Collaborator Author

Doesn't seem like there's an easy way to do this... No hook for this, and the generateBundle hook doesn't include public directory files... so there's no way to detect all filenames that should be wrapped in browser.runtime.getURL(...).

Ideally, it'd be as simple as looping through the bundle (before it's written to disk), and wrapping each file path in browser.runtime.getURL(...).

However... doing a replacement like that across megabytes of text will be slow... So I don't think I want to add this.

@aklinker1 aklinker1 closed this as not planned Won't fix, can't repro, duplicate, stale Nov 27, 2024
@aklinker1 aklinker1 added the wontfix This will not be worked on label Nov 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

1 participant