mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-21 18:13:29 +00:00
fe471dcbca
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).