Add `/` to `PublicPath` and `browser.runtime.getURL`
Describe the bug
Trying to call browser.runtime.getURL("/"), but am getting a type error.
Reproduction
Just add browser.runtime.getURL("/") to the vanilla template's background.
Steps to reproduce
pnpm tsc --noEmit
System Info
System:
OS: macOS 14.6.1
CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
Memory: 1.18 GB / 16.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 20.10.0 - ~/.asdf/installs/nodejs/20.10.0/bin/node
Yarn: 1.22.22 - ~/.asdf/installs/nodejs/20.10.0/bin/yarn
npm: 10.2.3 - ~/.asdf/plugins/nodejs/shims/npm
pnpm: 7.33.7 - ~/.asdf/installs/nodejs/20.10.0/bin/pnpm
Browsers:
Chrome: 128.0.6613.138
Safari: 17.6
npmPackages:
wxt: ^0.19.9 => 0.19.9
Used Package Manager
pnpm
Validations
- [X] Read the Contributing Guidelines.
- [X] Read the docs.
- [X] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- [X] Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- [X] The provided reproduction is a minimal reproducible example of the bug.
Good first issue for a contributor. Here's the function that needs updated: https://github.com/wxt-dev/wxt/blob/282458748d69556b53c391cfdb2ecdbb6b4ea0f8/packages/wxt/src/core/utils/building/generate-wxt-dir.ts#L75-L115
Is this issue still pending? if yes then assign It to me
@pritesh7098 yup, it's all yours! Thanks 😀
To test your changes, either run tests:
cd packages/wxt
pnpm test
or prepare the demo extension:
cd packages/wxt-demo
pnpm wxt prepare
@aklinker1
Hey, Aaron!
Looks like this is still an issue, and as I can see, the AugmentedBrowser type explicitly omits getURL.
What's the reason of this? Or is it an issue?
Good first issue for a contributor. Here's the function that needs updated:
https://github.com/wxt-dev/wxt/blob/282458748d69556b53c391cfdb2ecdbb6b4ea0f8/packages/wxt/src/core/utils/building/generate-wxt-dir.ts#L75-L115
@aklinker1 I've got the fix but do let me know if anyone's still working on it. Or else I can create a PR?
Here's the fix:
Just have to add root path in paths variable in getPathsDeclarationEntry function.
This seems to working.
@aklinker1
Hey, Aaron!
Looks like this is still an issue, and as I can see, the
AugmentedBrowsertype explicitly omitsgetURL.What's the reason of this? Or is it an issue?
I tried this as well by removing it from Omit Type.
But didn't solve the type error we're getting while using getURL method for / path.
Looks like this is still an issue, and as I can see, the
AugmentedBrowsertype explicitly omitsgetURL.What's the reason of this? Or is it an issue?
Because the function's types are generated per-project when you run wxt prepare. In a WXT project, run the prepare command, then look at .wxt/types/paths.d.ts.
If you are missing this function in your project, make sure you've setup typescript properly and ran wxt prepare:
https://wxt.dev/guide/essentials/config/typescript.html
Released in https://github.com/wxt-dev/wxt/releases/tag/wxt-v0.19.15
