Well, define goog.global.document.write (or this.document.write, since
goog.global = this), or override goog.inHtmlDocument_()?

Or maybe use CLOSURE_IMPORT_SCRIPT:

   
https://stackoverflow.com/questions/15279728/closure-dev-mode-chrome-packaged-app-document-write-is-not-available-in

   
http://blog.codekills.net/2012/01/10/loading-google-closure-libraries-from-node.js/

   
https://github.com/google/closure-library/blob/b86cde2489dc50868e2769e42961318a2fd50859/closure/goog/bootstrap/webworkers.js



On 7/11/2021 5:38 AM, Harbs wrote:
> Good idea, but it doesn’t seem to work.
>
> goog.Dependency.prototype.load has the following code which fails:
>
>     if (!goog.inHtmlDocument_()) {
>       goog.logToConsole_(
>           'Cannot use default debug loader outside of HTML documents.');
>       if (this.relativePath == 'deps.js') {
>         // Some old code is relying on base.js auto loading deps.js failing 
> with
>         // no error before later setting CLOSURE_IMPORT_SCRIPT.
>         // CLOSURE_IMPORT_SCRIPT should be set *before* base.js is loaded, or
>         // CLOSURE_NO_DEPS set to true.
>         goog.logToConsole_(
>             'Consider setting CLOSURE_IMPORT_SCRIPT before loading base.js, ' 
> +
>             'or setting CLOSURE_NO_DEPS to true.');
>         controller.loaded();
>       } else {
>         controller.pause();
>       }
>       return;
>     }
>
> goog.inHtmlDocument_ tests for document.write.
>
>> On Jul 11, 2021, at 1:00 PM, Edward Stangler <estang...@bradmark.com> wrote:
>>
>>
>> How about this?  ENABLE_CHROME_APP_SAFE_SCRIPT_LOADING
>>
>>
>> https://github.com/google/closure-library/issues/844#issuecomment-331235307
>>
>> Looks like it's used in UIModuleUtils.as for its purpose, too.
>>
>>
>>
>> On 7/11/2021 4:08 AM, Harbs wrote:
>>> We’ve been working on migrating a Royale project to Adobe’s UXP environment.
>>>
>>> Release build works, but debug build does not because of some of the inner 
>>> workings in the goog library.
>>>
>>> AIUI, the main blocker is:
>>>
>>>  goog.inHtmlDocument_ = function() {
>>>    /** @type {!Document} */
>>>    var doc = goog.global.document;
>>>    return doc != null && 'write' in doc;  // XULDocument misses write.
>>>  };
>>>
>>>
>>> UXP does not have document.write so goog.addDependency, goog.require and 
>>> goog.base do not work correctly.
>>>
>>> I’ve also noticed that recently browsers seem to be taking much longer to 
>>> load scripts in debug mode. I suspect that’s because document.write is 
>>> deprecated.
>>>
>>> Because of this, I’d really like to explore removing the reliance on 
>>> document.write and instead write script tags to load the scripts (in the 
>>> correct order).
>>>
>>> We’re going to need to figure out what to do with goog.provide and 
>>> goog.require which is written into classes.
>>>
>>> How necessary is that? Can we just use ES6 instead? Should we rewrite some 
>>> of the goog functions to do more precisely what we need?
>>>
>>> Thoughts?
>>>
>>> Harbs
>>
>

Reply via email to