KeithHenry / chromeExtensionAsync

Promise wrapper for the Chrome extension API so that it can be used with async/await rather than callbacks
MIT License
228 stars 32 forks source link

How can I use this in background.js? #19

Closed avalanche1 closed 5 years ago

avalanche1 commented 5 years ago

How can I use this awesome package in background.js file of an extension?

KeithHenry commented 5 years ago

@avalanche1 you can use import '../node_modules/chrome-extension-async/chrome-extension-async.js' or you can add a <script> in background.html or add it to the list in the background section of the manifest.

avalanche1 commented 5 years ago

Do you know a way to make import work in chrome extensions?

KeithHenry commented 5 years ago

@avalanche1 import works fine in Chrome extensions, but this library is overwriting an existing API and so applies as a side effect.

import '../node_modules/chrome-extension-async/chrome-extension-async.js'; should work, have you had issues with it?

avalanche1 commented 4 years ago

Thanks for the answer. Although I've decided to write extension files with typescript. So it handles all the imports for me now. Yay!