A Serverless plugin which uses lein/cljs-lambda (or, optionally Lumo) to package services written in Clojurescript.
$ lein new serverless-cljs example
example$ lein depsWill generate an example directory containing a minimal serverless.yml and
project.clj demonstrating this plugin's functionality.
functions:
echo:
cljs: example.core/echo
plugins:
- serverless-cljs-pluginWith 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.
Alternatively you can use the Lumo compiler.
In order to enable it, pass the --lumo switch to either deploy or package:
$ serverless deploy --lumoOr 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.lumomay be specified as a map of options. These options are passed directly to thelumoprocess. Currently supported: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
indexoption will materialize a customindex.jsin:output-dir's parent folder. This file should be thought as managed byserverless-cljs-pluginand it is necessary for some plugin (e.g.:serverless-offline) to work properly.Note: with the default compiler options,
index.jswill be saved in the project root, overwriting without warning. -
Exit on compilation warnings
Lumo generates warnings such as
WARNING: Use of undeclared Varto signal failures. You can tune the ones you want to see by using the:warningscompiler option inserverless-lumo.edn, but by default thelumoprocess emits the warnings, does not throw and returns0. This means thatserverlesswill 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.