StarkShang / vite-plugin-chrome-extension

A vite plugin to bundle chrome extensions for Manifest V3.
MIT License
460 stars 68 forks source link

update management permission regex #26

Open Toumash opened 2 years ago

Toumash commented 2 years ago

Issue with details can be found here: https://github.com/StarkShang/vite-plugin-chrome-extension/issues/22

New regex for checking if code is using the management module

There is something more missing, because adding this code to examples\background\dist\background.js

chrome.management.getSelf(() => {
// my code
})

and running the build

yarn; yarn build;
cd examples/background
yarn;yarn build;

still adds management into examples\background\dist\manifest.json

I'm still unsure how exactly code in file src\manifest-input\manifest-parser\permissions.ts is being used

Toumash commented 2 years ago

Writing the test in the src\manifest-input\__tests__\manifest__hook--generateBundle.test.ts should be easier that this testing, but i cannot get it to run

yarn test
yarn run v1.22.17
$ cross-env TS_NODE_COMPILER_OPTIONS={\"module\":\"commonjs\"} mocha --file tests/unit/setup.ts --require ts-node/register --require tsconfig-paths/register

TSError: ⨯ Unable to compile TypeScript:
src/utils/helpers.ts:84:25 - error TS2571: Object is of type 'unknown'.

84             handleError(error.message);