Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Can't use firebase db to build chrome extension in manifest v3?

I am trying to build a chrome extension that uses firebase as a db in my content.js file but it doesn’t work. I am using v3 manifest. But I am unable to import firebase.

I tried setting up firebase in my project using this resource. I also tried downloading the source code from firebase-app.js and firebase-database.js, and imported it using

const firebase = chrome.extension.getURL('./firebase-app.js');

but this file has imports from

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

https://www.gstatic.com/firebasejs/9.15.0/firebase-app.js

this violates the content_security_policy and I get this error

Refused to load the script ‘https://www.gstatic.com/firebasejs/9.15.0/firebase-app.js’ because it violates the following Content Security Policy directive: “script-src ‘self’ ‘wasm-unsafe-eval’“. Note that ‘script-src-elem’ was not explicitly set, so ‘script-src’ is used as a fallback.

I am aware of the external code restrictions.

Is there any workaround for this in vanilla JS implementation?

>Solution :

As the ECRs state, you cannot load these scripts from a CDN.

Instead you must install a JavaScript build pipeline (such as webpack or Rollup) to compile an application bundle of your extension’s code.

Firebase has documentation on this process and link to relevant resources that are worth reviewing.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading