PlasmoHQ / plasmo

šŸ§© The Browser Extension Framework
https://www.plasmo.com
MIT License
10.59k stars 369 forks source link

[EXP] Inconsistency between dev mode and prod mode permissions (Bug?) #1049

Open zystudios opened 3 months ago

zystudios commented 3 months ago

In dev mode, I seem to have all the permissions, and I don't have to declare them separately in package.json.

 "manifest": {
    "host_permissions": [
      "https://*/*"
    ],
    "permissions": [
    ]
  }

For example, I don't have to declare tabs permissions to use chrome.tabs.sendMessage

But in prod mode, If I don't declare tabs permission I can't use chrome.tabs.sendMessage

I must declare it in package.json:

  "permissions": [
       "tabs"
    ]

There are also things like having to declare contextMenus in order to use chrome.contextMenus.create under prod, etc.

But under dev I can just use it without declaring it.

  "permissions": [
       "contextMenus"
    ]

šŸ™šŸ™šŸ™šŸ™šŸ™šŸ™šŸ™šŸ™

So this creates a problem, everything works fine with my extension in the dev environment, but in the prod environment there are all sorts of problems because I don't know about this mechanism of plasmo, and I have to declare the relevant permissions in the prod environment to be able to use it.

Is this a bug or is the framework designed so ?

I suggest to keep all the permissions the same whether it's dev or prod, so that you can find the problem as early as possible under dev!

Or the framework can do a check if you use code without declared permissions and give you the necessary hints.

Thanks

Code of Conduct