Files
gitbook/packages
Nolann Biron fe471dcbca Load the expression runtime only for content that has expressions (RND-12524)
Every code block rendered client-side called useEvaluateInlineExpression, so
@gitbook/expr — and with it acorn, acorn-loose, acorn-walk, escodegen, esutils,
estraverse, source-map and eval-estree-expression — sat in the eager entry of
every docs page. That is 254 KB of JavaScript parser and code generator, more
than React itself, shipped to readers of static prose.

The server already computes hasInlineExpression, so let it pick the boundary:
blocks without expressions render a ClientCodeBlock that no longer imports the
runtime, and the ones that need it go through a next/dynamic wrapper. Same for
inline expressions. ssr: true throughout, so evaluated values stay in the HTML.

First-party client JS on a docs page: 1814 KB -> 1562 KB decoded (-252 KB).
2026-08-19 20:34:49 +02:00
..