winsoroaks
winsoroaks15mo ago

how to convex-helpers?

hello team. i wonder if my setup is wrong while trying to use convex-helpers. i've been running into
./node_modules/convex-helpers/server/relationships.ts
Module parse failed: Unexpected token (20:28)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| * @returns The Documents referenced by the Ids, in order.
| */
./node_modules/convex-helpers/server/relationships.ts
Module parse failed: Unexpected token (20:28)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| * @returns The Documents referenced by the Ids, in order.
| */
tried doing webpack, ts-loader etc. but didnt get it to work. pls lemme know. thanks!
11 Replies
ian
ian15mo ago
Howdy! where are you importing it from? I wouldn't expect it to need webpack - the goal was it'd be imported via esbuild that convex runs when uploading your functions. So I didn't generate cjs / mjs files. Do you have an example repo I could check out to debug?
winsoroaks
winsoroaksOP15mo ago
im having it under convex/db/merchant.ts. i havent been able to commit / push since it's messy :/
No description
ian
ian15mo ago
The repo uses the library as an import for some test functions in convex/counter.ts e.g.
GitHub
GitHub - get-convex/convex-helpers: A collection of useful code to ...
A collection of useful code to complement the official packages. - GitHub - get-convex/convex-helpers: A collection of useful code to complement the official packages.
ian
ian15mo ago
Is the error when you're bundling client code or server?
winsoroaks
winsoroaksOP15mo ago
client code
ian
ian15mo ago
Gotcha - tell me more about your client - framework / tsconfig / build script?
winsoroaks
winsoroaksOP15mo ago
next.js, my tsconfig for the convex/ dir is basically the same other than i have "jsx": "react" in my tsconfig.
{
/* This TypeScript project config describes the environment that
* Convex functions run in and is used to typecheck them.
* You can modify it, but some settings required to use Convex.
*/
"compilerOptions": {
/* These settings are not required by Convex and can be modified. */
"allowJs": true,
"strict": true,

/* These compiler options are required by Convex */
"target": "ESNext",
"lib": ["ES2021", "dom"],
"forceConsistentCasingInFileNames": true,
"allowSyntheticDefaultImports": true,
"module": "ESNext",
"moduleResolution": "Node",
"isolatedModules": true,
"noEmit": true,
"jsx": "react"
},
"include": ["./**/*"],
"exclude": ["./_generated"]
}
{
/* This TypeScript project config describes the environment that
* Convex functions run in and is used to typecheck them.
* You can modify it, but some settings required to use Convex.
*/
"compilerOptions": {
/* These settings are not required by Convex and can be modified. */
"allowJs": true,
"strict": true,

/* These compiler options are required by Convex */
"target": "ESNext",
"lib": ["ES2021", "dom"],
"forceConsistentCasingInFileNames": true,
"allowSyntheticDefaultImports": true,
"module": "ESNext",
"moduleResolution": "Node",
"isolatedModules": true,
"noEmit": true,
"jsx": "react"
},
"include": ["./**/*"],
"exclude": ["./_generated"]
}
"scripts": {
"dev": "npm-run-all dev:init --parallel dev:frontend dev:backend",
"dev:frontend": "next dev",
"dev:backend": "convex dev",
"scripts": {
"dev": "npm-run-all dev:init --parallel dev:frontend dev:backend",
"dev:frontend": "next dev",
"dev:backend": "convex dev",
i commented out a bunch of stuff and now im seeing too many errors 🫠
ian
ian15mo ago
Ok I have a repro - for now you might want to just copy the file in again, until I get bundling working with Next.js. Sorry! But the file is updated so should work 🤷‍♂️ - I tested copying the file in locally
winsoroaks
winsoroaksOP15mo ago
np, thank you so much ian 🙂
ian
ian15mo ago
Ok give this one a shot: convex-helpers@0.1.3 TIL... a little more about bundling
winsoroaks
winsoroaksOP15mo ago
works now. thanks, ian! 🎉

Did you find this page helpful?