A Serverless plugin for deploying Clojurescript functions
npm install serverless-cljs-plugin
A Serverless plugin which
uses lein/cljs-lambda (or,
optionally Lumo) to package services
written in Clojurescript.
`` shell`
$ lein new serverless-cljs example
example$ lein deps
Will generate an example directory containing a minimal serverless.yml andproject.clj demonstrating this plugin's functionality.
`yaml
functions:
echo:
cljs: example.core/echo
plugins:
- serverless-cljs-plugin
`
With the above serverless.yml, serverless deploy will create a zip filepackaging.artifact
containing your functions. Doing this is similar to setting the Serverless option - cljs-lambda is responsible for the zip contents,cljs-lambda
and Serverless includes/excludes will be skipped ( offers
equivalent functionality).
In the example above, there needn't be a corresponding entry for echo inproject.clj.
Alternatively you can use the Lumo
compiler.
In order to enable it, pass the --lumo switch to either deploy or package:
`shell`
$ serverless deploy --lumo
Or add the following to your serverless.yml:
`yaml`
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:
`clojure`
{: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 specifiedlumo
as a map of options. These options are passed directly to the process.
Currently supported:
`yaml`
custom:
cljsCompiler:
lumo:
dependencies:
- andare:0.7.0
classpath:
- /tmp/
localRepo: /xyz
cache: /cache | none
index: true | false
exitOnWarning: true | false
_Note_: caching is always on unless you specify "none" in the config.
- _The index.js file_
The index option will materialize a custom index.js in :output-dir's parent folder. Thisserverless-cljs-plugin
file should be thought as managed by 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:warnings
failures. You can tune the ones you want to see by using the
compiler optionserverless-lumo.edn
in , but by default the lumo process emits the warnings,0
does not throw and returns . This means that serverless` will keep going in
presence of warnings.
serverless-cljs-plugin is free and unencumbered public domain software. For more
information, see http://unlicense.org/ or the accompanying LICENSE
file.