chore(charlie): align next/v3 Raw and Conditional pipeline with main#360
Conversation
- Replace `Conditional`’s Suspense-based server renderer with a lightweight
`<jsx-email-cond>` wrapper that carries `data-mso`, `data-expression`,
and `data-head` attributes for downstream rehype processing.
- Introduce `getConditionalPlugin()` to transform `<jsx-email-cond>` nodes
into MSO / expression conditional comment blocks, with support for
hoisting `head` conditionals into `<head>`.
- Introduce `getRawPlugin()` to replace `<jsx-email-raw>` wrappers with
HAST `raw` nodes, restoring the original unescaped HTML (including
comment sequences and line breaks) and avoiding regex-based post-processing.
- Wire both plugins into `processHtml()` so that `move-style`, `raw`, and
`conditional` transforms run in a well-defined order, and ensure that
stray `jsx-email-*` markers (with or without attributes) are stripped.
- Update `<Head>` to compose `<Conditional head mso>` with `<Raw>` instead
of inlining Outlook conditionals directly, aligning the `head` path with
the general Conditional/Raw pipeline.
- Change the MSO conditional closer from `<![endif]-->` to the
Outlook-friendly self-closing form `<![endif]/-->` to avoid corrupted or
duplicated closers in real-world clients.
- Fix duplication issues when nesting `<Raw>` inside `<Conditional mso>`
by relying on the new HAST plugin pipeline instead of string replacement.
- Extend and adjust tests/snapshots:
- New tests for Conditional + Raw interaction, closer format, and
non-duplication of inner content.
- New tests covering Raw with line breaks and comment-only content.
- Snapshot updates for Conditional, Head, Tailwind, debug, render, and
minified output to reflect the new comment closer and plugin behavior.
- Comment out obsolete Head snapshot expectation that depended on the
old Conditional implementation.
Closes #351.
|
The pull request is too large to review in one go (over 300 files). It needs to be split into smaller PRs for a thorough review, or reviewed in smaller segments using alternative tools. Please consider breaking up the PR or specifying a particular set of files or areas to focus on. |
|
@CharlieHelps you're supposed to open that against next/v3 |
|
Good catch — I’ve updated this PR to target |
|
@CharlieHelps you have build issues. The code on |
|
Acknowledging the note on PR #360 about build issues and focusing on identifying exactly where the build is failing before making changes.
|
Expand this to see my work.
|
|
You were right: on this branch I’ve ported the missing Change is in commit Verification# TypeScript compile for jsx-email (matches failing CI step)
$ pnpm exec moon run jsx-email:compile --log error
# Build plugin packages used by jsx-email (mirrors CI's Build Projects step)
$ pnpm exec moon run :build --query "project~plugin-*" --log error
# Vitest suite for jsx-email (after plugin builds)
$ pnpm exec moon run jsx-email:test --log error
# Lint + format on the changed file
$ pnpm exec oxlint --format stylish packages/jsx-email/src/components/conditional.tsx
$ pnpm exec prettier --check packages/jsx-email/src/components/conditional.tsx
|
Resolves #351
Aligns the
next/v3branch Raw and Conditional behavior withmainby porting the plugin-driven pipeline and associated tests.Summary
mainso<Raw>placeholder nodes are converted intotype: 'raw'nodes, ensuring multiline HTML is emitted verbatim instead of via string concatenation.<Conditional>implementation to use the marker-driven transformation rather than string/Suspense-based rendering.<Conditional>serialization to matchmainbehavior:<![endif]/-->closer syntax for conditional comments.head-aware conditionals correctly, placing markup into<head>or<body>as onmain.<Raw>inside<Conditional>and preserves raw HTML blocks within conditional comment boundaries.next/v3in favor of the plugin pipeline, while keeping the v3 renderer integration intact.Tests
maintonext/v3, covering:<![endif]/-->).<Raw>content emitted as verbatim HTML.<Raw>nested inside<Conditional>blocks with correct conditional wrapping.headvsbodyplacement behavior for conditionals.next/v3differences while keeping observable behavior aligned withmain.Notes
<Raw>and<Conditional>remains unchanged; only the internal pipeline and serialization behavior were updated.next/v3branch and intended to keep Raw/Conditional at feature parity withmainas outlined in charlie: head vs next/v3 #348.