wxt icon indicating copy to clipboard operation
wxt copied to clipboard

Add `/` to `PublicPath` and `browser.runtime.getURL`

Open aaronklinker-st opened this issue 1 year ago • 4 comments

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

aaronklinker-st avatar Sep 16 '24 22:09 aaronklinker-st

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 avatar Sep 17 '24 17:09 aklinker1

Is this issue still pending? if yes then assign It to me

pritesh7098 avatar Sep 21 '24 06:09 pritesh7098

@pritesh7098 yup, it's all yours! Thanks 😀

aklinker1 avatar Sep 21 '24 13:09 aklinker1

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 avatar Sep 21 '24 13:09 aklinker1

@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?

CleanShot 2024-11-13 at 08 57 47@2x

ahudovich avatar Nov 13 '24 08:11 ahudovich

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.

nishu-murmu avatar Nov 13 '24 09:11 nishu-murmu

@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?

CleanShot 2024-11-13 at 08 57 47@2x

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.

nishu-murmu avatar Nov 13 '24 09:11 nishu-murmu

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?

CleanShot 2024-11-13 at 08 57 47@2x

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

aklinker1 avatar Nov 13 '24 13:11 aklinker1

Released in https://github.com/wxt-dev/wxt/releases/tag/wxt-v0.19.15

aklinker1 avatar Nov 14 '24 20:11 aklinker1