Modify dev builds to fit inside enterprisey function as a service runtime

In good clojure tradition, I sneaked in some clojure code into my customers enterprise environment.

I use shadow-cljs to generate a :node-library from my cljs code. This library is deployed to an enterprisey function as a service runtime (similar to AWS lambda) by an enterprisey cli tool. I cannot use shadows dev builds, as the enterprisey cli tool only accepts js files inside a single directory to be deployed to the runtime. Shadow references files outside this directory (like node_modules) and thus fails.

My workflow right now is to change code and then click manually on release build in shadow-cljs. I wait a bit and then see the changed code deployed inside the faas runtime.

I see 2 possible solutions:

  1. Get shadow to put all dev build js files under a single directory.
  2. Get shadow to do single file release-like builds on code changes during development.

You can configure :node-library with an additional :output-dir.

{:target :node-library
 ...
 :output-to "foo/lib.js"
 :output-dir "foo/files"}

This way the foo directory will contain all files. The build will however still access files from node_modules if you use any npm packages. In that case I’d recommend creating a package.json in the foo directory and installing the packages you need at runtime there. Don’t know if your “customers enterprise environment” supports this but I’d expect so?

Option 2. is not an option but you can always trigger a manual release build if needed. If you run shadow-cljs server separately you don’t pay the startup price and release builds can be reasonably fast. However optimizations may still take some time which is also why an “automatic” release build on watch changes is impractical.

Thanks for the ideas.

I tried option 1. Now the faas deployment tool cannot statically determine the required / require() js files and the deployment to the cloud fails.

Option 2 is super fine ok. Compilation time takes less than 2 seconds. Just clicking on the release button all the time is annoying.

If it really must be a single directory you can just use :output-dir "foo"? I was assuming it would also copy sub directories.

Your environment seems rather picky so release likely is the best option. Without more info about the environment I can’t make any other suggestions.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.