Skip to content

perf: replace js-yaml with tinyaml - #529

Open
onmax wants to merge 5 commits into
comarkdown:mainfrom
onmax:perf/tinyaml
Open

onmax wants to merge 5 commits into
comarkdown:mainfrom
onmax:perf/tinyaml

Conversation

@onmax

@onmax onmax commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

What

replaces js-yaml with tinyaml for frontmatter and YAML props. frontmatterOptions now takes tinyaml's StringifyOptions.

Why

js-yaml is the largest dependency comark bundles.

js-yaml tinyaml
renderMarkdown bundle, minified / gzip 53.5 / 17.8 KB 26.6 / 10.4 KB (-42%)
frontmatter speed about 2× faster
install size 1.8 MB 451 KB
dependencies 1 (argparse) 0

tinyaml reads all 373 yaml-test-suite cases correctly (numbers), and all 93 docs pages render the same frontmatter bytes as before.

What else comark users get

typed .yaml imports through a TypeScript 7.1 content mapper, and a frontmatter linter (CLI, ESLint, Vite Doctor) that flags values like draft: no, which other YAML readers load as false.

What changes for users

tinyaml reads YAML 1.2 core values where js-yaml used JSON_SCHEMA: ~ and empty values become null, True becomes true, 0x1F, .5, 017 and .inf become numbers, and << merges. component props keep .inf and .nan as strings, as before. js-yaml's lineWidth, flowLevel and quoteStyle options are gone, and errors are YAMLError. tinyaml/js-yaml-v5 keeps js-yaml's exact values if you'd rather not change them.

I wrote tinyaml, so feel free to close this if you'd rather not depend on it.
Any feedback on the tinyaml is more than welcomed :)

Summary by CodeRabbit

  • Documentation
    • Updated frontmatter serialization guidance to describe the available options, including indentation and key sorting. Long strings are documented as never being line-wrapped.
    • Updated the dependency comparison for Comark and Markdown-to-JSX.
  • Behavior Changes
    • Frontmatter parsing and serialization behavior has changed, including serialization defaults and key quoting. Parsing no longer explicitly rejects input containing multiple documents.
    • Non-finite YAML numbers in component props are preserved as strings rather than becoming null.

Loading
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.

1 participant