Skip to content

Commit

Permalink
Add option to specify application entry points to the closure compiler.
Browse files Browse the repository at this point in the history
  • Loading branch information
James Judd committed Jun 23, 2016
1 parent 9061033 commit 64b8c88
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/main/java/com/google/javascript/clutz/Options.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ public class Options {
usage = "emits platform externs, instead of omitting them in favor of TS lib.d.ts")
boolean emitPlatformExterns;

@Option(name = "--closure_entry_point",
usage = "only generate output for the given entry points to the program. Must be" +
" goog.provide'd symbols.",
metaVar = "ENTRYPOINT...",
handler = StringArrayOptionHandler.class)
List<String> entryPoints = new ArrayList<>();

@Argument
List<String> arguments = new ArrayList<>();

Expand All @@ -50,6 +57,10 @@ public CompilerOptions getCompilerOptions() {
final CompilerOptions options = new CompilerOptions();
options.setClosurePass(true);

if (!this.entryPoints.isEmpty()) {
options.setManageClosureDependencies(this.entryPoints);
}

// All diagnostics are WARNINGs (or off) and thus ignored unless debug == true.
// Only report issues (and fail for them) that are specifically causing problems for Clutz.
// The idea is to not do a general sanity check of Closure code, just make sure Clutz works.
Expand Down
11 changes: 11 additions & 0 deletions src/test/java/com/google/javascript/clutz/OptionsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,17 @@ public void testFilterSourcesDepgraphs() throws Exception {
assertThat(opts.output).isEqualTo("output.d.ts");
}

@Test
public void testClosureEntryPoint() throws Exception {
Options opts = new Options(new String[] {
"foo.js", "--closure_entry_point", "entryPoint", "--externs", "extern1.js", "extern2.js", "-o", "output.d.ts"
});
assertThat(opts.arguments).containsExactly("foo.js");
assertThat(opts.entryPoints).containsExactly("entryPoint");
assertThat(opts.externs).containsExactly("extern1.js", "extern2.js").inOrder();
assertThat(opts.output).isEqualTo("output.d.ts");
}

@Test
public void testHandleEmptyCommandLine() throws Exception {
ByteArrayOutputStream out = new ByteArrayOutputStream();
Expand Down

0 comments on commit 64b8c88

Please sign in to comment.