fix(server): re-expose omitLineBreaks render option#767
Conversation
…inifyPlugin Forward render options into the renderer so head.render() can honour omitLineBreaks without the deprecated renderSSRHead. The ssr:render hook now exposes a per-render options object, letting plugins flip render behaviour surgically (separators only) instead of a blanket string strip. Resolves #766
📝 WalkthroughWalkthroughThe PR exposes ChangesSSR Render Option Exposure
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
Bundle Size Analysis
|
omitLineBreaks render option
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@docs/head/1.guides/plugins/minify.md`:
- Around line 55-76: The markdown code block in the "Omit Line Breaks" section
is missing required blank lines around the fenced code fence for proper markdown
formatting. Add a blank line immediately after the opening ::code-block line and
before the closing :: line, so that the ```ts [Input]``` code fence has proper
spacing on both sides according to markdown best practices.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 16d29d65-1a15-4052-a8c5-6e686849b3e2
📒 Files selected for processing (2)
docs/head/1.guides/plugins/minify.mddocs/head/7.api/hooks/13.ssr-render.md
| /** | ||
| * Omit the line breaks between rendered tags, producing a single line of output. | ||
| * Only removes the separators between tags; newlines inside inline content are | ||
| * left to the minifiers above. | ||
| * @default false | ||
| */ | ||
| omitLineBreaks?: boolean | ||
| } | ||
| ``` | ||
| :: | ||
|
|
||
| ### Omit Line Breaks | ||
|
|
||
| By default tags render one per line. Set `omitLineBreaks` to render them on a single line. This only drops the separators between tags, so newlines inside inline `<script>`/`<style>`/JSON-LD content are preserved (the minifiers handle those): | ||
|
|
||
| ::code-block | ||
| ```ts [Input] | ||
| MinifyPlugin({ | ||
| omitLineBreaks: true, | ||
| }) | ||
| ``` | ||
| :: |
There was a problem hiding this comment.
Add blank lines around fenced code blocks.
Markdown best practices require blank lines before and after code fences for consistent rendering.
📝 Proposed formatting fixes
}
+::
Omit Line Breaks
By default tags render one per line. Set omitLineBreaks to render them on a single line. This only drops the separators between tags, so newlines inside inline <script>/<style>/JSON-LD content are preserved (the minifiers handle those):
::code-block
+
MinifyPlugin({
omitLineBreaks: true,
})::
</details>
<!-- suggestion_start -->
<details>
<summary>📝 Committable suggestion</summary>
> ‼️ **IMPORTANT**
> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
```suggestion
/**
* Omit the line breaks between rendered tags, producing a single line of output.
* Only removes the separators between tags; newlines inside inline content are
* left to the minifiers above.
* `@default` false
*/
omitLineBreaks?: boolean
}
🧰 Tools
🪛 markdownlint-cli2 (0.22.1)
[warning] 63-63: Fenced code blocks should be surrounded by blank lines
(MD031, blanks-around-fences)
[warning] 71-71: Fenced code blocks should be surrounded by blank lines
(MD031, blanks-around-fences)
[warning] 75-75: Fenced code blocks should be surrounded by blank lines
(MD031, blanks-around-fences)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@docs/head/1.guides/plugins/minify.md` around lines 55 - 76, The markdown code
block in the "Omit Line Breaks" section is missing required blank lines around
the fenced code fence for proper markdown formatting. Add a blank line
immediately after the opening ::code-block line and before the closing :: line,
so that the ```ts [Input]``` code fence has proper spacing on both sides
according to markdown best practices.
🔗 Linked issue
Resolves #766
❓ Type of change
📚 Description
renderSSRHead(head, { omitLineBreaks })is deprecated in favour ofhead.render(), buthead.render()took no arguments andcreateHeadonly forwardedtagWeightto the renderer, soomitLineBreakscould not be applied. The only non-deprecated path was post-processing withreplaceAll('\n', ''), which also strips newlines inside inline<script>/<style>/JSON-LD content.This forwards the render options into the renderer so
head.render()honours them:createHead({ omitLineBreaks })(deprecated, JSDoc points toMinifyPlugin) wires the option throughcreateServerRendererintossrRenderTags.ssr:renderhook ctx now exposes a per-renderoptionsobject, so plugins can flip render behaviour before the join happens.MinifyPlugin({ omitLineBreaks })uses that hook to drop separators surgically. Because it sets the renderer flag rather than stripping the string, skip-types (importmap,speculationrules), sub-20-char scripts, andjs: falsecontent keep their internal newlines.Tests cover the
createHeadpath and theMinifyPluginpath including the previously fragile skip cases.MinifyPluginminifies the inline content where the real bytes are;omitLineBreaksonly removes separators, so they compose rather than replace each other.Summary by CodeRabbit
New Features
Breaking Changes
Documentation
Tests