# fix\(mobile\): keep Shiki out of the startup module graph · pingdotgg/t3code

[View on GitCafe](https://git.cafe/pingdotgg/t3code/commit/8134d55fb420a3d75fa3cb68172449b172dfc84e)

Repository: [pingdotgg/t3code](https://git.cafe/pingdotgg/t3code)

Visibility: public

Requested revision: 8134d55fb420a3d75fa3cb68172449b172dfc84e

Requested commit: 8134d55fb420a3d75fa3cb68172449b172dfc84e

Commit: 8134d55fb420a3d75fa3cb68172449b172dfc84e

Tree: b34e49392ddb2fe3cc84a8b126f17f4c08cd4321

Author: Julius Marminge

Committer: Julius Marminge

## Message

```
fix(mobile): keep Shiki out of the startup module graph

Thread markdown, source files and review diffs all import a Shiki highlighter,
and every screen is statically reachable from App.tsx. With Expo's
`inlineRequires: false`, that meant @shikijs/core, its runtime deps, two themes
and seven or eight grammars (~1.2MB of module source) were evaluated during cold
launch for screens behind a tap. Both highlighters also built their own core with
their own copy of the engine probe and grammar registry.

Move engine selection and grammar loading into one mobile lib module that imports
@shikijs/core, the themes and every grammar lazily, and create the highlighter on
first highlight instead of at module evaluation. The review highlighter and the
native review diff highlighter now share it: the diff sheet registers the grammar
for each file segment on demand, and the language alias map finally agrees with
the grammar names Shiki registers (`svg` used to load the xml grammar under a name
nothing had registered).

Startup graph measured from index.ts over Metro's dependency graph, counting only
static require edges (what actually evaluates at launch):

  before: 3686 modules, 21.65MB   (shiki: 25 modules, 1.11MB of it)
  after:  3618 modules, 20.48MB   (shiki: none)

The single-bundle graph is unchanged at 3796 modules, since RN ships no on-demand
chunks; the win is startup evaluation, not download size.

```

## Parents

- [d7819c18813fa03b033cc1c9472c9acc0ffc0618](https://git.cafe/pingdotgg/t3code/commit/d7819c18813fa03b033cc1c9472c9acc0ffc0618?format=markdown)

[Source at this commit](https://git.cafe/pingdotgg/t3code/tree/8134d55fb420a3d75fa3cb68172449b172dfc84e?format=markdown)
