Fork me on GitHub
#nbb
<
2022-07-18
>
sirwobin19:07:27

Hi folks. I have a packaging question for an AWS lambda using nbb. My handler function runs just fine in a repl on my laptop. I zipped up the top directory including node_modules/ and uploaded it to my shiny new lambda function. When I invoke it for the first time it complains that it cannot load the second namespace in my zip file.

borkdude19:07:41

Do you see the log.cljs (which is presumably the namespace you can't load) in the AWS Console?

sirwobin19:07:02

Hi Michiel, yes I do

borkdude19:07:24

And all files are in the top level directory right?

sirwobin19:07:33

oh, looks like that's the problem

sirwobin19:07:00

I have another directory in the way! Stupid me

borkdude19:07:14

no worries, can happen :)

sirwobin19:07:29

Hmm, now I'm sure that *.cljs are in the root dir of the zip file. The AWS console is showing my zip file as a folder.

borkdude19:07:10

And does it work?

sirwobin19:07:17

Tried to test again and still get "Could not file namespace: log"

sirwobin19:07:53

so core is being found because it requires log

sirwobin19:07:58

but log isn't found

borkdude19:07:00

What is in your index.mjs?

borkdude19:07:28

what nbb version are you using?

borkdude19:07:38

sounds good

borkdude19:07:58

Can you publish your code somewhere?

sirwobin19:07:00

fantastic scripting environment btw! I'm loving it so far

❤️ 1
sirwobin19:07:20

Lemme put it to github and share with you

borkdude19:07:00

thanks. Can you perhaps update the nbb version here? https://github.com/sirwobin/external-api-cljs/blob/main/package.json cc @U04V5V0V4 The nbb version mentioned in the blog is from December 2021. Can this be updated to 0.6.126 or so? I'm afraid it would set people on the wrong foot otherwise

1
borkdude19:07:18

@U1KGF7AG3 And then repeat npm install, re-zip and then try again

borkdude19:07:00

Not sure if this will fix things, but I don't see anything weird

borkdude19:07:03

I can reproduce the issue with:

npm install
node index.mjs

borkdude19:07:01

@U1KGF7AG3 OK, this is the fix:

import { loadFile, addClassPath } from 'nbb';

addClassPath('.');

borkdude19:07:04

put that in index.mjs

sirwobin19:07:48

Perfect! Thank you. will try that now

sirwobin19:07:47

Update looks great. Thanks again

🎉 1
sirwobin19:07:18

The contents of the zip file are {index.mjs, package.json, core.cljs, log.cljs, node_modules/...}