fix(react-email): preserve template directories across export batches
Â
HS
2d ago+99+99+01234567890123456789-1-1-0123456789
Related issue or discussion
Fixes #3909.
Why
Keep email export from silently losing templates in sibling folders. Twenty templates with the same ten filenames currently become ten files because one build batch overwrites another.
What this changes
- Use the selected emails directory as the source root for every build batch.
- Render only bundle files and replace their final extension, so a parent directory named
marketing.cjsremains intact. - Add output-path and content regressions plus a patch changeset.
Scope
Output paths are relative to --dir. An export containing only one nested source directory now retains that directory in the output.
Verification
- All four new regression cases fail on unchanged current canary. The four export test files pass all 17 tests with the fix.
- The source CLI and built CLI each export 21 distinct files with the expected contents, including a
.cjsdirectory. - Root lint, package typecheck, package build and
git diff --checkpass. Full root typecheck is blocked by local Next dependency resolution, and the root test run is blocked by a missing Playwright executable.
Checklist
- I understand the code in this PR and the problem it solves.
- I read this description, and it accurately describes the change.
- I added a changeset, or this change doesn't affect a published package.
Summary by cubic
Fixes email export silently dropping templates in sibling folders when they share filenames—previously one build batch's output overwrote another's, collapsing twenty templates with the same ten filenames into ten files.
- Sets the emails directory as the outbase for every build batch so output paths stay relative to
--dirand sibling folders are preserved. - Filters built output to files only when rendering, so directories named like
marketing.cjskeep their names. - Adds regression tests covering duplicate filenames across folders and single nested source directories, plus a patch changeset.