GithubHelp home page GithubHelp logo

knyga / kjscompiler Goto Github PK

View Code? Open in Web Editor NEW
39.0 5.0 8.0 17.88 MB

Compiles multiple JavaScript files with Google Closure Compiler application in a right order

License: MIT License

Java 66.91% JavaScript 33.09%

kjscompiler's Introduction

Kjscompiler

Makes compilation of multiple JavaScript files with Google Closure Compiler application in right order.

Goal is to convert layout at input:

from

In to minifed layout:

to

With respect to internal and external dependencies.

Requirements

Requires Java Runtime Environment version 7.

How to run

java -jar kjscompiler.jar

Kjscompiler.json

Instead of kjscompile.json you can specify your own path to configuration file with --settings %path% attribute.

basedir - directory or array of directories with JavaScript files;

output - output JavaScript file name;

pattern - rule for filename (*.js);

level - level of optimization (WHITESPACE_ONLY, SIMPLE_OPTIMIZATIONS, ADVANCED_OPTIMIZATIONS).

wrapper - setting to wrap your output. The place holder is "%output%".

Example:

{
	"basedir": "js",
	"output": "js.min/all.js",
	"level": "SIMPLE_OPTIMIZATIONS",
	"pattern": "*.js"
}

Example:

{
	"basedir": ["lib/javascript", "lib/ecmascript"],
	"output": "js.min/all.js",
	"level": "SIMPLE_OPTIMIZATIONS",
	"pattern": "*.js",
	"wrapper" : "(function(){ %output% }());"
}

Note: Any path will be relative to the settings file. If none provided it will be relative to the current working directory ( the directory where you launched kjscompiler ).

Annotating JavaScript files

Kjscompiler can use information about JavaScript file to build right compiling chain.

Tag Example Description
@depends @depends {somescript.js} Specifies dependency on other file.
@ignore @ignore File with this mark will be ignored.
@external @external File with this mark will be considered as external. It will not be compiled, but it will give no unknown variable error during the compilation.
/**
 * kjscompiler annotation
 * @depends {somescript}
 * @depends {dir/otherscript}
 */
/**
 * kjscompiler annotation
 * @ignore
 */
/**
 * kjscompiler annotation
 * @external
 */

Debug

To debug add --debug true in call line.

Licence

kjscompiler

Copyright (C) 2014 Oleksandr Knyga, [email protected]

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

kjscompiler's People

Contributors

knyga avatar helly0d avatar timvasil avatar zipper2110 avatar shikonaj avatar

Stargazers

 avatar Claudio Felber avatar oxfn avatar Tristan Rentz avatar Vasyl Yevstygnyeyev avatar  avatar  avatar KeithM avatar Daniel Reyes avatar Ian Paschal avatar Matt Vav avatar  avatar Florian avatar Enes Erdoğan avatar  avatar TheCocce avatar  avatar  avatar  avatar  avatar Johannes Harth avatar  avatar Baptiste Fontaine avatar ElHo avatar Lebid Yuriy avatar  avatar Achraf Bouyakhsass avatar  avatar  avatar Yunjia Li avatar Stas avatar  avatar Alex Bolburin avatar Aleksei Ivanov avatar  avatar  avatar  avatar  avatar @printminion avatar

Watchers

James Cloos avatar  avatar  avatar  avatar  avatar

kjscompiler's Issues

Path problems

Running on Ubuntu 12.04 and the paths are messed up. your path system uses bot the native OS system up to the point of concatenation of paths for example ir eceive the following errors:

Searching for *.js in js
Found 7 files
Primaries: 7 files
Externals: 0 files
Order Error #1: Undefined dependency: /home/helly0d/Desktop/kjscompiler-master/examples/chainDoubleInput/js/o2.js => /home/helly0d/desktop/kjscompiler-master/examples/chaindoubleinput/js\dep.js
Order Error #2: Undefined dependency: /home/helly0d/Desktop/kjscompiler-master/examples/chainDoubleInput/js/o1.js => /home/helly0d/desktop/kjscompiler-master/examples/chaindoubleinput/js\dep.js
Order Error #3: Undefined dependency: /home/helly0d/Desktop/kjscompiler-master/examples/chainDoubleInput/js/o5.js => /home/helly0d/desktop/kjscompiler-master/examples/chaindoubleinput/js\o4.js
Order Error #4: Undefined dependency: /home/helly0d/Desktop/kjscompiler-master/examples/chainDoubleInput/js/o5.js => /home/helly0d/desktop/kjscompiler-master/examples/chaindoubleinput/js\dep.js
Order Error #5: Undefined dependency: /home/helly0d/Desktop/kjscompiler-master/examples/chainDoubleInput/js/o4.js => /home/helly0d/desktop/kjscompiler-master/examples/chaindoubleinput/js\o3.js
Order Error #6: Undefined dependency: /home/helly0d/Desktop/kjscompiler-master/examples/chainDoubleInput/js/o4.js => /home/helly0d/desktop/kjscompiler-master/examples/chaindoubleinput/js\dep.js
Order Error #7: Undefined dependency: /home/helly0d/Desktop/kjscompiler-master/examples/chainDoubleInput/js/o3.js => /home/helly0d/desktop/kjscompiler-master/examples/chaindoubleinput/js\o1.js
Order Error #8: Undefined dependency: /home/helly0d/Desktop/kjscompiler-master/examples/chainDoubleInput/js/o3.js => /home/helly0d/desktop/kjscompiler-master/examples/chaindoubleinput/js\o2.js
Order Error #9: Undefined dependency: /home/helly0d/Desktop/kjscompiler-master/examples/chainDoubleInput/js/o3.js => /home/helly0d/desktop/kjscompiler-master/examples/chaindoubleinput/js\dep.js
Primaries ordered
Compiled file: js.min/all.js

errors on built-in functions

When compiling with kjscompiler, I get errors like this:

Error #3: variable Date is undeclared
Error #4: variable NaN is undeclared
Error #5: variable Error is undeclared
Error #6: variable Math is undeclared
Why is that? Do I need to add some sort of dependency?

Simple concatination

As user, I would like to have level of oftimization CONCATENATE, that will just merge scripts in to one with right order.

{
...
"level": "CONCATENATE"
...
}

old jar file - how to build?

Hi,
the jar file stored in repository is older than source.
Can you provide new version or help me with building by myself.

Thanks

Typescript

I would like to be able to compile typescript project with kjscompiler

ADVANCED_OPTIMIZATIONS doesn't work, and many others problems...

Hi,

  • the parameter "--debug true" doesn't work
  • ADVANCED_OPTIMIZATIONS doesn't work
  • I get many errors like String is undeclared, Unit8Array is undeclared, Math is undeclared, etc
  • @Depends doesn't work in some cases. I had to use @requires, which is not in your documentation

kjscompiler.json:
{
"basedir": "../webcontent/ressources/js",
"output": "../webcontent/ressources/js/all.js",
"level": "ADVANCED_OPTIMIZATIONS",
"pattern": "*.js",
"wrapper" : "(function(){ %output% }());"
}

java -jar precommit/dev_tools/kjscompiler.jar --debug true --settings "precommit/kjscompiler.json"
I use Java 8.121 x64

CSS

I would like to be able to compile css files

Ignore files and folders

I would like to be able to ignore directories and files by patterns with configuration file.

{...
ignoredirs: ["/lib/old", "/lib/wiki"],
ignore: [".man.js", ".x.js"],
...}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.