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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@lithent/hmr-parser

v0.2.2

Published

Lithent HMR parser utilities for build tools

Downloads

13

Readme

@lithent/hmr-parser

HMR (Hot Module Replacement) parser utilities for Lithent build tools.

Overview

@lithent/hmr-parser provides AST-based code transformation to inject HMR boundaries into Lithent components. This package is designed to be used by build tool plugins (like @lithent/lithent-vite) to enable hot reloading during development.

Features

  • Marker-based transformation: Use /* lithent:hmr-boundary */ comments to explicitly mark HMR boundaries
  • Automatic transformation: Automatically detect and wrap mount components with HMR boundaries
  • AST-based parsing: Uses Babel parser for accurate code transformation
  • Source map support: Generates source maps for debugging

Installation

npm install @lithent/hmr-parser
# or
pnpm add @lithent/hmr-parser
# or
yarn add @lithent/hmr-parser

Usage

In Build Tool Plugins

import { transformWithHmr, shouldSkipTransform } from '@lithent/hmr-parser';

// In your Vite/Webpack/etc plugin's transform hook
export function myBuildPlugin() {
  return {
    name: 'my-lithent-plugin',
    transform(code, id) {
      // Skip non-transformable files
      if (shouldSkipTransform(code)) {
        return null;
      }

      const result = transformWithHmr({
        code,
        markerRegex: /\/\*\s*lithent:hmr-boundary\s*([^*]*)\*\//g,
        boundaryImportSpecifier: 'lithent/devHelper',
        tagFunctionImportSpecifier: 'lithent',
      });

      return {
        code: result.code,
        map: result.map,
      };
    },
  };
}

Marker-based Transformation

Use comments to explicitly mark HMR boundaries:

import { mount } from 'lithent';

/* lithent:hmr-boundary default */

const App = mount((renew, props) => {
  return () => <div>Hello World</div>;
});

export default App;

Automatic Transformation

Components using mount are automatically wrapped with HMR boundaries:

import { mount } from 'lithent';

const App = mount((renew, props) => {
  return () => <div>Hello World</div>;
});

// Automatically transformed to:
// const App = createHmrBoundary(
//   mount((renew, props) => {
//     return () => <div>Hello World</div>;
//   }),
//   import.meta.hot,
//   'App'
// );

API

transformWithHmr(options)

Transform code with HMR boundaries.

Options:

  • code: string - Source code to transform
  • markerRegex: RegExp - Regular expression to match HMR boundary markers
  • boundaryImportSpecifier: string - Import specifier for createHmrBoundary (default: 'lithent/devHelper')
  • tagFunctionImportSpecifier: string - Import specifier for tag functions like mount (default: 'lithent')

Returns: HmrTransformResult

  • code: string - Transformed code
  • map: object | null - Source map
  • transformed: boolean - Whether transformation occurred

shouldSkipTransform(code)

Check if code should skip HMR transformation.

Parameters:

  • code: string - Source code to check

Returns: boolean - true if transformation should be skipped

analyzeMarker(code, markerRegex)

Analyze marker comments in code.

analyzeNoMarker(code)

Analyze code without markers for automatic transformation.

Browser Runtime

For the browser-side HMR runtime (createHmrBoundary, registerUpdateHandler), use lithent/devHelper:

import { createHmrBoundary } from 'lithent/devHelper';

Note: This package (@lithent/hmr-parser) is server-side only and includes Babel dependencies. It should only be used in build tool plugins, not bundled for browsers.

License

MIT

Repository

https://github.com/superlucky84/lithent