How to include any js (i need crypto JS) library in backgroud script of web-extension?

Viewed 336

My current setup including:

manifest.json:

"background": {
    "scripts": [
      "scripts/cryptojs.js",
      "scripts/background.js"
    ]
  },

But when I actually call the Crypto function like,

code inside background.js:

var calculated_hash = CryptoJS.MD5(textValue);

The backgroud console error says,

CryptoJS is not defined
1 Answers

I found that libraries like this one to work perfectly need to be installed via NPM or Yarn only, manually adding CDN files may result in random errors

Related