This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-08-16
Channels
- # babashka (53)
- # beginners (61)
- # biff (2)
- # cherry (15)
- # cider (28)
- # clj-kondo (17)
- # clojure (57)
- # clojure-europe (27)
- # clojure-nl (13)
- # clojure-norway (6)
- # clojure-uk (4)
- # clojurescript (30)
- # core-async (2)
- # data-science (39)
- # datomic (16)
- # docker (34)
- # emacs (4)
- # events (1)
- # figwheel-main (9)
- # guix (5)
- # hiccdown (2)
- # honeysql (5)
- # hyperfiddle (5)
- # interceptors (1)
- # jobs (2)
- # joyride (5)
- # lsp (36)
- # midje (1)
- # minimallist (1)
- # nbb (21)
- # off-topic (45)
- # polylith (42)
- # rum (1)
- # shadow-cljs (24)
- # sql (1)
- # squint (62)
- # vrac (1)
- # xtdb (6)
What does "Cannot set property 'returnExports' of undefined" mean? I've created a node-library target in shadow-cljs, zipped the resulting js file and uploaded it as function code for an AWS lambda. When I call the lambda I get this error.
I export one function called 'handler' in js and I'm confident that it is being called correctly. Some environment checking code was throwing exceptions correctly, I fixed the env and then got this error.
I haven't included the node_modules. I thought the closure compiler included necessary dependencies. While I haven't added any node_modules, shadow-cljs has quite a few. Should I include all node_modules?
no, you only need to include the packages you actually use. you can also post-process the release
build with something like https://github.com/vercel/ncc to bundle all npm dependencies
shadow-cljs does not do that by default since generally it is not required or desirable for regular node builds
My build config looks like this:
:builds
{:lambda {:target :node-library
:exports {:handler com.pds.external-api.core/handler}
:output-to "target/lambda.mjs"
:compiler-options {:output-feature-set :es2020}}}
well the hint seems to be that you have :output-to "target/lambda.mjs"
meaning its expected to be a ES module?
if it must be a module use :target :esm
https://shadow-cljs.github.io/docs/UsersGuide.html#target-esm
changing the build target to .js worked perfectly. Thank you! I copied that entry from an example without understanding the significance.
So when I package the zip file, I should take care to include my own node_modules and their deps? Can shadow help me determine those deps or should I figure them out via dep trees and select what to zip?
FYI: transitive dependencies for any top level node package can be listed with npm ls -a --json | jq --arg v 'shadow-cljs' '[ .dependencies | .[$v] | .dependencies | .. | .dependencies? | objects | to_entries[] | .key ] | sort | unique'
and changing the value of --arg v
me recommendation is either post processing with ncc to get a completely standalone .js file