Jervis2049 / vite-plugin-crx-mv3

Build a Chrome Extension with Vite⚡
201 stars 30 forks source link

How can we use `import` in `background.ts` #14

Closed FavorMylikes closed 1 year ago

FavorMylikes commented 1 year ago

When I use import to invoke other api, I got this error below:

Uncaught SyntaxError: Cannot use import statement outside a module

Is there any way to solve this?

https://github.com/Jervis2049/vite-plugin-crx-mv3/blob/e0c27aadfacaa7aa02736589e6f61437562c36a4/examples/crx-vue-drawer/src/background.ts

FavorMylikes commented 1 year ago

Add type: module at the background in the manifest could solve this problem

But maybe we need to make some changes here

    manifest.background = {
      service_worker: SERVICE_WORK_DEV_PATH
    };
Jervis2049 commented 1 year ago

Thank you for the correction, I have fixed the problem in v0.1.1, please try again.

FavorMylikes commented 1 year ago

Thank you for the correction, I have fixed the problem in v0.1.1, please try again.

Cool, Fixed