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
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