Is it possible to specify a closure define on compiletime from the environment? In shadow-cljs there's something like {:closure-defines {:my-define #shadow/env "MY_ENVVAR"}}
, which goes in the shadow-cljs.edn
config file
@grav you mean when compiling lumo or lumo.build.api?
and good news for nixos users, this eternal headache of getting it to work there, I hope I've ended it with this PR https://github.com/NixOS/nixpkgs/pull/44076 Basically no shortcut, blood sweat and tears were used to compile the whole thing from source, with every dependency targeted with sha-sums, node modules and jars.
and the way I compile it there, very verbose with clj
, could be an alternative to compiling it with boot. As trying to make boot work in offline mode was a headache that I finally gave up on.
omg
@hlolli you’re a hero
but that looks so brittle
and subject to breakage should we change any deps at all
yes, the change of deps wouldn't hurt. But I'd like to know how boot-cljs uses the build-api. So that I'm not requireing all these namespaces. As for the deps, it's aumomatically generated, both node and clojure deps, so I'd run it again for every new version.
specifically for this task I made https://github.com/hlolli/clj2nix which takes deps.edn and exports the nix expression with shasums
there's actually one bug in this, the binary is called directly, meaning the first cli parameter is ignored. I think I need to use wrapBinary (or just node process like on npm).
or sed process.argv.slice(2)
to process.argv.slice(1)
in src/js/cli.js
Woah
@hlolli I guess through the API. I’m using a serverless
plugin for lumo (or rather a lumo plugin for serverless), so I’m not using the api directly
@grav author of that plugin here 😄 I don't think you can populate the :closure-defines
from the env vars in the serverless plugin...the plugin just accepts options from serverless-lumo.edn
if I remember correctly
@richiardiandrea Ah, yes that’s right - there’s not a config file for lumo itself. I’m mixing it with shadow-cljs.
And thanks for the plugin btw 🙂
one thing you can do is to generate the serverless-lumo.edn
file as part of one of the serverless lifecycle hooks
And the edn file accepts :closure-defines
?
Hrm. This is odd. Trying to set :closure-defines
manually doesn’t work in lumo
:
cljs.user=> (set! js/goog.global.CLOSURE_UNCOMPILED_DEFINES #js {"foo.core.bar" "hi"})
#js {"foo.core.bar" "hi"}
cljs.user=> (ns foo.core)
nil
foo.core=> (goog-define bar "x")
nil
foo.core=> bar
"x"
(I was thinking that a workaround like this might be possible https://github.com/planck-repl/planck/issues/773)
the .edn
is just passed as compiler options so in theory it should work
yep so just make sure you use :compiler
as key: https://github.com/nervous-systems/serverless-cljs-plugin/blob/master/serverless-cljs-plugin/serverless_lumo/build.cljs#L68