HoriSun / closure-compiler

Automatically exported from code.google.com/p/closure-compiler
0 stars 0 forks source link

[Enhancement] ZIP'd Externs (--externs) #1306

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Something I find a bit frustrating when using Closure (JAR) is the "--externs" 
parameter, specifically each externs file has to be specified individually.

Would it be possible to tweak Closure so it accepts a ZIP of externs files?

  --externs my_externs.zip

The ZIP structure would simply consist of one or more externs files.

  my_externs.zip/apple.js
  my_externs.zip/banana.js
  my_externs.zip/cherry.js
  my_externs.zip/doughnut.js

I can think of numerous benefits; better organization, easier distribution, and 
less command-line clutter being the main ones.

Original issue reported on code.google.com by RetroModular on 15 Apr 2014 at 10:40

GoogleCodeExporter commented 9 years ago
Not a bad idea, but I doubt it would be a high priority for us, to be honest. 
As a workaround, you could write a small script that unzips the zip into a temp 
dir, and then loops through all the files building up the command-line and 
calls the compiler.

Original comment by tbreisac...@google.com on 15 Apr 2014 at 4:52

GoogleCodeExporter commented 9 years ago
Seems like a two line shell script should fix this problem.

I am against this idea. It'll be harder to make incremental compile time 
improvement if inputs are bundled in a zip file. I am be wrong but zip file's 
last write time is an optional field.

Also, less extern implies better size optimizations. We should encourage 
projects to pick externs carefully.

Original comment by acle...@gmail.com on 17 Apr 2014 at 10:43

GoogleCodeExporter commented 9 years ago
It's also worth pointing out that order of externs matters, which is hard to 
reason about when they're inside a ZIP file.

what sort of a build system are you using? It seems like in most build systems, 
passing around ZIPs would make life harder.

It's unclear what value native compiler support would add over a shell script 
that accepts whatever idiosyncratic format you like.

Original comment by Nicholas.J.Santos on 19 Apr 2014 at 4:09

GoogleCodeExporter commented 9 years ago
@Nicholas (#3)

The order of the extern files in a ZIP could be specified with an optional 
properties file if needed; this is actually something Closure could use itself 
(for the default externs) to avoid the messy file order check that's baked into 
the Java code.

  externs.zip {
    apple.js
    banana.js
    cherry.js
    doughnut.js
    zip.properties
  }

  zip.properties {
    order = doughnut.js cherry.js banana.js apple.js
  }

Passing a ZIP of extern files to Closure would be an optional feature that some 
developers would find useful, myself included, and it would take less than hour 
to actually implement the functionality in Closure. I could branch the repo and 
add this functionality myself easily enough if the conditions were suitable.

Yes, a build system could be modified to deal with this but it would make more 
sense if Closure supported this functionality.

Original comment by RetroModular on 19 Apr 2014 at 5:57

GoogleCodeExporter commented 9 years ago
Issue tracking has been migrated to github. Please make any further comments on 
this issue through https://github.com/google/closure-compiler/issues

Original comment by blic...@google.com on 1 May 2014 at 6:31

GoogleCodeExporter commented 9 years ago

Original comment by blic...@google.com on 1 May 2014 at 6:34