Will it ever be possible to use
Will it ever be possible to use something like
bun patch
for third-party node modules that will run within the Convex environment? Every time we save a file within the ./convex
folder, the change gets deployed to the convex database. I'm assuming that you guys do your own dependency install process and don't care what's in my local node_modules
folder. The issue I'm having is that I found a bug in a 3rd-party library and I'm not able to patch it until my PR is merged so I can use the bug fix in my local development.19 Replies
The PR mentioned above: https://github.com/get-convex/convex-ents/pull/39
GitHub
Fix many:many .has() utility by meenie · Pull Request #39 · get-con...
This utility always returns true. There was a missing await which means Promise { <pending> } !== null will always be true.
By submitting this pull request, I confirm that you can u...
@meenie Convex functions do use the locally-resolved package from node_modules!
The exception to this is for "use node" files in the convex directory if you're using the "external packages" config option, which causes some package to be installed via
npm install
instead https://docs.convex.dev/functions/bundling#external-packagesBundling | Convex Developer Hub
Bundling is the process of gathering, optimizing and transpiling the JS/TS
Hmmm... The patch is being applied and the fix is in my
node_modules
folder, but the error still happens. I made sure to restart npx convex dev
as well. Defo not using the "use node" stuff.
I'll check again just to make sure.Is the fix being applied in the dist folder of the
node_modules/that_library/dist
?Yup
You might try applying it to the source as well
which file will be used depends on module resolution settings and esbuild
Ahhh
Okay, lemme try that as well.
Convex bundles up each file in the convex/ directory with esbuild, so esbuild is driving what code is used. I don't think there's a way to debug what files are actually used but we should add that
There is no source folder for
convex-ents
. You guys just publish the ./dist
folder.huh, and which files are pointed to by the package.json?
dist/index.js isn't a bundled file with all the code in it is it?
Try adding console.logs in ther emanually, no bun patch, and see if that works
(I dont' know how bun patch works)
bun patch
just makes it easier to mutate a file in your node_modules
after a bun install
. It creates a patches
folder in your app and applies diffs to the proper files. It's a nice way to patch security issues ASAP without having to wait on the 3rd-party author to do so.
I'll add some console logs.ok if this happens after the bun install then I'd think this would work
None of the No, I made sure. I'm an idiot. When I searched for similar code, I think Cursor excluded the files even though I specifically told it to look in that folder 🤦🏼♂️
This is all working fine. You're right, it's only the
console.log
s I've added in that file are coming through. Saving it doesn't trigger a deploy. I've made changes to my files that consume this library and also restarted npx convex dev
and there are no console logs coming through from there. Only the ones in my own files.
index.js
file that is being imported. Damn, I hate being stupid.Certainly confusing that dist/ has those files but they are't used! Glad it's working. Thanks for contributing the pull request!