好吧——之后有很多关于聚合物的类似问题dart2js
。我似乎遇到了一个特定于执行此操作但也将其作为 Chrome 应用程序运行的问题。
我发现结果根据变压器的顺序而变化(这是预期的)。
这是我到目前为止的结果:
transformers:
- chrome
- polymer:
entry_points: web/example.html
csp: true
- $dart2js:
csp: true
这在浏览器中效果很好,但在作为 Chrome 应用程序运行时会失败。
Error: Uncaught TypeError: Cannot read property 'apply' of undefined
(在 example.html_bootstrap.dart.js 文件中)
从现在起我将删除chrome
变压器,因为它是多余的。
现在我将切换变压器的顺序:
transformers:
- $dart2js:
csp: true
- polymer:
entry_points: web/example.html
csp: true
在浏览器中运行时会失败。
错误:example.html_bootstrap.dart.js net::ERR_FILE_NOT_FOUND
当作为 Chrome 应用程序运行时,这也会失败(具有相同的错误)。
现在我尝试复制 CDE 团队的成员正在做的事情。完全删除 $dart2js 变压器。https://github.com/dart-lang/chromedeveditor/blob/master/ide/pubspec.yaml
transformers:
- polymer:
entry_points: web/example.html
csp: true
这可以从浏览器完美运行。
当作为 Chrome 应用程序运行时,此操作会失败。
错误:blah blah 违反了 CSP 政策unsafe-eval
为了覆盖我的基础,我也尝试了这个(未通过 CSP 政策):
- chrome
- polymer:
entry_points: web/example.html
csp: true
这(未通过 CSP 政策):
- polymer:
entry_points: web/example.html
csp: true
- chrome