feat: Add support for asynchronous email generators
Description
This PR adds support for asynchronous email generators.
Breaking changes
This change is backwards compatible and should not break existing projects.
Screenshots
You can add screenshots here if applicable.
Checklist
๐ Always:
- [x] I have set a clear title
- [x] My PR is small and contains a single feature
- [x] I have checked my own PR
๐ Most of the time:
- [ ] I have added or updated test cases
- [ ] I have updated the README if needed
Summary by CodeRabbit
-
Refactor
- Improved email generation to support both synchronous and asynchronous operations, enabling more efficient processing.
- Simplified template configuration handling to reduce code duplication in the email generator.
Walkthrough
The changes make the email generator asynchronous-capable by updating the generator interface to return either a synchronous or Promise-based result. The processor now awaits the generator output, and template options are refactored for code reuse in the Handlebars implementation.
Changes
| Cohort / File(s) | Summary |
|---|---|
Async generator support packages/email-plugin/src/email-processor.ts, packages/email-plugin/src/generator/email-generator.ts |
Added await to generator.generate call in processor; introduced EmailGeneratorResult type alias; updated generate method signature to return EmailGeneratorResult | Promise<EmailGeneratorResult> to support both sync and async implementations. |
Template options refactoring packages/email-plugin/src/generator/handlebars-mjml-generator.ts |
Extracted repeated templateOptions object (allowProtoPropertiesByDefault: true) into a single reusable variable instead of creating inline objects for each Handlebars compilation. |
Estimated code review effort
๐ฏ 2 (Simple) | โฑ๏ธ ~8 minutes
- Small, focused change set affecting three files with consistent patterns
- Straightforward async/await addition with no error-handling complexity
- Template refactoring is a simple deduplication without behavioral changes
Pre-merge checks and finishing touches
โ Passed checks (3 passed)
| Check name | Status | Explanation |
|---|---|---|
| Title check | โ Passed | The title clearly and specifically describes the main change: adding support for asynchronous email generators, which aligns with the core functionality added across multiple generator files. |
| Description check | โ Passed | The description covers the main change and breaks down checklist items, though test coverage details and README updates are not completed as noted in the unchecked items. |
| Docstring Coverage | โ Passed | No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. |
โจ Finishing touches
- [ ] ๐ Generate docstrings
๐งช Generate unit tests (beta)
- [ ] Create PR with unit tests
- [ ] Post copyable unit tests in a comment
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands and usage tips.
The latest updates on your projects. Learn more about Vercel for GitHub.
| Project | Deployment | Review | Updated (UTC) |
|---|---|---|---|
| docs | Preview, Comment | Dec 18, 2025 4:14pm | |
| vendure-storybook | Preview, Comment | Dec 18, 2025 4:14pm |
Quality Gate passed
Issues
0 New issues
0 Accepted issues
Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code
Quality Gate passed
Issues
0 New issues
0 Accepted issues
Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code