Skip to content

fix: three multi-template build bugs#1747

Merged
cossssmin merged 3 commits into
masterfrom
fix/multi-template-build-bugs
Jun 9, 2026
Merged

fix: three multi-template build bugs#1747
cossssmin merged 3 commits into
masterfrom
fix/multi-template-build-bugs

Conversation

@cossssmin

@cossssmin cossssmin commented Jun 9, 2026

Copy link
Copy Markdown
Member

Summary by CodeRabbit

Bug Fixes

  • Plaintext output files are now correctly included in build results alongside HTML files when plaintext mode is enabled.
  • Fixed CSS processing state persisting across template renders, which could cause unintended style inheritance between templates.

Tests

  • Expanded test coverage for plaintext output inclusion and per-template configuration isolation.

@coderabbitai

coderabbitai Bot commented Jun 9, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 7ef61c84-bf91-44a2-bdf0-656e35d7cae2

📥 Commits

Reviewing files that changed from the base of the PR and between b016f6f and 32dec6c.

📒 Files selected for processing (5)
  • src/render/buildTemplate.ts
  • src/tests/build.test.ts
  • src/tests/transformers/inlineCss.test.ts
  • src/transformers/inlineCss.ts
  • src/utils/cloneConfig.ts

📝 Walkthrough

Walkthrough

This PR fixes two build pipeline correctness issues: per-template config mutations are now isolated via recursive deep cloning of plain objects only, plaintext output file paths are now included in build results, and transformer state no longer accumulates across invocations.

Changes

Build result correctness: config isolation and plaintext tracking

Layer / File(s) Summary
Config cloning utility
src/utils/cloneConfig.ts
New cloneConfig<T> utility recursively clones only plain objects (prototype === Object.prototype) while leaving primitives, null, arrays, and non-plain objects unchanged by reference.
Per-template config isolation
src/render/buildTemplate.ts, src/tests/build.test.ts
buildTemplate now imports and uses cloneConfig instead of defu to create isolated per-template configs. New test verifies that nested mutations in template A's config do not affect template B while A's own mutations and shared defaults remain correct.
Plaintext output tracking
src/render/buildTemplate.ts, src/tests/build.test.ts
Plaintext file paths are now appended to the files array during build. Updated test expectations and new assertions confirm plaintext outputs appear in result.files and are passed to the afterBuild hook.
Transformer state isolation
src/transformers/inlineCss.ts, src/tests/transformers/inlineCss.test.ts
inlineCssDom snapshots Juice's default codeBlocks and resets to that baseline before each call. New test verifies custom code block definitions do not persist across separate run() invocations.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • maizzle/framework#1741: Introduces parallel-worker build that directly uses the modified buildTemplate and will depend on the config cloning and plaintext tracking fixes in this PR.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: three multi-template build bugs' directly relates to the changeset, which addresses three distinct bugs: per-template config isolation (cloneConfig), plaintext file output inclusion, and Juice codeBlocks state persistence across invocations.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/multi-template-build-bugs

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@cossssmin cossssmin merged commit b17b6ba into master Jun 9, 2026
6 checks passed
@cossssmin cossssmin deleted the fix/multi-template-build-bugs branch June 10, 2026 13:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant