To express this another way: I’m trying to figure out exactly what we’re using goog for and what can be dropped.
It seems to me that we’re calculating the dependencies in the compiler, so there shouldn’t be any reason why we can’t write all the scripts as simple script tags. It’s also likely that using ES6 output might solve these issues. I’m not sure how difficult it would be to switch to ES6 output —especially for library code. If we don’t go the ES6 route, it seems we’re using: In compiles js files: goog.provide goog.require goog.inherits The “base” method added to classes by base.js We’re using goog.addDependency in index.html and goog.require for the main class. It seems like writing scipt tags should remove the need for goog.addDependency and likely goog.require in the index.html file. I’m not sure what’s going to happen with the goog.requires in the compiled js files. I’m not sure of the best way to go about unravelling all of this… Harbs > On Jul 11, 2021, at 1:37 PM, Harbs <harbs.li...@gmail.com> 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 >> >> >