简体   繁体   English

是否可以为闭包编译器添加@language ECMASCRIPT5来注释JavaScript?

[英]Is it possible to annotate JavaScript for the Closure Compiler adding @language ECMASCRIPT5?

I need to minificate some code using Google Compiler compiler.jar as part of a build process. 在构建过程中,我需要使用Google Compiler Compiler.jar简化一些代码。

I have notice that by default the compiler is set to ES3 when I need instead setting the language to ES5. 我注意到默认情况下,当我需要将语言设置为ES5时,编译器设置为ES3。

At the moment I am trying to annotate my source code in order to fore ES5 using the following scripts. 目前,我正在尝试注释我的源代码,以便使用以下脚本发布ES5。

Unfortunately @language is being ignored. 不幸的是@language被忽略。

My question: 我的问题:

  • Is it possible to enforce @language ECMASCRIPT5 in code annotation directily in JS source code? 是否可以在JS源代码中直接在代码注释中强制使用@language ECMASCRIPT5 ECMASCRIPT5?

// ==ClosureCompiler==
    // @compilation_level SIMPLE_OPTIMIZATIONS
    // @language ECMASCRIPT5
    // ==/ClosureCompiler==


    define([
        'dojo/_base/declare',
        'dojo/topic'
    ], function (declare, topic) {
        'use strict';
        return declare('Message', null, {

            _test: 'default',
            get test() {
                return this._test;
            },
            set test(value) {
                this._test = value;
            },


            constructor: function (options) {

            }
        });
    });

No language is not determined by annotations - but by compiler options (flags). 语言不是由注释决定的,而是由编译器选项(标志)决定的。

java -jar compiler.jar -O=SIMPLE --language_in=ECMASCRIPT5

I realize that the web service uses special annotations - but they are part of the special comment block at the top of the file. 我意识到Web服务使用特殊注释-但是它们是文件顶部特殊注释块的一部分。 This is a special case and not used elsewhere. 这是特例,在其他地方未使用。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 JavaScript:ECMAScript5中的继承 - JavaScript: Inheritance in ECMAScript5 在EcmaScript5中实现WeakMap? - WeakMap implementation in EcmaScript5? 如何使用闭包编译器在javascript中注释扩展泛型类的类 - How to annotate in javascript a class that extends a generic type, using closure compiler 是否可以使用Ecmascript5脚本中的Ecmascript6脚本而不进行转译? - Is it possible to use an Ecmascript6 script out of an Ecmascript5 script without transpiling? Javascript:各种浏览器中是否有与caniuse.com相同的HTML5 API / ECMAScript5 / ECMAScript6? - Javascript: Is there an equivalent to caniuse.com for HTML5 APIs/ECMAScript5/ECMAScript6 in the various browsers? 当 --language_out 设置为 ECMASCRIPT_2015 时,Google Closure Compiler 在结果文件中添加了“use strict” - Google Closure Compiler addes “use strict” to result file when --language_out is set to ECMASCRIPT_2015 如何在javascript中扩展抽象类并为闭包编译器添加注释,但没有闭包库? - How do you extend an abstract class in javascript and annotate for closure compiler but without closure library? 是否包含使用Google Closure编译器的Ecmascript 6类? - Include an Ecmascript 6 class using Google Closure Compiler? JavaScript(ECMAScript5)严格模式是否具有显着的性能优势,值得广泛使用? - Does JavaScript (ECMAScript5) Strict Mode offer significant performance advantages to merit widespread use? ECMAScript5新功能的填充或解决方法? - Polyfill or workarounds for ECMAScript5 new features?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM