I'm running into issues in development mode with Closure as the security policies for my Chrome Packaged App (i.e., v2 manifest file) are restricting things called in the Closure bootstrap process (e.g., when I load the app using the uncompiled dev code, I get "document.write() is not available in the sandbox of packaged apps").
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
The following code is what I eventually used and it works great for running Closure in Dev mode within Chrome's Packaged App framework.
In closure/goog/base.js, overwrite goog.global.CLOSURE_IMPORT_SCRIPT as follows:
goog.global.CLOSURE_IMPORT_SCRIPT = function(src) {
var script = document.createElement('script');
script.src = src;
script.type = 'text/javascript';
goog.global.document.getElementsByTagName("head")[0].appendChild(script);
return true;
};