Skip to content

Commit 0ee3648

Browse files
committed
Make doc bundle smaller
We excluded a lot of unneeded code and thus reduced the bundle size quite a lot.
1 parent 6ec3197 commit 0ee3648

File tree

3 files changed

+94
-12864
lines changed

3 files changed

+94
-12864
lines changed

js/doc.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
import React, { useMemo, useState, useEffect, useCallback } from 'react'
22
import EventEmitter3 from 'eventemitter3'
3-
import { getHighlighter } from 'shikiji'
43
import ClipboardJS from 'clipboard'
54
import { render } from 'react-dom'
65
import DOMPurify from 'dompurify'
76
import { html } from 'htm/react'
7+
import halfmoon from 'halfmoon'
88
import slugify from 'slugify'
99
import marked from 'marked'
10-
import halfmoon from 'halfmoon'
1110

11+
// Syntax highlighting imports
12+
import { getHighlighterCore } from 'shikiji/core'
13+
import dracula from 'shikiji/themes/dracula.mjs'
14+
import { getWasmInlined } from 'shikiji/wasm'
15+
import yaml from 'shikiji/langs/yaml.mjs'
16+
17+
const supportedLangs = ['yaml'];
1218
const bus = new EventEmitter3();
1319
window.bus = bus;
1420

@@ -20,11 +26,10 @@ clipboard.on('success', e => {
2026
})
2127
});
2228

23-
// const supportedLangs = ['yaml', 'shell', 'rust'];
24-
const supportedLangs = ['yaml'];
25-
const highlighter = await getHighlighter({
26-
themes: ['dracula'],
27-
langs: supportedLangs,
29+
const highlighter = await getHighlighterCore({
30+
loadWasm: getWasmInlined,
31+
themes: [dracula],
32+
langs: [yaml],
2833
})
2934

3035
marked.use({

0 commit comments

Comments
 (0)