[英]How to use closurebuilder.py to compile my library with Google Closure Compiler
Can't seem to find current information or a working solution to my problem. 似乎找不到当前的信息或无法解决我的问题的解决方案。 I'm trying to compile all the scripts in my /src directory as a standalone JavaScript library (as opposed to a Closure application). 我正在尝试将/ src目录中的所有脚本编译为独立的JavaScript库(与Closure应用程序相对)。 Although I am setting the flag --output_mode=compiled
, the output of the compilation still has 尽管我设置了--output_mode=compiled
标志,但是--output_mode=compiled
的输出仍然具有
var COMPILED=!0
Here's how I'm compiling: 这是我的编译方式:
1 - Concat all my .js files into a single file in ./tmp/concat.js 2 - Run concat.js through the compiler with the following command 1-将我的所有.js文件Concat合并到./tmp/concat.js中的单个文件中2-使用以下命令通过编译器运行concat.js
./lib/closure/bin/build/closurebuilder.py \
--root=/usr/local/google-closure/closure-library/ \
--root=./tmp \
--namespace=BB.go \
--output_mode=compiled \
--compiler_jar=/usr/local/google-closure/compiler.jar \
--compiler_flags="--compilation_level=SIMPLE_OPTIMIZATIONS" \
--compiler_flags="--create_source_map=bb.js.map" \
--compiler_flags="--warning_level=VERBOSE" \
--compiler_flags="--language_in=ECMASCRIPT5" \
> bb.min.js
The output is bb.min.js
which has the problem described above. 输出是bb.min.js
,它具有上述问题。
If I compile it in ADVANCED_OPTIMIZATIONS
mode, then I get the expected output (minus all the public interfaces being renamed, which I don't want, and I don't want to export all of them, either). 如果我以ADVANCED_OPTIMIZATIONS
模式进行编译,则将获得预期的输出(减去所有已重命名的公共接口,这是我不想要的,也不想导出所有它们)。 What I want to do is compile in SIMPLE_OPTIMIZATIONS
mode and white-space only (so I can offer the library as a un-minified/un-obfuscated as well). 我想做的是仅在SIMPLE_OPTIMIZATIONS
模式下进行编译,并且只能使用空格(因此,我也可以将库提供为未缩小/未混淆的)。
I'm pretty sure --output_mode=compiled
should be --output_mode="compiled"
我很确定--output_mode=compiled
应该是--output_mode="compiled"
Here's what mine looks like that works: 这是我的样子:
python Z:\scripts\closure\closure\bin\calcdeps.py^
--path=Z:\scripts\closure\^
--output_mode="compiled"^
--compiler_jar=Z:\scripts\closure\other\compiler.jar^
--compiler_flag=--compilation_level=ADVANCED_OPTIMIZATIONS^
--compiler_flag=--use_types_for_optimization^
--compiler_flag=--warning_level=VERBOSE^
--input=Z:\scripts\closure\other\soyutils_usegoog.js^
--input=Z:\scripts\closure\closure\goog\deps.js^
--input=utils.js^
--input=main.js^
--input=templates.soy.js^
--output_file=main.min.js
Note that you would need to modify this to match your paths/files and that mine is meant for a windows environment, so replace the ^
with \\
and the backslashes with forward slashes for paths. 请注意,您需要对其进行修改以匹配您的路径/文件,并且该类适用于Windows环境,因此请将^
替换为\\
,并将反斜杠替换为路径的正斜杠。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.