我可以像这样导入闭包编译器:
const ClosureCompiler = require('google-closure-compiler').compiler;但这使用了java版本。我对工作中的构建机器有一个限制,以至于我不能使用java。我希望强制编译使用本机版本。我试过这样做:
const ClosureCompiler = require('google-closure-compiler-osx').compiler;这似乎会导致ClosureCompiler未定义。我已经到处找过任何暴露在javascript中的API文档,但是我始终什么也没想出来。
如果有人知道如何强制进行本机编译,而不是java编译,我们将不胜感激。
发布于 2022-05-02 23:31:29
我认为我已经在这方面取得了一些进展,我查看了node_ made /google-接近编译器中的cli.js和util.js文件中正在发生的事情。
这一模式似乎正在发挥作用:
const ClosureCompiler = require('google-closure-compiler').compiler,
compilerInstance = new ClosureCompiler({... setup opts ...});
// Force native compilation
let compilerPlatform = 'linux';
switch (process.platform) {
case 'win32': compilerPlatform = 'windows'; break;
case 'darwin': compilerPlatform = 'osx'; break;
}
compilerInstance.JAR_PATH = null;
compilerInstance.javaPath = require('google-closure-compiler-' + compilerPlatform);
compilerInstance.run((exitCode, stdOut, stdErr) => {
... do some stuff ...
});https://stackoverflow.com/questions/72093150
复制相似问题