如果你正在使用模块模式,并且有这样的代码:
(function () {
"use strict";
// this function is strict...
}());
如果使用Google Closure Compiler编译代码,"use strict";
指令将不会出现在编译后的文件中。
那么如何防止Closure Compiler删除ES5/strict指令呢?
(请注意,我不想使用另一种强制启用ES5/strict模式的方法,即在编译后的文件的第一行简单地添加 "use strict";。我想要使用模块模式,如这里所述。)
'use strict';
。不错! - Kyle Falconer--language_out=ECMASCRIPT5_STRICT
,最终的代码压缩中就会包含'use strict';
。 - IvanRF