google / closure-compiler-npm

Package for managing and documenting closure-compiler for use via npm

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

native-image version of compiler claims 1970 is the latest meaningful value to use for browser_featureset_year

AshleyScirra opened this issue · comments

I tried setting browser_featureset_year 2020 in the command line, e.g.:

npx google-closure-compiler --js in.js --js_output_file out.js --browser_featureset_year 2020

This logs the message:
--browser_featureset_year=1970 is the latest meaningful value to use

Clearly this is wrong - browsers didn't exist in 1970! It's probably parsing the value incorrectly.

This can be happening only if the current year obtained from LocalDataTime is 1970, which indicates that maybe your system time clock is set to that year. Can you confirm your system clock year?

Fyi, the code responsible for causing this is:

int currentYear = LocalDateTime.now(ZoneId.systemDefault()).getYear();
if (inputYear > currentYear) {
      throw new FlagUsageException(
          SimpleFormat.format(
              "--browser_featureset_year=%d is the latest meaningful value to use", currentYear));

My system clock is set correctly - at time of writing, it says 17th May 2020.

On which version of google-closure-compiler are you seeing this problem?
I haven't been able to reproduce on the latest https://www.npmjs.com/package/google-closure-compiler

npx google-closure-compiler --version prints:

Closure Compiler (http://github.com/google/closure-compiler)
Version: v20200504
Built on: 2020-05-06 19:27

My initial guess would be that it has something to do with one of the alternative platforms.

Can you try with --platform=java (the configuration that we use most at google) to see if it works in that mode?

If so, it may be an issue with graal (for the native binary version) or j2cl/gwt (for the JavaScript version).

If I run npx google-closure-compiler --js in.js --js_output_file out.js --browser_featureset_year 2020 --platform=java, there is no error about browser_featureset_year. However it doesn't produce an output file either. I don't have Java installed though, I guess I need it for that option?

I installed Java for some other testing so I gave this a spin with Java installed.

npx google-closure-compiler --js in.js --js_output_file out.js --browser_featureset_year 2020
Result: --browser_featureset_year=1970 is the latest meaningful value to use

npx google-closure-compiler --platform=java --js in.js --js_output_file out.js --browser_featureset_year 2020
Result: WARNING - [JSC_UNKNOWN_DEFINE_WARNING] unknown @define variable goog.FEATURESET_YEAR

java -jar closure-compiler.jar --js in.js --js_output_file out.js --browser_featureset_year 2020
Result: WARNING - [JSC_UNKNOWN_DEFINE_WARNING] unknown @define variable goog.FEATURESET_YEAR

Hmm... is the option just broken?

Well, that is a very different error message, which makes me think that there is some bug in one of the tools that we use to transpile the non-java versions. (I think that the default version when running without the --platform flag is a native versions compiled with graal). oracle/graal#1374 looks somewhat similar, but is already fixed.

From the --platform=java output, it looks like the JS code defining goog.FEATURESET_YEAR is missing. Are you perhaps using an old version of closure-library from before goog.FEATURESET_YEAR was added in google/closure-library@9234c1a ?

Created Google internal issue http://b/157485632

I've renamed this bug to be specific to the the original issue without the --platform=java flag.

If using a more recent version of closure-library doesn't fix the issue --platform=java issue, could you file a new issue on https://github.com/google/closure-compiler/issues/new/choose
?

FWIW, Closure Library maintainers are interested in cutting the dependencies between the library and the compiler so that each can be meaningfully used independent of the other. We should look into finding a way to make FEATURESET_YEAR usable without Closure Library.

Note also, that on my OS X machine, I wasn't able to reproduce this issue with the native-image version of the compiler.

Can you tell us which platform you are running on (windows, linux, os x, etc.)?

My previous comment was based on running Closure Compiler v20200517 on Windows 10 x64.

does --platform=js give the same error as --platform=java?

@ChadKillingsworth do you know what version of Graal we're using here?
Maybe it still has the issue oracle/graal#1374 ?

I expect this to be fixed by: #174
Chad can you confirm this?

I think it will be. At least it looks like the version of Graal is newer than when that fix was merged.

This should also have been fixed by Rishi's google/closure-compiler@041dc07, once that's released.

Is this still failing on Win10 x64?