weixin_39528559
weixin_39528559
2020-12-30 08:02

Test Closure Compiler

Google Closure Compiler support 99% of the ES6 grammar, will be great to compare the results against the other transpilers.

该提问来源于开源项目:kpdecker/six-speed

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

12条回答

  • weixin_39869432 weixin_39869432 4月前

    Google Closure Compiler support 99% of the ES6

    compat-table does not agree with you ;)

    点赞 评论 复制链接分享
  • weixin_39528559 weixin_39528559 4月前

    interesting, cc'ing google folks.

    Obviously the 35% score on compat-table is about ES6 features, not only about ES6 grammar, while six-speed is mostly about new grammar.

    /cc ,

    点赞 评论 复制链接分享
  • weixin_39742958 weixin_39742958 4月前

    not sure what you mean by features vs. grammar but compat table includes syntax as well; unless we tested google closure incorrectly (not enabling new syntax or some such)

    点赞 评论 复制链接分享
  • weixin_39528559 weixin_39528559 4月前

    by default, closure compiler will transpiler all new grammar (syntax) down to ES3, you could tweak that to target ES5 instead for the case of six-speed and compat-table.

    I suspect compat-table is testing closure compiler with the default options, without using externs, which are equivalent to babel-polyfill, that's why you see all the built-ins and built-ins extensions not supported.

    I'm not a expert in closure compiler, I will let and to chime in. I just want to make sure that we take closure compiler into consideration.

    点赞 评论 复制链接分享
  • weixin_39869432 weixin_39869432 4月前

    Only ~35% of a compat-table ES6 result is built-ins result. Anyway, Closure supports more ES6 features than TypeScript ;)

    点赞 评论 复制链接分享
  • weixin_39575850 weixin_39575850 4月前

    Here is the doc about ES6 support in the compiler: https://github.com/google/closure-compiler/wiki/ECMAScript6

    Did you have a question about whether some specific feature is supported?

    点赞 评论 复制链接分享
  • weixin_39528559 weixin_39528559 4月前

    I think that documentation is incomplete, it only talks about grammar, but not all other features in ES6, let's say WeakMap or Promise, etc. Babel includes a section about the polyfill to support a full ES6 Environment (e.g.: https://babeljs.io/docs/usage/polyfill/), and even though closure compiler has a similar thing via externs, it is hard for people to make sense of it, that's probably why 's compat-table didn't take that into consideration.

    As for six-speed, it will be great is you guys can validate that closure can handle all the tests required to be added to the result table, that might help to add closure here, maybe a pull request?

    点赞 评论 复制链接分享
  • weixin_39575850 weixin_39575850 4月前

    To rewrite the polyfills, you need to set this compiler option: https://github.com/google/closure-compiler/blob/master/src/com/google/javascript/jscomp/CompilerOptions.java#L792 I think there isn't a flag for it at the moment, but we'll turn it on by default soon, maybe in the next release? CC

    点赞 评论 复制链接分享
  • weixin_39603505 weixin_39603505 4月前

    I don't have concrete plans to turn it on by default externally. We can't do that unless we add a flag to turn it off, at any rate.

    点赞 评论 复制链接分享
  • weixin_39528559 weixin_39528559 4月前

    whether that's turn on by default or not, it is debatable, babel doesn't do that automatically (IIRC), but having a very simple and intuitive way to do so is what really matters.

    点赞 评论 复制链接分享
  • weixin_39869432 weixin_39869432 4月前

    most babel features just will not work without it. BTW https://github.com/kangax/compat-table/pull/741#issuecomment-179923364

    点赞 评论 复制链接分享
  • weixin_39727005 weixin_39727005 4月前

    Glad to include this in the tests as long as they are automated and can run under OSX. I don't have time to wire this up, but glad to pull in a PR and include in my weekly test exec. Might be as simple as adding another permutation here, but this should be tested out.

    点赞 评论 复制链接分享

相关推荐