Closed arichiardi closed 7 years ago
@arichiardi When serverless-cljs-plugin is used, it doesn't make any AWS calls - serverless is responsible for doing that (if you use cljs-lambda to deploy, w/out serverless, then it'll make the API calls).
So if you want to avoid the JVM, the problem you'd want to solve is writing something executable which takes a cljs project directory and compiles it into a zip file of js, with an index.js file containing an entry for each handler. That would then be a drop-in replacement for the lein cljs-lambda
invocation used inside this serverless plugin.
I personally am not motivated to do that, because for my use cases, JVM compilation makes a lot of sense. I'm more than happy to answer questions you might have about what you'd need to do, if I'm able.
You are right, I see that this plugin basically calls the build
of cljs-lambda
. I have studied a bit in the meantime and I am going to work on something...if it is worth publishing you'll see a link here at some point.
I am wondering whether I should try to wrap this and compile with lumo
. It would probably be ok for some libs, less ok for others, but eventually the GCC for JS will get feature parity I guess...
If you write a javascript module which takes the same inputs as the lein cljs-lambda build
invocation in this project, and which creates an identical zip output file (compiled with lumo, or whatever), I can help you with the rest.
I have always had in the radar calvin-cljs. This might be the time when I can actually start using it :wink: /cc @eginez
I have just tried in a cljs-lambda
project and it fails, both for core.async
and because of the macros namespaces not compatible
Yeah - I think getting cljs-lambda, the runtime library, to compile with another tool is best considered a separate problem from using the serverless plugin to trigger a project build without involving the JVM. You could have a project with no custom dependencies, and an xyz.core
namespace like so:
(ns xyz.core)
(def ^:export handler [event ctx callback]
(callback nil "Success"))
And that would work with lein-cljs-lambda, the plugin, if you associated xyz.core/handler
with a lambda function. If I were focused on getting the process to work, I'd initially forget about the optional runtime library (which contains very little functionality), and try to concentrate on compilation and zip structure.
I am doing exactly that, with partial success. I also think that probably, unless you think otherwise, this would be considered a separate plugin. Or otherwise there is going to be a need of a :compilation-style
key in the config somewhere.
The serverless bit could probably be the same plugin, i.e. if your 'compile my code' thing was an npm dependency of this project, we could use a command line switch to conditionally use it over the JVM. Assuming that you don't want to launch a JVM, then yeah, the 'compile my code' thing would have to be totally separate, I would guess.
Yes calvin-cljs
is on npm
and the command I am trying is as simple as:
./node_modules/.bin/calvin build dev
That calls lumo
after resolving all the deps from project.clj
.
This was started in #6 and continues in branch wip/lumo
. I guess I can close it now.
Hello folks ;)
Just putting there this idea in order for me to understand what it would take to have something that just calls the AWS command line tool directly without spinning a JVM (this maybe is the same as the other issue in
cljs-lambda
).It would make startup time way faster and little or no change to the current plugin.
:peace_symbol: :wave: