Closure Builder - Simplified Closure Build System (Deprecated⛔️)
⛔️ Package no longer updated and supported. Use at your own risk. ⛔️
A Closure build system to easily compile Closure JavaScript files,
Closure Template files and Closure Stylesheet files without the need to
configure anything.
The Google Closure library will be included automatically if needed.
This build system could be also used for normal css, js, nodejs and
static files as well.
The following options are partially implemented and should not be used:
data
compress
type
Function Callback
For performance reasons the tasks will be executed asynchronous whenever it
is possible.
If you need to know exactly if a tasks has finished you could add a callback
function as well.
var closureBuilder = require('closure-builder');
var callbackExample = function(errors, warnings, files, results) {
...
};
closureBuilder.build({
...
}, callbackExample.bind(this));
The callback will be called with the following parameters:
errors Errors if any
warnings Warnings if any
files Single output file or list of output files if any
results Result if any
Example build configurations
These example shows the basic usage for the different file types.
You could define as many build rules you want.
Please keep in mind to add the needed require before like:
var closureBuilder = require('closure-builder');
var glob = closureBuilder.globSupport();
closureBuilder.build({
...
});
Compile Closure JavaScript files
Compiling Closure JavaScript files for the given namespace to an single
JavaScript file.
Compile Closure JavaScript files over remote service
Compiling Closure JavaScript files with the remote service to a single
javascript file.
Please keep in mind that the remote service is not supporting all features and
options of the closure compiler.
In some cases you need to init and update the submodules manually by:
git submodule init
git submodule update
Get required packages
Enter the “closure-builder” directory and get the required packages by:
npm install
Updating dependencies
Before you start working, run npm run update to update the dependencies to
the latest package versions.
Code Style
Run npm run lint to make sure that your code is according the general style.
Testing
Tests could be performed with npm run test. Before the test runs it will
automatically run the linter to make sure that the code has no syntax errors.
Deploying
Add all your files and create your commit, but instead of using “git push”
directly please use npm run deploy instead.
It will automatically run some tests and increase the versions number by 0.0.1.
Closure Builder - Simplified Closure Build System (Deprecated⛔️)
⛔️ Package no longer updated and supported. Use at your own risk. ⛔️
A Closure build system to easily compile Closure JavaScript files, Closure Template files and Closure Stylesheet files without the need to configure anything. The Google Closure library will be included automatically if needed.
This build system could be also used for normal css, js, nodejs and static files as well.
Installation
Requirements
Basic Usage
Options
Function callback
Example build configurations
Best practise
Development
Disclaimer
Author
License
Installation
Use NPM using
npm install closure-builderor fork, clone download the source on GitHub to get the latest version.Requirements
To be able to use all available features and options, please make sure to install the Java Runtime Environment (JRE).
Basic Usage
Options
All of the options will be defined inside the BUILD rule. But there is not limit of BUILD rules which could be setup for your needs.
Required
These basic required options for compiling are:
nameClosure namespace to compiler or unique name of your build rulesrcsList of (Soy, CSS, Closure or JavaScript files) which should be compiledoutOutput path / output file for the compiled Soy, Closure or JavaScript filesFor copying files the required options are:
nameUnique name of your build ruleresourcesResource files which will be copied to the output folderoutOutput path / output file for the compiled Soy, Closure or JavaScript filesAdditional
These options could be used for adding additional information.
typeOverwrites the automatic type detectionout_source_mapStores possible source map to the given output fileappendAppend the given text to the final outputprependPrepend the given text to the final outputreplaceReplace the given text on the final outputClosure compiler options
depsDependencies like additional closure files or additional file for the compilerentry_pointClosure namespace if not already defined undernameexternsAdditional JavaScript externs for the compilerlicenseAdditional license header file which will be include as header to the compiled filesremote_serviceIf true use online remote services instead of local toolsVerbose
warnIf false disable all warning messagesdebugIf true display additional debug informationstraceIf true display additional trace informationsOptions
The following options are available for the closure and soy compiler:
options.exclude_testIf true _test. files will be excludedoptions.soyAdditional settings for the Soy compileroptions.closureAdditional settings for the Closure compileroptions.closure.use_closure_libraryIf true bundled closure library will be included. If a path, the defined path will be included instead.Closure compiler warnings
To adjust the Closure compiler warnings, you could use
options.closure.jscomp_...or the shortcutjscomp_....jscomp_errorList of compiler checks which produce an error message.jscomp_warningList of compiler checks which produce an warning message.jscomp_offList of compiler checks which should be disabled.See full list of compiler checks
Not implemented yet
The following options are partially implemented and should not be used:
datacompresstypeFunction Callback
For performance reasons the tasks will be executed asynchronous whenever it is possible.
If you need to know exactly if a tasks has finished you could add a callback function as well.
The callback will be called with the following parameters:
errorsErrors if anywarningsWarnings if anyfilesSingle output file or list of output files if anyresultsResult if anyExample build configurations
These example shows the basic usage for the different file types. You could define as many build rules you want. Please keep in mind to add the needed require before like:
Compile Closure JavaScript files
Compiling Closure JavaScript files for the given namespace to an single JavaScript file.
Compile Closure JavaScript files with Soy files
Compiling Closure JavaScript files and associated Soy files to a single javascript file.
Compile Closure JavaScript files with externs
Compiling Closure JavaScript files with JavaScript externs. javascript file.
Compile Closure JavaScript files over remote service
Compiling Closure JavaScript files with the remote service to a single javascript file. Please keep in mind that the remote service is not supporting all features and options of the closure compiler.
Compile Closure Template files
Compiling Soy files into Soy JavaScript files to an targeted directory.
Compile Closure Stylesheet files
Compiling closure stylesheet files into css files to an targeted directory.
Compile JavaScript files
Combine several JavaScript files to a single JavaScript file.
Compile Node.js files
Combine node.js JavaScript files with browserify to a single JavaScript bundle.
Compile Rollup files
Combine JavaScript files with rollup to a single JavaScript bundle.
Compile CSS files
Combine and minified several CSS files to a single CSS file.
Copy resources
Copy static resources from the different location to the target directory.
Copy remote resources
Copy resources from an remote location to the target directory.
Convert Markdown (.md) to .html file
Convert markdown (.md) to .html file.
Best practise
For a better overview, you could split your build rules to several files. They could be placed in an “build” folder or something like this. Example: https://github.com/google/coding-with-chrome/tree/master/build
This allows you to rebuild only some of the files if needed.
Example package.json:
Development
There are some automated scripts which will help you for development on the closure-builder project.
Get the sources
Download the source files manual from GitHub or with git by running:
Init / update submodules
In some cases you need to init and update the submodules manually by:
Get required packages
Enter the “closure-builder” directory and get the required packages by:
Updating dependencies
Before you start working, run
npm run updateto update the dependencies to the latest package versions.Code Style
Run
npm run lintto make sure that your code is according the general style.Testing
Tests could be performed with
npm run test. Before the test runs it will automatically run the linter to make sure that the code has no syntax errors.Deploying
Add all your files and create your commit, but instead of using “git push” directly please use
npm run deployinstead. It will automatically run some tests and increase the versions number by 0.0.1.Disclaimer
This is not an official Google product.
Author
Markus Bordihn
License
Apache License, Version 2.0 - http://www.apache.org/licenses/LICENSE-2.0