expose goog.provide vs goog.module in jstrimmer summary
This information is needed by Clutz.  Providing it here will allow
Clutz to remove its dependency on depgraphs.
@@ -57,11 +57,19 @@ import javax.annotation.Nullable;
public class JsFileFullParser {
/** The dependency information contained in a .js source file. */
public static final class FileInfo {
+ /** The module system declared by the file, e.g. goog.provide/goog.module. */
+ public enum ModuleType {
+ UNKNOWN,
+ GOOG_PROVIDE,
+ GOOG_MODULE,
+ }
+
public boolean goog = false;
public boolean isConfig = false;
public boolean isExterns = false;
public boolean provideGoog = false;
public boolean testonly = false;
+ public ModuleType moduleType = ModuleType.UNKNOWN;
public final Set<String> hasSoyDelcalls = new TreeSet<>();
public final Set<String> hasSoyDeltemplates = new TreeSet<>();
@@ -192,6 +200,21 @@ public class JsFileFullParser {
} else if (module.isGoogModule()) {
info.loadFlags.put("module", "goog");
}
+ switch (module.moduleType()) {
+ case GOOG_PROVIDE:
+ info.moduleType = FileInfo.ModuleType.GOOG_PROVIDE;
+ break;
+ case GOOG_MODULE:
+ case LEGACY_GOOG_MODULE:
+ info.moduleType = FileInfo.ModuleType.GOOG_MODULE;
+ break;
+ case ES6_MODULE:
+ case COMMON_JS:
+ case SCRIPT:
+ // Treat these as unknown for now; we can extend the enum if we care about these.
+ info.moduleType = FileInfo.ModuleType.UNKNOWN;
+ break;
+ }
info.goog = module.usesClosure();
// If something doesn't have an external dependency on Closure, then it does not have any
// externally required files or symbols to provide. This is needed for bundles that contain
