-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DRAFT ServiceLoader implementation for J2CL+Closure #245
base: main
Are you sure you want to change the base?
Conversation
Note that the pass still runs too early, but we can't easily run it earlier because we're dependent on inlineFunction rewriting params to the lookup/register calls.
At this point we have a working build for plain JS. For reference, here's the final output for the current sample, correctly picking just one implementation, removing the other, and inlining the results of the constant expressions: (function(){globalThis.g=function(){};setTimeout(function(){return console.log("Hello, Java!")},100);}).call(this); Note that The next step for this PR is to establish a Java (with some shim JS, probably will be generated) pattern that still compiles out nicely. |
Adds a custom compiler pass that optimizes a particular pattern of JS code, with a simple integration test that confirms that the fully-optimized output contains only the expected implementation, and no strings remain from the unused implementation.
Before merging, the JS example should be rewritten to handmade java (plus required shim JS), to specify an expected pattern to follow. Should also consider a "service loader version" to ensure that any given implementation confirms to these expectations, should they need to evolve further.
By itself, this will not work with a multi-stage build - another custom pass could be required, or requiring the use of
goog.LOCALE
to drive the selected property.Partial #244