serverless-cljs-plugin
A Serverless plugin which uses lein/cljs-lambda (or, optionally Lumo) to package services written in Clojurescript.
Leiningen Template
$ lein new serverless-cljs exampleexample$ lein deps
Will generate an example
directory containing a minimal serverless.yml
and
project.clj
demonstrating this plugin's functionality.
Guide to using the plugin via Lein/JVM compilation.
Usage
functions: echo: cljs: example.core/echoplugins: - serverless-cljs-plugin
With the above serverless.yml
, serverless deploy
will create a zip file
containing your functions. Doing this is similar to setting the Serverless
packaging.artifact
option - cljs-lambda
is responsible for the zip contents,
and Serverless includes/excludes will be skipped (cljs-lambda
offers
equivalent functionality).
In the example above, there needn't be a corresponding entry for echo
in
project.clj
.
Lumo
Alternatively you can use the Lumo compiler.
In order to enable it, pass the --lumo
switch to either deploy
or package
:
$ serverless deploy --lumo
Or add the following to your serverless.yml
:
custom: cljsCompiler: lumo
-
Compiler options
The source paths and compiler options will be read from the optional file
serverless-lumo.edn
. Below are the defaults:{:source-paths ["src"]:compiler {:output-to "out/lambda.js":output-dir "out":source-map false ;; because of a bug in lumo <= 1.8.0:target :nodejs:optimizations :none}} -
Lumo Configuration
As an alternative to
cljsCompiler: lumo
,cljsCompiler.lumo
may be specified as a map of options. These options are passed directly to thelumo
process. Currently supported:custom:cljsCompiler:lumo:dependencies:- andare:0.7.0classpath:- /tmp/localRepo: /xyzcache: /cache | noneindex: true | falseexitOnWarning: true | falseNote: caching is always on unless you specify "none" in the config.
-
The index.js file
The
index
option will materialize a customindex.js
in:output-dir
's parent folder. This file should be thought as managed byserverless-cljs-plugin
and it is necessary for some plugin (e.g.:serverless-offline
) to work properly.Note: with the default compiler options,
index.js
will be saved in the project root, overwriting without warning. -
Exit on compilation warnings
Lumo generates warnings such as
WARNING: Use of undeclared Var
to signal failures. You can tune the ones you want to see by using the:warnings
compiler option inserverless-lumo.edn
, but by default thelumo
process emits the warnings, does not throw and returns0
. This means thatserverless
will keep going in presence of warnings.
License
serverless-cljs-plugin is free and unencumbered public domain software. For more information, see http://unlicense.org/ or the accompanying LICENSE file.