Chrome App CSP violation after Dart/Polymer transform/compile to JavaScript

折月煮酒 提交于 2019-11-30 19:00:26

问题


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

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

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

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

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

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

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.

This fails when run as a Chrome app.

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

and this (fails CSP policy):

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

回答1:


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.



来源:https://stackoverflow.com/questions/27511346/chrome-app-csp-violation-after-dart-polymer-transform-compile-to-javascript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!