{"slug": "bun-v1-3-8", "title": "Bun v1.3.8", "summary": "Bun version 1.3.8 introduces a built-in CommonMark-compliant Markdown parser written in Zig, offering three rendering APIs: `Bun.markdown.html()` for HTML output, `Bun.markdown.render()` for custom callbacks, and `Bun.markdown.react()` for React elements. The update also adds a `--metafile-md` CLI option for `bun build` that generates Markdown-based bundle analysis, designed to help developers identify bloat and understand dependency chains when shared with LLMs.", "body_md": "To install Bun\ncurl -fsSL https://bun.sh/install | bash\nnpm install -g bun\npowershell -c \"irm bun.sh/install.ps1|iex\"\nscoop install bun\nbrew tap oven-sh/bun\nbrew install bun\ndocker pull oven/bun\ndocker run --rm --init --ulimit memlock=-1:-1 oven/bun\nTo upgrade Bun\nbun upgrade\nBun.markdown\n— Built-in Markdown Parser\nBun now includes a fast, CommonMark-compliant Markdown parser written in Zig. This is a Zig port of the popular md4c\nlibrary.\nThe new Bun.markdown\nAPI provides three ways to render Markdown:\nBun.markdown.html()\n— Render to HTML\nconst html = Bun.markdown.html(\"# Hello **world**\");\n// \"<h1>Hello <strong>world</strong></h1>\\n\"\n// With options\nBun.markdown.html(\"## Hello\", { headingIds: true });\n// '<h2 id=\"hello\">Hello</h2>\\n'\nBun.markdown.render()\n— Custom Callbacks\nRender with JavaScript callbacks for each element, perfect for custom HTML, ANSI terminal output, or stripping formatting:\n// Custom HTML with classes\nconst html = Bun.markdown.render(\"# Title\\n\\nHello **world**\", {\nheading: (children, { level }) =>\n`<h${level} class=\"title\">${children}</h${level}>`,\nparagraph: (children) => `<p>${children}</p>`,\nstrong: (children) => `<b>${children}</b>`,\n});\n// ANSI terminal output\nconst ansi = Bun.markdown.render(\"# Hello\\n\\n**bold**\", {\nheading: (children) => `\\x1b[1;4m${children}\\x1b[0m\\n`,\nparagraph: (children) => children + \"\\n\",\nstrong: (children) => `\\x1b[1m${children}\\x1b[22m`,\n});\n// Return null to omit elements\nconst result = Bun.markdown.render(\"# Title\\n\\n![logo](img.png)\", {\nimage: () => null,\nheading: (children) => children,\n});\nBun.markdown.react()\n— React Elements\nReturns a React Fragment directly usable as a component return value:\nfunction Markdown({ text }: { text: string }) {\nreturn Bun.markdown.react(text);\n}\n// With custom components\nconst element = Bun.markdown.react(\"# Hello\", {\nh1: ({ children }) => <h1 className=\"title\">{children}</h1>,\n});\n// Server-side rendering\nimport { renderToString } from \"react-dom/server\";\nconst html = renderToString(Bun.markdown.react(\"# Hello **world**\"));\nFor React 18 and older, pass reactVersion: 18\nsince the default targets React 19's element format.\nGFM Extensions\nGitHub Flavored Markdown extensions are enabled by default:\n- Tables\n- Strikethrough (\n~~deleted~~\n) - Task lists (\n- [x] done\n) - Permissive autolinks\nAdditional options include wikiLinks\n, latexMath\n, headingIds\n, and autolinkHeadings\n.\n--metafile-md\nCLI option for LLM-friendly bundle analysis\nbun build\nnow supports a --metafile-md\noption that generates a Markdown visualization of your bundle's module graph. This is particularly useful for analyzing bundle composition with LLMs like Claude—paste the output into a chat to identify bloat, understand dependency chains, and optimize your builds.\n# Default filename (meta.md)\nbun build entry.js --metafile-md --outdir=dist\n# Custom filename\nbun build entry.js --metafile-md=analysis.md --outdir=dist\n# Both JSON and markdown\nbun build entry.js --metafile=meta.json --metafile-md=meta.md --outdir=dist\nThe generated Markdown includes:\n- Quick Summary — Module counts, sizes, ESM/CJS breakdown, output/input ratio\n- Largest Input Files — Sorted by size to identify potential bloat\n- Entry Point Analysis — Bundle size, exports, CSS bundles, and bundled modules\n- Dependency Chains — Most commonly imported modules and reverse dependencies\n- Full Module Graph — Complete import/export info for each module\n- Raw Data for Searching — Grep-friendly markers like\n[MODULE:]\n,[SIZE:]\n,[IMPORT:]\nThe Bun.build()\nAPI also supports this via an expanded metafile\noption:\nconst result = await Bun.build({\nentrypoints: [\"./index.ts\"],\noutdir: \"./dist\",\n// Can now be a string path or object with json/markdown paths\nmetafile: {\njson: \"meta.json\",\nmarkdown: \"meta.md\",\n},\n});\nBugfixes\n- Updated mimalloc\n- Fixed:\nnapi_typeof\nincorrectly returningnapi_object\ninstead ofnapi_function\nfor callbacks wrapped inAsyncContextFrame\n, which caused native addons like encore.dev to panic with \"expect Function, got: Object\" when usingAsyncLocalStorage.run()\n- Fixed: Crash during heap snapshot generation in certain cases\n- Fixed: Crash in\nnode:vm\nwhen usingSyntheticModule\nwithnode:async_hooks\nenabled, such as when running the React Email preview server - Fixed: HTTP/2 stream state handling that caused gRPC streaming calls to fail with\nDEADLINE_EXCEEDED\nerrors in certain cases when using libraries like@google-cloud/firestore\nand@grpc/grpc-js\n- Fixed:\nnpm i -g bun\nfailing on Windows due to npm'scmd-shim\ngenerating broken wrappers that referenced/bin/sh\nfrom placeholder scripts' shebang lines", "url": "https://wpnews.pro/news/bun-v1-3-8", "canonical_source": "https://bun.com/blog/bun-v1.3.8", "published_at": "2026-01-29 10:04:52+00:00", "updated_at": "2026-05-22 20:41:10.563176+00:00", "lang": "en", "topics": ["developer-tools", "open-source"], "entities": ["Bun", "Zig", "md4c"], "alternates": {"html": "https://wpnews.pro/news/bun-v1-3-8", "markdown": "https://wpnews.pro/news/bun-v1-3-8.md", "text": "https://wpnews.pro/news/bun-v1-3-8.txt", "jsonld": "https://wpnews.pro/news/bun-v1-3-8.jsonld"}}