https://www.boundaryml.com logo
🟡 Deployment Issue with BAML Setup
# questions
c
So I'm running into an issue with deploying the baml setup I just worked on implementing. I get this error
No loader is configured for ".node" files: ../../node_modules/@boundaryml/baml-linux-x64-gnu/baml.linux-x64-gnu.node
My app is running on convex-dev, their normal TS runtime is restrictive, but they have a 'use node' version that spawns a bigger node runtime, but this seems to require a custom runtime or something? I'm not familiar enough with node to know what native code this is looking for or how to load it
Am I doing this wrong? Or did I just waste a bunch of time?
b
Let me link you to the docs on this, we have an npm package for this!
If you're not in Nextjs, you'll need something like
Copy code
module.exports = {
  webpack: (config) => {
    config.module.rules.push({
      test: /\.node$/,
      loader: 'node-loader',
    })
    return config
  },
}
with
npm install --save-dev node-loader
(I'm not sure if that's exactly correct, but it's roughly along the lines of what you'll need.)
c
I am using nextjs, but I'm not using it as the backend function handler, I'm using convex-dev which is where all my messages and such need to get persisted. It connects over a separate websocket connection
I'll check out their docs to see if they have some way of doing this
b
But I think the better way would be to ask on their Discord
c
Ya i was just looking at that, it has a section on external packages. That seems more in line right?
b
It could be? Unfortunately I'm not familiar enough with Convex's runtime model to understand why they distinguish between external packages and esbuild-bundled deps
It does seem like the best bet though
c
I'm asking over there to see if there's an obvious answer
j
@chrisbod4 did you find anything here? Are you calling these from within a Convex Action? I don't think you can call anything from within a Query or Mutation because those are pure functions (which I think is necessary for them to convert into a transactional plan). This is also why the Mutation function schedules an Action in the wikipedia chat tutorial, rather than directly hitting the wikipedia api
I found running through the convex tutorial super helpful
I have not yet called BAML from Convex (we're currently in the middle of migrating our backend CRUD ops to Convex for now) but I think it's something we will likely do in the future as well
c
Ya I was in a 'use node' action, the problem is I don't think convex runners can load native code the way that baml does it. And I didn't want an external service as that would mean a whole other layer of trust to manage. So I ended up porting it to pure TS and just stuck it in a package in my monorepo. That was a simpler option for me.
j
When you say porting to pure TS and sticking it in a package in your monorepo, do you mean like checking in the BAML generated typescript client and pushing it to convex with your convex definitions? Not sure I fully understand
c
No I mean ported what baml does to pure TS. So it's all compiled directly into my app instead of an external dep
a
i got it working (calling a baml function in a convex action) by marking the '@boundaryml/baml' package as external; /convex.json: { "node": { "externalPackages": ["@boundaryml/baml"] } } https://docs.convex.dev/functions/bundling#specifying-external-packages