This article is based on this gist by Jack Rusher. Thanks Jack!
All you need to do to get nbb running on AWS Lambda is the following:
package.json:
{
"type": "module",
"scripts": {
"start": "functions-framework --target=hello"
},
"main": "index.mjs",
"dependencies": {
"nbb": "0.2.8",
"@google-cloud/functions-framework": "~1.9.0"
}
}
index.mjs:
import { loadFile } from 'nbb';
const { hello } = await loadFile('./hello.cljs');
export { hello }
hello.cljs:
(ns hello)
(defn hello [req res]
(js/console.log req)
(.send res "hello world"))
#js {:hello hello}
Then deploy the function with:
$ gcloud functions deploy hello --runtime nodejs14 --trigger-http
Also see Nbb on AWS Lambda.