Mordsith
Mordsith8mo ago

Use jsx-email within convex

jsx-email has clean-css as a dependency that throws an error within the convex environment. I'm using this in convex actions with use node at the top of the file but no luck. Any idea how to get past this would be appreciated
No description
5 Replies
Mordsith
MordsithOP8mo ago
The action file
No description
sshader
sshader8mo ago
I'd double check that there are no other files importing jsx-email without the "use node" at the top. I'd also check that there are no files without "use node" that import from the files that import from jsx-email
Mordsith
MordsithOP8mo ago
@sshader I have an action with use node that calls a mailer function with use node. In this mailer function file is where I imported jsx-email. jsx-email is a node library. I have use node from the action file to the file that impors the library.
No description
No description
sshader
sshader8mo ago
So to confirm, convex/lib/mails/summary.tsx is the only Convex file that imports jsx-email and convex/routes/sessionSummary/internal_actions.ts is the only Convex file that imports convex/lib/mails/summary.tsx? And both have "use node" at the top? FWIW I can reproduce your original issue with this code
import { action } from "./_generated/server";
import { render } from "jsx-email"

export default action({
handler: async (_ctx, _args) => {
// log it so the bundler doesn't remove the import
console.log(render)
return null
}
})
import { action } from "./_generated/server";
import { render } from "jsx-email"

export default action({
handler: async (_ctx, _args) => {
// log it so the bundler doesn't remove the import
console.log(render)
return null
}
})
But use node fixes it, so I suspect that we're accidentally importing jsx-email indirectly from a file that does not have use node at the top
Mordsith
MordsithOP8mo ago
It worked, thank you very much @sshader . I had another file that was importing the component

Did you find this page helpful?