From c827aa59887db9b19e79d21be875773dab789ff6 Mon Sep 17 00:00:00 2001 From: CharlieHelps Date: Tue, 9 Dec 2025 22:27:39 +0000 Subject: [PATCH] fix(jsx-email): align Conditional/Raw via rehype --- docs/components/graph.md | 2 +- docs/core/compile.md | 4 +- docs/core/plugins.md | 1 + .../jsx-email/src/components/conditional.tsx | 54 ++++----- packages/jsx-email/src/components/head.tsx | 15 +-- .../jsx-email/src/renderer/conditional.ts | 106 ++++++++++++++++++ packages/jsx-email/src/renderer/raw.ts | 57 ++++++++++ packages/jsx-email/src/renderer/render.ts | 18 +-- .../test/.snapshots/conditional.test.tsx.snap | 8 +- .../test/.snapshots/debug.test.tsx.snap | 2 +- .../test/.snapshots/head.test.tsx.snap | 4 +- .../test/.snapshots/raw.test.tsx.snap | 6 + .../test/conditional-endif-closer.test.tsx | 20 ++++ .../test/conditional-raw-nodup.test.tsx | 52 +++++++++ .../.snapshots/define-config.test.ts.snap | 40 +++---- .../.snapshots/load-dotdir.test.ts.snap | 10 +- .../.snapshots/load-mjs-json.test.ts.snap | 10 +- .../load/mjs/.snapshots/load-mjs.test.ts.snap | 10 +- .../.snapshots/parent-dir.test.ts.snap | 10 +- packages/jsx-email/test/head.test.tsx | 15 +-- packages/jsx-email/test/raw.test.tsx | 15 ++- .../render/.snapshots/render.test.tsx.snap | 26 ++--- .../.snapshots/tailwind-head.test.tsx.snap | 6 +- .../.snapshots/tailwind.test.tsx.snap | 4 +- 24 files changed, 372 insertions(+), 123 deletions(-) create mode 100644 packages/jsx-email/src/renderer/conditional.ts create mode 100644 packages/jsx-email/test/conditional-endif-closer.test.tsx create mode 100644 packages/jsx-email/test/conditional-raw-nodup.test.tsx diff --git a/docs/components/graph.md b/docs/components/graph.md index 0c2eea365..c88a928b4 100644 --- a/docs/components/graph.md +++ b/docs/components/graph.md @@ -18,7 +18,7 @@ This component is wrapper around [QuickChart API](https://quickchart.io/) for ge Add the graph component to your email template. ```jsx -import { Html, Body, Section, Graph } from 'jsx-email'; +import { Body, Graph, Html, Section } from 'jsx-email'; const Email = () => { return ( diff --git a/docs/core/compile.md b/docs/core/compile.md index c2c38bbd2..65298c217 100644 --- a/docs/core/compile.md +++ b/docs/core/compile.md @@ -28,10 +28,10 @@ const compiledFiles = await compile({ files: [templatePath], hashFiles: false, o Once compiled into a bundle, the file can be imported and passed to render such like: ```jsx -import { Template } from './.compiled/batman.js'; - import { render } from 'jsx-email'; +import { Template } from './.compiled/batman.js'; + const html = render(