An overview of the React Email codebase
Directory | Description |
---|---|
apps | Here you can find all of the apps related to our online presence, like:
|
benchmarks | We make benchmarks from version-to-version to demonstrate data-observable performance gains with metrics like p99 and p75.For example, see the Improved Performance for Tailwind Emails benchmark. |
packages | Most contributions will be made to the packages in this directory.This directory contains all our published NPM packages. Each subdirectory is a single component published as its own package, with the exception of a few packages that serve as shared configuration. |
turbo build
in any of the packages will build both the package
you are on as well as the dependent packages. The global installation handles version mismatching as well.
build
, dev
, and start
commands all depend on the user first installing @react-email/preview-server
.
Locally installing the preview server also includes all the required dependencies so you can run the necessary commands.
nypm and jiti work together to first ensure @react-email/preview-server
is installed and then to import it into the CLI.
The Preview Server and the CLI work together. The CLI detects changes to files
in the user’s dependency graph with chokidar and then sends
the updated files to the Preview Server using socket.io. Other details, like the path to the user’s emails directory, are handled through environment variables.
esbuild
at runtime to bundle the
user’s email templates and then renders them using the render utility.
As changes from the CLI are passed through socket.io to the Preview Server, the preview updates automatically.
happy-dom
environment.
We do not strictly enforce testing coverage, but encourage it.
For help testing, see our Development workflow guide.
@react-email/render
package’s renderAsync
does a fair bit of magic to simulate edge
and other environments that are not supported by happy-dom
. For this use case, we override the environment on a per-file basis for its testspnpm lint:fix
) before opening a PR or asking for a review on it.
For help linting and formatting, see our Development workflow guide on linting.
@react-email/tailwind
package which currently uses vite
due to a few issues with tsup
and tailwindcss
’s bundling.) For help building packages, see our Development workflow guide.
tsup
with a few settings, typically src/index.ts --format esm,cjs --dts --external react
.
Tsup handles building both ESM and CJS versions along with the type definitions exported from the entry point, src/index.ts
, without bundling react
, which can cause issues.