Closure编译器需要入口点" ..."从未提供

时间:2014-08-18 19:51:47

标签: javascript minify google-closure-compiler

我有一个js模块,取决于其他几个模块。我想避免使用browserify来构建CommonJS模块,因为它很难用于闭包编译器缩小。 我正在尝试通过闭包编译器编译模块,如下所示:

java -jar compiler.jar --js=node_modules/object-id/index.js --js=node_modules/each-csv/index.js --js=node_modules/matches-selector/index.js --js=index.js --process_common_js_modules --common_js_entry_module=index.js

我得到的一切都是错误的:

ERROR - required entry point "module$each_csv" never provided

ERROR - required entry point "module$matches_selector" never provided

ERROR - required entry point "module$object_id" never provided

3 error(s), 0 warning(s)

在闭包编译器中使用commonjs模块的正确方法是什么?

1 个答案:

答案 0 :(得分:1)

我提出的最佳解决方案是非包装CommonJS合并 - UncommonJS。 它以正确的顺序将所有可靠模块从传递的条目文件合并到单个单范围的捆绑包中,解决全局变量干扰,替换module.exportsrequire声明并删除重复项,以便结果为〜通过闭包编译器比browserify bundle更好地压缩27%。