Fork me on GitHub
#nbb
<
2022-07-13
>
borkdude13:07:03

Just released another version of nbb with some bug fixes. Nbb's birthday is coming up at the end of the month - will it reach 500 stars or not by then...? https://github.com/babashka/nbb

❤️ 3
3
Michaël Salihi13:07:00

Let's say, I want to run serverless function (DigitalOcean functions) accepting only CommonJS with a main function. For now, I have a working solution with this wrapper hello.cjs:

async function main(params) {
  const { handler } = await import('./hello.mjs');
  return handler(params);
}

exports.main = main;
Any kind of suggestion or better way to run nbb?

borkdude14:07:45

So hello.cjs loads hello.mjs which loads nbb?

borkdude14:07:12

Cool workaround :)

😁 1
borkdude14:07:29

One other option is to put it through webpack which is able to bundle your entire thing into a .cjs file, including nbb.

borkdude14:07:46

But I think your workaround is great and should maybe be documented somewhere in nbb's repo

Michaël Salihi14:07:54

Thanks. 🙂 I saw this happen when you added the version of nbb with bundle. Will try.

borkdude14:07:15

> I saw this happen what did you see happen?

Michaël Salihi14:07:48

Yes, that's what I intended (to document this). Precisely, I wanted a confirmation before doing the PR so perfect 🙂

Michaël Salihi14:07:09

> what did you see happen? Badly expressed sorry. I saw the doc about bundle + webpack that you linked.