无法在manifest v3中使用Firebase数据库构建Chrome扩展程序?

3
我正在尝试构建一个Chrome扩展程序,在我的 content.js 文件中使用firebase作为数据库,但是它不起作用。我正在使用v3清单。但我无法导入firebase。
我尝试使用 resource在项目中设置firebase。我还尝试从 firebase-app.js firebase-database.js下载源代码,并使用导入。
const firebase = chrome.extension.getURL('./firebase-app.js');

但此文件具有来自以下的导入:
https://www.gstatic.com/firebasejs/9.15.0/firebase-app.js

这违反了“内容安全策略”,我收到了这个错误。
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.

我知道 外部代码限制
在原生JS实现中有没有任何解决方法?
1个回答

2
根据ECRs的规定,您不能从CDN加载这些脚本。
相反,您必须安装一个JavaScript构建流程(例如webpackRollup)来编译扩展代码的应用程序包。
Firebase有关于此过程的文档以及相关资源链接值得查阅。

使用ReactJS构建扩展是否比使用Vanilla JS更好? - Raj Chandra

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接