Reactjs Chrome扩展名中的意外评估生成背景页面
我有一个用TypeScript和React+JSX编写的Chrome扩展。我在我的扩展的Chrome扩展选项卡中看到以下错误:Reactjs Chrome扩展名中的意外评估生成背景页面,reactjs,typescript,google-chrome-extension,Reactjs,Typescript,Google Chrome Extension,我有一个用TypeScript和React+JSX编写的Chrome扩展。我在我的扩展的Chrome扩展选项卡中看到以下错误: Uncaught EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "script-s
Uncaught EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "script-src 'self'".
Context
_generated_background_page.html
Stack Trace
js/background.js:291 (anonymous function)
我没有在代码中的任何地方使用
eval
。因为扩展现在要求CSP,所以我使用的CSP不包括eval
(这被认为是最佳实践)。我认为TypeScript可能正在编译我的代码或JSX代码,以使用eval
。但是,我在缩小/编译的代码中找不到eval
。你们都知道这可能指的是什么吗?当指定devtool选项时,webpack
似乎使用了eval
。可以找到更多文档。在开发(未统一)模式下构建时,这一事实变得更加明显
这种行为是不幸的