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

error on openOptionsPage #171

Open
5 tasks done
mia-zhao opened this issue Apr 2, 2024 · 4 comments
Open
5 tasks done

error on openOptionsPage #171

mia-zhao opened this issue Apr 2, 2024 · 4 comments

Comments

@mia-zhao
Copy link

mia-zhao commented Apr 2, 2024

Describe the bug

When clicking the "Open Options" button of pop up, error Uncaught TypeError: Cannot read properties of undefined (reading 'openOptionsPage') is thrown on browser.runtime.openOptionsPage().
Screenshot from 2024-04-01 23-00-48

Reproduction

  1. pnpm dev 2. open extension pop up 3. click "Open Options" 4. option page won't open, observed error Uncaught TypeError: Cannot read properties of undefined (reading 'openOptionsPage')

System Info

System:
    OS: Linux 6.5 Manjaro Linux
    CPU: (4) x64 Intel(R) Core(TM) i5-6200U CPU @ 2.30GHz
    Memory: 504.36 MB / 7.66 GB
    Container: Yes
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 21.6.2 - /usr/bin/node
    Yarn: 1.22.21 - /usr/bin/yarn
    npm: 10.5.0 - /usr/bin/npm
    pnpm: 8.15.2 - /usr/bin/pnpm
    bun: 1.0.35 - ~/.bun/bin/bun
  Browsers:
    Chromium: 123.0.6312.86

Used Package Manager

pnpm

Validations

  • Follow our Code of Conduct
  • Read the Contributing Guide.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
  • The provided reproduction is a minimal reproducible of the bug.
@mia-zhao
Copy link
Author

mia-zhao commented Apr 2, 2024

I don't quite understand the error behind. But I played around a bit, manually importing import browser from 'webextension-polyfill' in Popup.vue or updating the auto import config 'webextension-polyfill': [ ['*', 'browser'], ], to 'webextension-polyfill': [ ['default', 'browser'], ], seems to fix the undefined error

@tmkx
Copy link
Collaborator

tmkx commented Apr 2, 2024

updating the auto import config 'webextension-polyfill': [ ['*', 'browser'], ], to 'webextension-polyfill': [ ['default', 'browser'], ], works in dev, but breaks in production.

it seems like a bug in the unplugin-auto-import (not sure), PRs welcome :)

@mia-zhao
Copy link
Author

mia-zhao commented Apr 4, 2024

hi @tmkx thanks for following up. It does look like a limitation of unplugin-auto-import.

Based on the generated code from unplugin-auto-import, when 'webextension-polyfill': [ ['*', 'browser'] ] is configured, the Browser type is generated correctly (however, the browser object imported is not - the actual browser alias needed is in fact browser.default, and thus the reason browser.runtime is undefined). Likewise, if 'webextension-polyfill': [ ['default', 'browser'] ] is used, the imported object is correct (while Browser type is not).

@zreren
Copy link

zreren commented May 9, 2024

updating the auto import config 'webextension-polyfill': [ ['*', 'browser'], ], to 'webextension-polyfill': [ ['default', 'browser'], ], works in dev, but breaks in production.

it seems like a bug in the unplugin-auto-import (not sure), PRs welcome :)

That works for me

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

No branches or pull requests

3 participants