nickm91
nickm912y ago

Hey team how does npm bundling work in

Hey team, how does npm bundling work in convex actions? Let's say I've got this action
'use node';

import { build } from "esbuild";

export const doSomethingWithEsBuild = action({
args: {},
handler: async () => {
// do something with esbuild...
},
});
'use node';

import { build } from "esbuild";

export const doSomethingWithEsBuild = action({
args: {},
handler: async () => {
// do something with esbuild...
},
});
But I see this error in the function response from client and on the dashboard when I run the function through there too:
Uncaught Error: The esbuild JavaScript API cannot be bundled. Please mark the "esbuild" package as external so it's not included in the bundle.

More information: The file containing the code for esbuild's JavaScript API (/var/task/aws_lambda.cjs) does not appear to be inside the esbuild package on the file system, which usually means that the esbuild package was bundled into another file. This is problematic because the API needs to run a binary executable inside the esbuild package which is located using a relative path from the API code to the executable. If the esbuild package is bundled, the relative path will be incorrect and the executable won't be found.
at esbuildCommandAndArgs (../../node_modules/esbuild/lib/main.js:1971:6)
at ensureServiceIsRunning (../../node_modules/esbuild/lib/main.js:2144:14)
at build (../../node_modules/esbuild/lib/main.js:2036:15)
at handler (../../convex/workers/wrangle.ts:16:13)
Uncaught Error: The esbuild JavaScript API cannot be bundled. Please mark the "esbuild" package as external so it's not included in the bundle.

More information: The file containing the code for esbuild's JavaScript API (/var/task/aws_lambda.cjs) does not appear to be inside the esbuild package on the file system, which usually means that the esbuild package was bundled into another file. This is problematic because the API needs to run a binary executable inside the esbuild package which is located using a relative path from the API code to the executable. If the esbuild package is bundled, the relative path will be incorrect and the executable won't be found.
at esbuildCommandAndArgs (../../node_modules/esbuild/lib/main.js:1971:6)
at ensureServiceIsRunning (../../node_modules/esbuild/lib/main.js:2144:14)
at build (../../node_modules/esbuild/lib/main.js:2036:15)
at handler (../../convex/workers/wrangle.ts:16:13)
3 Replies
presley
presley2y ago
We are actively working on it. Will aim to releasing a BETA in a couple of weeks. Sorry about the trouble. Side note: Interesting you try to use esbuild. Since we use esbuild to bundle. So in your case, esbuild fails to bundle esbuild.
nickm91
nickm91OP2y ago
Yeah the irony right.. Its actually a bit of a work around to the fact I cant see a programmatic API for convex. cc @presley I've got to say I love the model convex uses, simplifed DB modelling, drop in api layer and auto cached queries and instant "subscriptions". I'd love a way (and would be very open to helping contribute to this in some way) to allow folks like myself to manage many convex projects for downstream clients from an API, including an API to build functions leveraging your esbuild setup etc.. Context is that I've got my own project that allows users/teams to define data models, services and frontends in a drag on drop way, and Iove to integrate that concept with convex at its core via an API. So drop me DM or something, got a ton of sw experience and I'd be very down to help
presley
presley2y ago
Yeah, what you are building sounds pretty interesting. Yeah, API for provisoning & co is something in something we are going to need to do eventually.

Did you find this page helpful?