Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

support goog.require syntax. #116

Merged
merged 1 commit into from
Oct 16, 2015
Merged

support goog.require syntax. #116

merged 1 commit into from
Oct 16, 2015

Conversation

rkirov
Copy link
Contributor

@rkirov rkirov commented Oct 15, 2015

Closes #113

@rkirov
Copy link
Contributor Author

rkirov commented Oct 15, 2015

Can you take a look before I go an update all the goldens.

_emitGoogRequireSupport(namespace, isDefault ? symbol.getName() : namespace);
}

private void _emitGoogRequireSupport(String namespace, String closureNamespace) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No _ in method names in Java.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

@mprobst
Copy link
Contributor

mprobst commented Oct 15, 2015

Approach looks good generally.

@rkirov rkirov force-pushed the goog_require branch 2 times, most recently from b73665c to acdd5f5 Compare October 15, 2015 22:14
@@ -0,0 +1,4 @@
/** @provideGoog */
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem to work.

When debugging compilerInput.getProvides() returns 0 provides for this file. If I understand @provideGoog properly, it should be providing goog.provide as there is not other method to provide that during bootstrapping.

@MatrixFrog, anything obviously wrong with this approach. I am trying to replicate base.js so that the Closure compiler is aware of goog.require as a provided function symbol.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't actually see any special handling for the provideGoog annotation in the compiler. As far as I can tell that annotation is understood by some other (Google-internal) tools but not by the compiler itself.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank Tyler! After some poking around (basically taking a real base.js and bisecting) turns out the special part that makes goog.require persist as a provided symbol is var COMPILED = false;.

@mprobst PTAL, before I update the goldens?

if (namespace.equals("goog")) return;
emitNamespaceBegin("goog");
String qualifiedClosureNamespace = INTERNAL_NAMESPACE + "." + closureNamespace;
emit("function require(name: '" + closureNamespace + "'): typeof " + qualifiedClosureNamespace + ";");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might want to add a comment here pointing out the TypeScript overloading based on string arguments, otherwise this is a bit mistifying.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

@mprobst
Copy link
Contributor

mprobst commented Oct 16, 2015

LGTM, except a bit the "cannot use as type" concern, but that's unrelated to the code here.

@rkirov rkirov merged commit 770f49e into master Oct 16, 2015
@mprobst mprobst deleted the goog_require branch April 21, 2016 16:59
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants