nbb 2022-10-31

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

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

are other folders needed?

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

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

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

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

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

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

the project supports many lambdas

so I'm not sure that's viable

I can look more closely tomorrow if you find something

I'll check in the morning also - thanks!

$ 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

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

I’m not sure what I’m looking at

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

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

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

ok, I'll try to make a small repro

ok, I'm back at kbd now

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

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

(I tested the above, it works)

why do you have the .mjs file here again?

oh yes, for AWS

šŸ‘šŸ¼ 1

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

is addClasspath in the card-get.mjs?

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 }

ok, I'll open an issue

I'll probably get to this tomorrow or Thursday

šŸ‘šŸ¼ 1

find .nbb -type d -name nbb-deps

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

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

I much prefer to write code like this

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

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

I'm working with keywords babe šŸ™‚

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

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

goddammit I was just deploying my countermeasure šŸ™‚

but in all sincerity, thanks