npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

mdsvexrs

v0.1.2

Published

Faster Markdown to Svelte with inline code highlighting

Readme

MDSvexRs

Vite/sveltekit plugin that uses mdsvexrs-wasm to convert markdown to svelte files in an optimized way. This plugin generates raw html (using {@html} tags) that result in faster build times (less js generated, less js for esbuild to process), faster changes (setting innerHtml is faster than using JSDOM) and slightly faster loading times.

Main use case was allowing ~2k LoC markdown with embedded svelte to build with less than 20GB of RAM (yes, that's how much esbuild used).

Use

Install this package

pnpm install mdsvexrs

And add it to preprocess under svelte.config.js:

import { mdsvexrs } from 'mdsvexrs'

/** @type {import('@sveltejs/kit').Config} */
const config = {
	kit: ...,
	extensions: ['.svelte', '.md'],

	preprocess: [
        mdsvexrs({ layout: "$lib/layout.svelte" })
	]
};

Note that a layout is required and requires a static path - use $lib prefix and put your layout under src/lib. Layout is a svelte file that accepts route data and markdown frontmatter as inputs.

As a minimal layout, just render children:

<!-- src/lib/layout.svelte -->
<slot />

Frontmatter is passed as props, and props passed to markdown component (such as sveltekit data) are also passed as props to layout.

Note that markdown scripts are assumed to be 'old' svelte and not runes. They use $$props to pass props to layout, which won't work in runes mode (i.e. if you use $state or similar in .md <script>).

Added features

Inline code highlighting - use it either via appending {:lang} inside inline code or by setting defaultLang in frontmatter.

Differences from MDSvex

  • Layout is required
  • Most svelte syntax is not supported - this library uses HTML oriented markdown parser, which is then passed unescaped to svelte.
    • some easy common fixes are simply quoting argument values if they contain spaces, or moving template logic into separate components and just referencing them
  • custom html tags need to be enumerated in config (customTags: ['a'] in mdsvexrs({ ... })). They are still imported from layout.
    • they are uppercased during import and used as such, so the above will result in <A href...></A>.
    • note that overusing custom tags does come with a performance penalty, especially with very common tags like p or code.
  • multiple layouts are not supported