如果您使用的是模块模式并且有这样的东西:
(function () {
"use strict";
// this function is strict...
}());
并使用 Google Closure Compiler 编译代码,该"use strict";
指令不会将其放入编译文件中。
那么如何防止 Closure Compiler 移除 ES5/strict 指令呢?
(请注意,我不想使用强制 ES5/strict 模式的其他模式,即简单地将“use strict”添加到编译文件的第一行。我想使用这里描述的模块模式.)