Since lot of js modules are in npm now a days. I was wondering if there is any way to use them directly in making of a chrome extension.
Asked
Active
Viewed 4,227 times
4
-
The extension must include all of its files in the package. Just add a build step. – wOxxOm Jan 09 '18 at 19:28
-
So does that mean its possible? – Gautham Santhosh Jan 10 '18 at 00:00
-
1Possible duplicate of [Is it possible to require npm modules in a chrome extension ?](https://stackoverflow.com/questions/43684452/is-it-possible-to-require-npm-modules-in-a-chrome-extension) – Jonathan Hult Mar 13 '18 at 16:53
1 Answers
5
Yes it is possible to use npm packages but they need to be bundled i.e. included in the extension javascript source. What you need to look into is a module bundler like webpack, rollup to create a bundle for your background scripts and/or content scripts along with the required npm packages. Your manifest should point to your bundled files and it should be working fine.
Here is an example
acesmndr
- 7,087
- 3
- 22
- 27