#Use jsx-email within convex

6 messages · Page 1 of 1 (latest)

quartz kiln
#

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

#

The action file

frozen copper
#

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

quartz kiln
#

@frozen copper 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.

frozen copper
#

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
    }
})

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