Google Closure Compiler: Difference between revisions

From Chorke Wiki
Jump to navigation Jump to search
No edit summary
 
(14 intermediate revisions by the same user not shown)
Line 4: Line 4:


sudo mkdir -p  /opt/cli/closure-compiler-20200719
sudo mkdir -p  /opt/cli/closure-compiler-20200719
sudo unzip     /opt/cli/compiler-20200719.zip -d /opt/cli/closure-compiler-20200719
sudo unzip -q  /opt/cli/compiler-20200719.zip -d /opt/cli/closure-compiler-20200719
sudo rm -rf    /opt/cli/compiler-20200719.zip
sudo rm -rf    /opt/cli/compiler-20200719.zip


Line 25: Line 25:
export CLOSURE_COMPILER_HOME='/opt/cli/closure-compiler-20200719'
export CLOSURE_COMPILER_HOME='/opt/cli/closure-compiler-20200719'
export CLOSURE_COMPILER_EXEC="java -jar ${CLOSURE_COMPILER_HOME}/closure-compiler-v20200719.jar"
export CLOSURE_COMPILER_EXEC="java -jar ${CLOSURE_COMPILER_HOME}/closure-compiler-v20200719.jar"
if  [[ "${@}/arg/is/empty" != '/arg/is/empty' ]];then export CLOSURE_COMPILER_EXEC="${CLOSURE_COMPILER_EXEC} ${@}";fi


if  [ -f "${JAVA_HOME}/bin/java" ];then ${JAVA_HOME}/bin/${CLOSURE_COMPILER_EXEC}
if  [ -f "${JAVA_HOME}/bin/java" ];then ${JAVA_HOME}/bin/${CLOSURE_COMPILER_EXEC}
elif [ -x "$(command -v java)" ];then ${CLOSURE_COMPILER_EXEC}
elif [ -x "$(command -v java)" ];then ${CLOSURE_COMPILER_EXEC}
else printf '\njava 3 \033[0;31mnot found! \033[0m:(\n';fi
else printf '\njava \033[0;31mnot found! \033[0m:(\n';fi
EOF
EOF
</source>
</source>
Line 36: Line 38:
  /opt/cli/closure-compiler-20200719/bin/closure-compiler 1983
  /opt/cli/closure-compiler-20200719/bin/closure-compiler 1983
</source>
</source>
==Web Install==
<source lang="bash">
sudo apt -qq update;\
bash <(curl -s 'https://cdn.chorke.org/exec/cli/bash/install/closure-compiler/20200719.sh.txt')
</source>
==Examples==
{|
|valign='top'|
<source lang="bash">
closure-compiler
:'
The compiler is waiting for input via stdin.
function greeting(name){return 'Hi '+name+', Eid Mubarak';};
function greeting(a){return"Hi "+a+", Eid Mubarak"};
'
</source>
|valign='top'|
<source lang="bash">
closure-compiler
:'
The compiler is waiting for input via stdin.
var greeting=(name)=>'Hi '+name+', Eid Mubarak';
var greeting=function(a){return"Hi "+a+", Eid Mubarak"};
'
</source>
|-
| colspan="2" |
----
|-
| valign="top" |
<source lang="bash">
closure-compiler --language_out STABLE|ECMASCRIPT3|ECMASCRIPT5
:'
The compiler is waiting for input via stdin.
var greeting=(name)=>'Hi '+name+', Eid Mubarak';
var greeting=function(a){return"Hi "+a+", Eid Mubarak"};
'
</source>
| valign="top" |
<source lang="bash">
closure-compiler --language_out ECMASCRIPT5_STRICT
:'
The compiler is waiting for input via stdin.
var greeting=(name)=>'Hi '+name+', Eid Mubarak';
'use strict';var greeting=function(a){return"Hi "+a+", Eid Mubarak"};
'
</source>
|-
| colspan="2" |
----
|-
| valign="top" colspan="2"|
<source lang="bash">
closure-compiler --language_out ECMASCRIPT_2015|ECMASCRIPT_2016|ECMASCRIPT_2017|ECMASCRIPT_2018|ECMASCRIPT_2019
:'
The compiler is waiting for input via stdin.
var greeting=(name)=>'Hi '+name+', Eid Mubarak';
'use strict';var greeting=a=>"Hi "+a+", Eid Mubarak";
'
</source>
|-
| colspan="2" |
----
|-
| valign="top" colspan="2"|
<source lang="bash">
closure-compiler --js ./handlebars.js --js_output_file ./handlebars.min.js --language_out ECMASCRIPT_2015
closure-compiler --js ./mustache.js --js_output_file ./mustache.min.js --language_out ECMASCRIPT_2015
closure-compiler --js ./moment.js --js_output_file ./moment.min.js --language_out ECMASCRIPT_2015
closure-compiler --js ./ajv7.js --js_output_file ./ajv7.min.js --language_out ECMASCRIPT_2015
</source>
|}


