nbb

ray 2022-10-31T21:02:07.686659Z

We are seeing some errors finding deps when using nbb.edn on Lambdas

ray 2022-10-31T21:02:14.351649Z

ray 2022-10-31T21:03:38.469659Z

we have ensured that the contents of .nbb is populated and added to the zip

ray 2022-10-31T21:03:47.897599Z

are other folders needed?

borkdude 2022-10-31T21:06:11.871199Z

I don't think so but I think you should be able to reproduce that locally

borkdude 2022-10-31T21:06:27.191339Z

did you also add the nbb.edn to the zip?

ray 2022-10-31T21:07:04.670609Z

yes

borkdude 2022-10-31T21:07:23.861859Z

and the lambda is running the code from the directory where the nbb.edn is right?

ray 2022-10-31T21:08:36.544459Z

yes

borkdude 2022-10-31T21:08:55.462669Z

should work (in theory) but reproducing locally to find out would be best

ray 2022-10-31T21:09:25.947979Z

ok, just wanted to make sure I hadn't missed anything obvious

borkdude 2022-10-31T21:09:35.169929Z

else https://github.com/babashka/nbb/tree/main/doc/bundle is still an option. This produces a single .mjs file where all .cljs is inlined into a single file, so no .nbb necessary

ray 2022-10-31T21:10:09.089459Z

the project supports many lambdas

ray 2022-10-31T21:10:49.057259Z

so I'm not sure that's viable

borkdude 2022-10-31T21:11:09.182709Z

I can look more closely tomorrow if you find something

ray 2022-10-31T21:11:31.011669Z

I'll check in the morning also - thanks!

ray 2022-11-01T08:33:37.006329Z

$ node card-get.mjs 
file:///home/ray/fc/repos/card-main/node_modules/nbb/lib/nbb_core.js:2214
2,null),new $APP.G(null,jt,new $APP.G(null,new $APP.G(null,$APP.Ul,new $APP.G(null,D,null,1,null),2,null),null,1,null),2,null),3,null),4,null),5,null),6,null)):null}finally{$APP.Wq()}}).then(function(){var P=$APP.z(a);return hx.h?hx.h(P,b):hx.call(null,P,b)}):Promise.reject(Error(["Could not find namespace: ",$APP.p.g(q)].join("")))}return Promise.resolve($APP.U.g(b))};
                                                                                                                                                                                                                                                                                   ^

Error: Could not find namespace: camel-snake-kebab.core
    at hx (file:///home/ray/fc/repos/card-main/node_modules/nbb/lib/nbb_core.js:2214:276)
    at file:///home/ray/fc/repos/card-main/node_modules/nbb/lib/nbb_core.js:2214:244
    at async file:///home/ray/fc/repos/card-main/card-get.mjs:5:21

ray 2022-11-01T08:35:33.834859Z

I tried with node 14 / 16 / 18 and got the same result

borkdude 2022-11-01T08:36:42.186259Z

I’m not sure what I’m looking at

borkdude 2022-11-01T08:37:17.815899Z

Can you make some kind of repro? Will be at kbd in an hour

ray 2022-11-01T08:42:04.854109Z

Sure but can you confirm that is it supposed to "just work" directly with node?

borkdude 2022-11-01T08:42:38.446019Z

It depends what you did. I have no clue with additional context?

ray 2022-11-01T08:42:59.061029Z

ok, I'll try to make a small repro

borkdude 2022-11-01T09:42:41.060819Z

ok, I'm back at kbd now

ray 2022-11-01T10:08:17.501139Z

https://github.com/raymcdermott/nbb-deps-repro

ray 2022-11-01T10:09:12.144369Z

after npm install and npx nbb call node card-get.mjs

borkdude 2022-11-01T10:14:03.419679Z

I think when going through the JS API, it doesn't add the .nbb stuff. You can fix this by adding addClassPath(".nbb/.cache/e4754d38932a5ba3dcbfe8a138680e6ec55900db/nbb-deps") manually for now. Issue welcome

borkdude 2022-11-01T10:14:11.575779Z

(I tested the above, it works)

borkdude 2022-11-01T10:14:31.943239Z

why do you have the .mjs file here again?

borkdude 2022-11-01T10:14:39.155099Z

oh yes, for AWS

šŸ‘šŸ¼ 1
borkdude 2022-11-01T10:15:31.820839Z

next time you can also use getClassPath to print the current classpath, for debugging

ray 2022-11-01T10:17:42.524749Z

is addClasspath in the card-get.mjs?

borkdude 2022-11-01T10:21:46.977209Z

yes:

import { addClassPath, getClassPath, loadFile } from 'nbb';

addClassPath("src")
addClassPath(".nbb/.cache/e4754d38932a5ba3dcbfe8a138680e6ec55900db/nbb-deps")

const { handler } = await loadFile('./src/card_get.cljs');

export { handler }

ray 2022-11-01T10:22:06.709349Z

ok, I'll open an issue

borkdude 2022-11-01T10:22:42.620999Z

nice

borkdude 2022-11-01T10:22:53.874249Z

I'll probably get to this tomorrow or Thursday

šŸ‘šŸ¼ 1
ray 2022-11-01T10:40:56.155519Z

find .nbb -type d -name nbb-deps

ray 2022-11-01T11:49:52.033909Z

and of course I have to write bash šŸ™‚

borkdude 2022-11-01T11:50:43.255079Z

You could do this as part of the .mjs script too ;)

ray 2022-11-01T11:52:13.320569Z

I much prefer to write code like this

function patch() {
    sed -e "s?\(^addClassPath.*\)?\1\n${extra_classpath}?" $1
}

borkdude 2022-11-01T11:53:33.600389Z

Btw, there's also plenty npm deps that can do the kebab thing: https://www.npmjs.com/package/kebab-case

ray 2022-11-01T11:58:19.206409Z

I'm working with keywords babe šŸ™‚

ray 2022-11-01T11:59:04.691669Z

anyway ... it's a fun adventure to find all the nooks and crannies a week before the project goes live

borkdude 2022-11-01T12:05:24.564149Z

sarcasm?

ray 2022-11-01T12:07:12.893099Z

no, no

ray 2022-11-01T12:08:32.323219Z

I just mean that I have to be careful now about what new features to adopt

ray 2022-11-01T14:24:40.800889Z

https://github.com/babashka/nbb/issues/270

borkdude 2022-11-01T14:57:30.040549Z

@raymcdermott Fixed in 1.0.140

ray 2022-11-01T15:09:36.637829Z

goddammit I was just deploying my countermeasure šŸ™‚

ray 2022-11-01T15:10:00.295029Z

but in all sincerity, thanks