Chrome应用程序CSP违反Dart / Polymer转换/编译为JavaScript后 [英] Chrome App CSP violation after Dart/Polymer transform/compile to JavaScript

查看:168
本文介绍了Chrome应用程序CSP违反Dart / Polymer转换/编译为JavaScript后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

很好 - 所以关于Polymer的 dart2js 有很多类似的问题。我似乎遇到了一个特定的问题,这是做这个,但也运行它作为一个Chrome应用程序。

Alright-- so there are a lot of similar questions regarding Polymer after dart2js. I am seemingly running into an issue that's specific to doing this but also running it as a Chrome app.

我发现结果根据变压器的顺序而不同(这是预期的)。

I have discovered that the outcome varies depending on the order of the transformers (which is expected).

这是我到目前为止的结果:

Here's my results so far:

transformers:
- chrome
- polymer:
    entry_points: web/example.html
    csp: true
- $dart2js:
    csp: true

这在浏览器中运行良好,但在以Chrome应用运行时失败。

This works great in browser but fails when run as a Chrome app.

错误:未捕获的TypeError:无法读取未定义的属性apply(在example.html_bootstrap.dart.js文件中)

Error: Uncaught TypeError: Cannot read property 'apply' of undefined (in the example.html_bootstrap.dart.js file)

从这一点上,我删除了 chrome 变压器,因为它是多余的

From this point I am removing the chrome transformer because it's redundant.

现在我将切换变换器的顺序:

Now I will switch the order of the transformers:

transformers:
- $dart2js:
    csp: true
- polymer:
    entry_points: web/example.html
    csp: true

在浏览器中运行时失败。
错误: example.html_bootstrap.dart.js net :: ERR_FILE_NOT_FOUND

This fails when run in the browser. Error: example.html_bootstrap.dart.js net::ERR_FILE_NOT_FOUND

作为Chrome应用(同样的错误)。

This also fails when run as a Chrome app (with the same error).

现在我试着复制CDE团队中的人正在做什么。完全取出$ dart2js变压器。
https://github.com/dart-lang /chromedeveditor/blob/master/ide/pubspec.yaml

Now I try to replicate what the guys on the CDE team are doing. Taking out the $dart2js transformer entirely. https://github.com/dart-lang/chromedeveditor/blob/master/ide/pubspec.yaml

transformers:
- polymer:
    entry_points: web/example.html
    csp: true



This runs perfectly from the browser.

以Chrome应用程式执行时会失败。

This fails when run as a Chrome app.

错误:blah blah违反CSP政策与 unsafe-eval

Error: blah blah violates CSP policy with unsafe-eval

只是为了掩盖我的基础我也试过这政策):

Just to cover my bases I also tried this (fails CSP policy):

- chrome
- polymer:
    entry_points: web/example.html
    csp: true

p>

and this (fails CSP policy):

- polymer:
    entry_points: web/example.html
    csp: true
- chrome


推荐答案

使用Polymer时 chrome 变压器, $ dart2js 应该是最后一个变压器。
csp_fixer 应该修复其余的问题。

I think you can omit the chrome transformer when you use Polymer and $dart2js should be the last transformer. csp_fixer is supposed to fix remaining issues.

这篇关于Chrome应用程序CSP违反Dart / Polymer转换/编译为JavaScript后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