==Knowledge==
==Knowledge==
Line 47: Line 129:
{|
{|
| valign="top" |
| valign="top" |
* [https://gist.github.com/3rikschmidt/52187a37e87d830046f8 Google Closure Compiler » Ant Targets]
* [https://github.com/google/closure-compiler/wiki/Supported-features Closure Compiler » Supported Feature]
* [https://github.com/google/closure-compiler/wiki/Binary-Downloads Google Closure Compiler » Download]
* [https://mvnrepository.com/artifact/com.google.javascript/closure-compiler Closure Compiler » Maven Repository]
* [https://github.com/google/closure-compiler/wiki/Releases Google Closure Compiler » Releases]
* [https://gist.github.com/3rikschmidt/52187a37e87d830046f8 Closure Compiler » Ant Targets]
* [https://closure-compiler.appspot.com/home Google Closure Compiler » Online]
* [https://github.com/google/closure-compiler/wiki/Binary-Downloads Closure Compiler » Download]
* [https://github.com/google/closure-compiler/wiki/ECMAScript6 Google Closure Compiler » ES6]
* [https://github.com/google/closure-compiler/wiki/Releases Closure Compiler » Releases]
* [https://chromium.googlesource.com/chromium/blink/+/master/Source/devtools/scripts/closure/README.md Google Closure Compiler]
* [https://closure-compiler.appspot.com/home Closure Compiler » Online]
* [[Maven]]
* [https://github.com/google/closure-compiler/wiki/ECMAScript6 Closure Compiler » ES6]
* [[ExtJS]]
* [https://chromium.googlesource.com/chromium/blink/+/master/Source/devtools/scripts/closure/README.md Closure Compiler]
* [[Ant]]
* [[Ant]]
* [[Ivy]]
* [[Ivy]]


| valign="top" |
| valign="top" |
* [https://github.com/jgraph/drawio/blob/dev/etc/build/build.xml Google Closure Compiler » Example by DrawIO]
* [https://github.com/google/closure-compiler/wiki/Managing-Dependencies Closure Compiler » Managing Dependencies]
* [https://github.com/jgraph/drawio/blob/dev/etc/build/build.xml Google Closure Compiler » Ant Task Example]
* [https://github.com/google/closure-compiler/wiki/Annotating-JavaScript-for-the-Closure-Compiler Closure Compiler » Annotating JavaScript]
* [https://mvnrepository.com/artifact/com.google.javascript/closure-compiler Google Closure Compiler » Maven Repository]
* [https://github.com/jgraph/drawio/blob/dev/etc/build/build.xml Closure Compiler » Example by DrawIO]
* [https://developers.google.com/closure/compiler/docs/gettingstarted_app Google Closure Compiler » Getting Started]
* [https://github.com/jgraph/drawio/blob/dev/etc/build/build.xml Closure Compiler » Ant Task Example]
* [https://chromium.googlesource.com/chromium/blink/+/master/Source/devtools/scripts/closure/README.md Google Closure Compiler » Readme]
* [https://mvnrepository.com/artifact/com.google.javascript/closure-compiler Closure Compiler » Maven Repository]
* [https://stackoverflow.com/questions/939326/ Execute JavaScript without Eval]
* [https://developers.google.com/closure/compiler/docs/gettingstarted_app Closure Compiler » Getting Started]
* [https://github.com/wro4j/wro4j-examples WRO4J Example]
* [https://chromium.googlesource.com/chromium/blink/+/master/Source/devtools/scripts/closure/README.md Closure Compiler » Readme]
* [[Rhino]]
* [[Rhino]]
* [[Bazel]]
* [[Bazel]]
Line 75: Line 157:
* [[JavaScript Proprietary Library Example]]
* [[JavaScript Proprietary Library Example]]
* [[JavaScript Ali Express Discounted Cart]]
* [[JavaScript Ali Express Discounted Cart]]
* [https://stackoverflow.com/questions/939326/ Execute JavaScript without Eval]
* [[JSON Schema Validation]]
* [[JSON Schema Validation]]
* [https://github.com/jgraph/drawio-desktop DrawIO Desktop]
* [https://github.com/jgraph/drawio-desktop DrawIO Desktop]
* [https://github.com/wro4j/wro4j-examples WRO4J Example]
* [[Maven]]
* [[ExtJS]]


|-
|-
Line 83: Line 169:
|-
|-
| valign="top" |
| valign="top" |
* [https://github.com/google/closure-compiler/wiki/Flags-and-Options Closure Compiler » Flags and Options]
* [[Yarn]]
* [[NPM]]


| valign="top" |
| valign="top" |

Latest revision as of 21:17, 11 November 2022

sudo wget -c https://dl.google.com\
/closure-compiler/compiler-20200719.zip       -P /opt/cli/

sudo mkdir -p  /opt/cli/closure-compiler-20200719
sudo unzip -q  /opt/cli/compiler-20200719.zip -d /opt/cli/closure-compiler-20200719
sudo rm -rf    /opt/cli/compiler-20200719.zip

sudo chmod 644 /opt/cli/closure-compiler-20200719/closure-compiler-v20200719.jar
sudo mkdir -p /opt/cli/closure-compiler-20200719/bin
sudo touch    /opt/cli/closure-compiler-20200719/bin/closure-compiler
sudo chmod +x /opt/cli/closure-compiler-20200719/bin/closure-compiler
sudo tee   -a /opt/cli/closure-compiler-20200719/bin/closure-compiler >/dev/null <<'EOF'
#!/bin/bash
: '
 @vendor    Chorke Academia, Inc.
 @web       https://cdn.chorke.org/docs/academia
 @version   1.0.00
 @since     1.0.00
'

export CLOSURE_COMPILER_HOME='/opt/cli/closure-compiler-20200719'
export CLOSURE_COMPILER_EXEC="java -jar ${CLOSURE_COMPILER_HOME}/closure-compiler-v20200719.jar"

if   [[ "${@}/arg/is/empty" != '/arg/is/empty' ]];then export CLOSURE_COMPILER_EXEC="${CLOSURE_COMPILER_EXEC} ${@}";fi

if   [ -f "${JAVA_HOME}/bin/java" ];then ${JAVA_HOME}/bin/${CLOSURE_COMPILER_EXEC}
elif [ -x "$(command -v java)" ];then ${CLOSURE_COMPILER_EXEC}
else printf '\njava \033[0;31mnot found! \033[0m:(\n';fi
EOF
sudo update-alternatives --install /usr/bin/closure-compiler closure-compiler\
 /opt/cli/closure-compiler-20200719/bin/closure-compiler 1983

Web Install

sudo apt -qq update;\
bash <(curl -s 'https://cdn.chorke.org/exec/cli/bash/install/closure-compiler/20200719.sh.txt')

Examples

closure-compiler
:'
The compiler is waiting for input via stdin.
function greeting(name){return 'Hi '+name+', Eid Mubarak';}; 
function greeting(a){return"Hi "+a+", Eid Mubarak"};
'
closure-compiler
:'
The compiler is waiting for input via stdin.
var greeting=(name)=>'Hi '+name+', Eid Mubarak'; 
var greeting=function(a){return"Hi "+a+", Eid Mubarak"};
'

closure-compiler --language_out STABLE|ECMASCRIPT3|ECMASCRIPT5
:'
The compiler is waiting for input via stdin.
var greeting=(name)=>'Hi '+name+', Eid Mubarak';
var greeting=function(a){return"Hi "+a+", Eid Mubarak"};
'
closure-compiler --language_out ECMASCRIPT5_STRICT
:'
The compiler is waiting for input via stdin.
var greeting=(name)=>'Hi '+name+', Eid Mubarak';
'use strict';var greeting=function(a){return"Hi "+a+", Eid Mubarak"};
'

closure-compiler --language_out ECMASCRIPT_2015|ECMASCRIPT_2016|ECMASCRIPT_2017|ECMASCRIPT_2018|ECMASCRIPT_2019
:'
The compiler is waiting for input via stdin.
var greeting=(name)=>'Hi '+name+', Eid Mubarak';
'use strict';var greeting=a=>"Hi "+a+", Eid Mubarak";
'

closure-compiler --js ./handlebars.js --js_output_file ./handlebars.min.js --language_out ECMASCRIPT_2015
closure-compiler --js ./mustache.js --js_output_file ./mustache.min.js --language_out ECMASCRIPT_2015
closure-compiler --js ./moment.js --js_output_file ./moment.min.js --language_out ECMASCRIPT_2015
closure-compiler --js ./ajv7.js --js_output_file ./ajv7.min.js --language_out ECMASCRIPT_2015

Knowledge

sudo chmod +x /opt/cli/closure-compiler-20200719/closure-compiler-v20200719.jar
stat -c '%a'  /opt/cli/closure-compiler-20200719/closure-compiler-v20200719.jar
stat          /opt/cli/closure-compiler-20200719/closure-compiler-v20200719.jar

References