Serves and builds an app with Google Closure Compiler/Library/Templates. An alternative to plovr.
Status: WIP
$ npm i -D @teppeis/duckduck <command>
Commands:
duck serve [entryConfigDir] Start dev server
duck build [entryConfigDir] Build Soy, deps.js and JS
duck build:js [entryConfigDir] Compile JS files
duck build:soy Compile Soy templates
duck build:deps Generate deps.js
duck clean:soy Remove all compiled .soy.js
duck clean:deps Remove generated deps.js
duck completion Generate completion script for bash/zsh
Options:
-v, --version Show version number [boolean]
-h, --help Show help [boolean]
CLI options overwrite config file
duck serve [entryConfigDir]
Start dev server
Options:
--inputsRoot A root directory to serve [string]
--closureLibraryDir A root directory of Closure Library [string]
--depsJs A path to deps.js to save and load [string]
--depsWorkers The number of workers to analyze deps [number] [default: 4]
--config A path to duck.config.js, the extension can be ommited [string]
--nonTTY, --noTTY, -n Output in nonTTY mode [boolean] [default: false]
--skipInitialBuild, -s Skip initial building of Soy and deps.js [boolean] [default: false]
--port A port number to listen [number] [default: 9810]
--host A host to listen [string] [default: "localhost"]
-v, --version Show version number [boolean]
-h, --help Show help [boolean]
duck build [entryConfigDir]
Build Soy, deps.js and JS
Options:
--entryConfigs, -e Entry config files (this option ignores entryConfigDir) [array]
--closureLibraryDir A root directory of Closure Library [string]
--config A path to duck.config.js, the extension can be ommited [string]
--concurrency, -c Concurrency limit of Closure Compiler [number]
--batch Build in batch mode (on AWS or local for debug)[choices: "aws", "local"]
--reporters Test reporters ("text", "xunit" or "json") [array] [default: ["text"]]
--reporterOptions Test reporter options
--printConfig, -p Print effective configs for compilers [boolean] [default: false]
--depsJs A path to deps.js to save and load [string]
--nonTTY, --noTTY, -n Output in nonTTY mode [boolean] [default: false]
--depsWorkers The number of workers to analyze deps [number] [default: 4]
--skipInitialBuild, -s Skip initial building of Soy and deps.js [boolean] [default: false]
--soyJarPath A path to Soy.jar [string]
--soyFileRoots Root directories of soy files [array]
--watch, -w Re-compile incrementally when files change [boolean] [default: false]
-v, --version Show version number [boolean]
-h, --help Show help [boolean]
Also see examples.
duck provides batch mode that compiles all entry points simultaneously in parallel on AWS Lambda with faast.js.
- Setting AWS credentials in Node.js (See AWS document)
- Configure
batchOptionsinduck.config.js. It's used for faast.js as AWSOptions.
const closureVersion = require('google-closure-compiler/package.json').version;
module.exports = {
batchOptions: {
region: 'ap-northeast-1',
awsLambdaOptions: {
Runtime: 'nodejs10.x',
},
include: ['path/to/your/source/**/*.js'],
exclude: ['**/*_spec.js'],
packageJson: {
dependencies: {
'google-closure-compiler-linux': closureVersion,
'google-closure-library': closureVersion,
},
},
},
};- Run
buildorbuild:jscommand with--batch aws.
$ duck build --batch aws- Use
--batch localfor local debugging - Use
DEBUG=faast:infoor other log level to get more debug information - Get
logUrlfrom debug info and view it in CloudWatch logs - Use
FAAST_PACKAGE_DIR=foo/barto investigate a package sent to Lambda
Also see faast.js document for more information.
Create a self-signed certificate like
$ openssl req -x509 -newkey rsa:4096 -keyout duck-key.pem -out duck-cert.pem -days 365 -nodes -subj '/CN=localhost'Then specify them and enable http2 in duck.config.js.
module.exports = {
http2: true,
https: {
keyPath: './path/to/duck-key.pem',
certPath: './path/to/duck-cert.pem'
}
};Initial setting:
$ duck completion >> ~/.bashrc
# or
$ duck completion >> ~/.zshrcThen, you can complete commands and options with TAB !
$ duck build:<TAB>
build:deps -- Generate deps.js
build:js -- Compile JS files
build:soy -- Compile Soy templatesMIT License: Teppei Sato <[email protected]>