meenie
meenie3mo ago

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
meenie
meenieOP3mo ago
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...
ballingt
ballingt3mo ago
@meenie Convex functions do use the locally-resolved package from node_modules!
ballingt
ballingt3mo ago
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-packages
Bundling | Convex Developer Hub
Bundling is the process of gathering, optimizing and transpiling the JS/TS
meenie
meenieOP3mo ago
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.
ballingt
ballingt3mo ago
Is the fix being applied in the dist folder of the node_modules/that_library/dist ?
meenie
meenieOP3mo ago
Yup
diff --git a/dist/functions.js b/dist/functions.js
index 0c0577b1ac964d474b18705f55a647fe26b179f8..1ba2e75bae202ec1f4aa7cb951599e72f15ffece 100644
--- a/dist/functions.js
+++ b/dist/functions.js
@@ -820,7 +820,7 @@ var PromiseEdgeOrNullImpl = class _PromiseEdgeOrNullImpl extends PromiseEntsOrNu
if (sourceId === null) {
return null;
}
- const edgeDoc = this.ctx.db.query(this.edgeDefinition.table).withIndex(
+ const edgeDoc = await this.ctx.db.query(this.edgeDefinition.table).withIndex(
edgeCompoundIndexName(this.edgeDefinition),
(q) => q.eq(this.edgeDefinition.field, sourceId).eq(
this.edgeDefinition.ref,
diff --git a/dist/functions.js b/dist/functions.js
index 0c0577b1ac964d474b18705f55a647fe26b179f8..1ba2e75bae202ec1f4aa7cb951599e72f15ffece 100644
--- a/dist/functions.js
+++ b/dist/functions.js
@@ -820,7 +820,7 @@ var PromiseEdgeOrNullImpl = class _PromiseEdgeOrNullImpl extends PromiseEntsOrNu
if (sourceId === null) {
return null;
}
- const edgeDoc = this.ctx.db.query(this.edgeDefinition.table).withIndex(
+ const edgeDoc = await this.ctx.db.query(this.edgeDefinition.table).withIndex(
edgeCompoundIndexName(this.edgeDefinition),
(q) => q.eq(this.edgeDefinition.field, sourceId).eq(
this.edgeDefinition.ref,
ballingt
ballingt3mo ago
You might try applying it to the source as well which file will be used depends on module resolution settings and esbuild
meenie
meenieOP3mo ago
No description
meenie
meenieOP3mo ago
Ahhh Okay, lemme try that as well.
ballingt
ballingt3mo ago
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
meenie
meenieOP3mo ago
There is no source folder for convex-ents. You guys just publish the ./dist folder.
meenie
meenieOP3mo ago
No description
ballingt
ballingt3mo ago
huh, and which files are pointed to by the package.json?
meenie
meenieOP3mo ago
"files": [
"dist"
],
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"files": [
"dist"
],
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
ballingt
ballingt3mo ago
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)
meenie
meenieOP3mo ago
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.
ballingt
ballingt3mo ago
ok if this happens after the bun install then I'd think this would work
meenie
meenieOP3mo ago
None of the console.logs 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. 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 index.js file that is being imported. Damn, I hate being stupid.
ballingt
ballingt3mo ago
Certainly confusing that dist/ has those files but they are't used! Glad it's working. Thanks for contributing the pull request!

Did you find this page helpful?