google/closure-compiler-npm

--platform flag is undocumented, and possibly regressed?

juj opened this issue · 4 comments

juj commented

In Emscripten use of Closure compiler, we have somehow evolved the following CLI invocation:

emscripten-win\node_modules\.bin\google-closure-compiler --platform native,javascript --version

which does not work, but prints an empty string. Also

emscripten-win\node_modules\.bin\google-closure-compiler --platform asdf --version

just exits without printing anything.

I can't figure out where we evolved this use from, the intent being that --platform native,javascript would pick the first one that is supported. That has apparently worked in the past, but for some reason is not working in the latest Closure. In google-closure-compiler/cli.js there is this code:

let platform;
if (compilerFlags.hasOwnProperty('platform')) {
  platform = compilerFlags.platform;
  delete compilerFlags.platform;
} else {
  platform = getFirstSupportedPlatform(['native', 'java']);
}

i.e. presumably --platform native,javascript would be intended to result in platform = getFirstSupportedPlatform(['native', 'javascript']);, but that is not happening.

Looking at https://github.com/google/closure-compiler/wiki/Flags-and-Options the flag --platform is not documented at all, so not sure what the expected behavior should be.

  1. can you document --platform in https://github.com/google/closure-compiler/wiki/Flags-and-Options?
  2. can you add support for --platform native,javascript in this option, if that was not a real thing before?
  3. can you check that --platform asdf properly fails?
juj commented

Thanks for the quick work! Btw https://github.com/google/closure-compiler/wiki/Flags-and-Options still does not mention --platform, should this bug be kept open until then, or?

--platform isn't a JSCompiler flag, only to particular scripts in the closure-compiler-npm repo. It wouldn't be accurate to document it for the compiler.

juj commented

That is a good explanation, though is there a separate documentation page for the CLI tool cmdline options? Since https://github.com/google/closure-compiler/wiki/Flags-and-Options flags work for the CLI tool as well, maybe the Flags and Options page should either link to that, or just document the --platform flag there under a separate subheading to explain the difference?

Not sure if many people are able to make a distinction between the two, and that should not lead to lack of documentation?

juj commented

Looks like the documentation is here? https://www.npmjs.com/package/google-closure-compiler That does not document the list aspect though?