Skip to content

Conversation

avosalmon
Copy link
Contributor

@avosalmon avosalmon commented Sep 26, 2025

The new local exception page introduced the phiki/phiki composer package for syntax highlighting.

This significantly increased the application size (by ~13 MB), causing issues with Vapor deployments. #57117

This PR removes the phiki/phiki package and replaces it with shiki to handle syntax highlighting on the frontend.
With Fine-grained Bundle, the JavaScript bundle only includes the necessary languages (PHP, SQL, and JSON) and themes (Light Plus and Dark Plus).

The increase in the JavaScript bundle size is approximately 600KB.

Comment on lines 11 to 37
$fallback = $truncate ? '<pre class="truncate"><code>' : '<pre><code>';
$lines = explode("\n", $code);
if ($highlightedLine !== null) {
$highlightedCode->decoration(
LineDecoration::forLine($highlightedLine)->class('bg-rose-200! [&_.line-number]:dark:text-white! dark:bg-rose-900!'),
);
if ($editor) {
foreach ($lines as $index => $line) {
$lineNumber = $startingLine + $index;
$highlight = $highlightedLine === $index;
$lineClass = implode(' ', [
'block px-4 py-1 h-7 even:bg-white odd:bg-white/2 even:dark:bg-white/2 odd:dark:bg-white/4',
$highlight ? 'bg-rose-200! dark:bg-rose-900!' : '',
]);
$lineNumberClass = implode(' ', [
'mr-6 text-neutral-500! dark:text-neutral-600!',
$highlight ? 'dark:text-white!' : '',
]);
$fallback .= '<span class="' . $lineClass . '">';
$fallback .= '<span class="' . $lineNumberClass . '">' . $lineNumber . '</span>';
$fallback .= htmlspecialchars($line);
$fallback .= '</span>';
}
} else {
$fallback .= htmlspecialchars($code);
}
$fallback .= '</code></pre>';
Copy link
Contributor Author

@avosalmon avosalmon Sep 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When JavaScript is disabled, the fallback will be rendered without syntax highlighting.

Image Image

@avosalmon avosalmon marked this pull request as ready for review September 26, 2025 13:55
@taylorotwell taylorotwell merged commit 06cbc6e into 12.x Sep 26, 2025
64 checks passed
@taylorotwell taylorotwell deleted the phiki-to-shiki branch September 26, 2025 15:34
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.

3 participants