CasperJS テストの run.js コード (https://github.com/n1k0/casperjs/blob/master/tests/run.js) を最適化しようとしているので、それをさらに使用して最適化する方法を理解できます。私が書いたテストをさらに進めます。これは、コンパイラに ADVANCED_OPTIMIZATIONS フラグを使用して最適化しようとしていた CasperJS プロジェクトのサンプル run.js です。(https://github.com/n1k0/casperjs/blob/master/tests/run.js) ただし、最適化されたコードは次のとおりです。
phantom.d || (console.log("This script must be invoked using the casperjs executable"), phantom.c(1)); var a = require("fs"), c = require("utils").h, d = require("casper").create({g:!1}); d.options.n = d.a.get("direct") || !1; d.options.i = d.a.get("log-level") || "error"; d.m("open.location", function(b) { return!/^http/.test(b) ? c("file://%s/%s", phantom.e, b) : b }); var e = []; d.a.b.length ? e = d.a.b.filter(function(b) { return a.isFile(b) || a.isDirectory(b) }) : (d.f("No test path passed, exiting.", "RED_BAR", 80), d.c(1)); d.test.j("tests.complete", function() { this.k(true, void 0, d.a.get("xunit") || void 0) }); d.test.l.apply(d.test, e);
明らかに、これはコンパイラーによって通知されているため失敗しています (例: JSC_INEXISTENT_PROPERTY: Property casperLoaded never defined on phantom at line 2 character 5 if (!phantom.casperLoaded) )
Closure Compiler を使用して、プロジェクト内のすべての JS ファイルを依存関係で最適化し、これらのエラーを回避してさらに先に進む方法を教えてください。
Closure のドキュメントを調べましたが、この場合に必要なアプローチを理解できませんでした。
参考までに、私は Closure compiler.jar を使用していました