-
Notifications
You must be signed in to change notification settings - Fork 147
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
System.getProperty doesn't emit goog.require #1
Comments
I think the best way forward is to have goog.getDefine and have the tooling handle this but earlier they were hesitant on that. |
What would "goog.getDefine" be? |
It would be an official version of J2CL's nativebootstrap.Util.$getDefine; a utility that returns the value of a property defined with @define. See the current code for uncompiled mode here (minus the string coercion):
And the pass for compiled mode: We are missing an automatic edge between the class that uses getDefine and the class that defines it. |
This is unlikely to be a thing in Closure Library. Continuing to expose define values as globals is not something we want to do. global namespaces are slowly being turned down (nothing new should use goog.provide or goog.module.declareLegacyNamespace). Going forward, you should expect @define values to be module local and to access them you will need to import the module that defines them. Any solution you build around @define should keep that model in mind. |
@concavelenz @gkdn any update? |
This doesn't need an update, could stay as a known issue. |
Since there is not much we can do here I'm closing the issue. |
Observed in jsinterop-base, where jsinterop.js contains the following:
Then, InternalPreconditions.java uses this:
Currently, System.getProperty is implemented with JsMethod for J2CL (and a magic method for gwt2):
The Util.$getDefine method only calls
goog.getObjectByName
with the parameter, not a compiletime string, and closure-compiler doesn't seem to be able to detect this anyway.The result is a runtime NPE in both BUNDLE and ADVANCED compilation modes, unless jsinterop.js is manually added as an
--entry_point
, or a new define is added to the build directly (and in that case,--define
isn't used by BUNDLE, by design).Historically, it looks like J2CL used to have a pass which would examine System.getProperty calls and do something with them - perhaps the same idea could be used again to emit
goog.require
calls to correctly require that non-native.js files are loaded.This might be worth generalizing, so that non-native.js files can be depended on in general? It would add an extra step to use a system property which isn't ideal, but does prevent the need for j2cl to recognize specific pieces of code to be transpiled.
This would also allow
jre.js
to keep working if classMetadata and checkedMode were moved - while there is agoog.provide('jre.checks')
in that file, nothing actually ever depends on jre.checks, so could stop working if the file were split into one file perprovide
.The text was updated successfully, but these errors were encountered: