react-email
react-email copied to clipboard
NX Monorepo support
Hi, first of all, thank you for your work, it's a really great and promising lib :)
It would be really great if react-email could integrate in an NX monorepo.
Actually, we have to run email dev
, that creates a folder .react-email
and we have to add a yarn.lock into it to install dependencies.
Is it possible to make a thing about it ? Like create an adapter that doesnt create this folder and uses root package.json ?
Or maybe I miss something..
Thanks :)
You do not need to use yarn. You can use NPM if you want
I took a look at the code, but the dev server does use the root of your package.json
. So I guess you can generate a react email project and just move it to your monorep. I do not use NX monorepo, but I guess you still need to edit the nx.json
file to make it aware of your new project.
If not, can you provide a sample repo in which you want to integrate this project?
Here's a sample repo where it works and doesn't work:
https://github.com/williamgkzhang/nx-react-email
works with npx nx run backend-emails:serveFromWorkspace
but not so with npx nx run backend-emails:serve
Basically it'd be nice to generate the .react-email
next project in a sub-directory. The problem is that nx generates a package.json with the package name @org/packageName
in the subdirectory which violates readPackage
normalization.
Line in question: https://github.com/resendlabs/react-email/blob/ee7aa406e139948439fe5e9778a2ef2bc407bb54/packages/react-email/source/commands/dev.ts#L221
The read-pkg
itself uses https://github.com/npm/normalize-package-data
to do much of the heavy lifting. You could use that to parse the package.json
file with a warning function if all you care about is the dependencies in the resulting package.json
.
Or perhaps a cli flag to pick the package.json
directory.