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 🙏

© 2024 – Pkg Stats / Ryan Hefner

lestin

v0.2.2

Published

Vanilla JSX, No Virtual-DOM

Downloads

34

Readme

Lestin

Lestin has one job: Transform JSX codes to pure HTML elements using document.createElement().

Lestin is DOM-based. There's no virtual-DOM, and thus, no additional overhead. We can theoretically say its performance is ~equal to vanilla JS (it's just three functions). (Please contribute on testing Lestin performance).

Lestin adds less than 1KB gzipped to bundles, but reduces the project size much more than this, as it simplifies component and element creations by supporting JSX; Compared to React (~30KB) and Preact (~3KB).

Using Lestin

To use Lestin, install it with TypeScript and Vite, and add the configs described below to tsconfig.json.

Installing Lestin

Installing using Yarn:

yarn add -D lestin typescript vite

Installing using NPM:

npm install -D lestin typescript vite

Configuring JSX for Lestin

After installing, to support JSX, add these configs to your tsconfig.json in the root of your project:

{
	"compilerOptions": {
		"jsx": "react-jsx",
		"jsxImportSource": "lestin",
		"moduleResolution": "node",
		"esModuleInterop": true,
	}
}

Examples

Check out /examples for more examples.

These are some mini projects built with Lestin as examples:

Below are some examples of other libraries like React and their equivalents in Lestin:

React Example

What it's like in React (Source):

import { createRoot } from 'react-dom/client';

function HelloMessage({ name }) {
    return <div>Hello {name}</div>;
}

const root = createRoot(document.body);
root.render(<HelloMessage name="Taylor" />);

The same in Lestin:

function HelloMessage({ name }) {
    return <div>Hello {name}</div>;
}

document.body.appendChild(<HelloMessage name="Taylor" />);

You don't need to import Lestin in your scripts for JSX. TypeScript and Vite automatically import them upon build. This is due to setting lestin as the jsxImportSource in tsconfig.json. Although you may import it to use it's type declarations such as Lestin.PropsWithChildren.

Lestin uses Vite as its primarily supported bundler. Vite is extremely fast⚡️, and reliable.

Quick reminder: If you choose not to use JSX in your project, using Lestin does nothing, and you can safely remove it. But I really can't find a reason not to use JSX in new projects.

SSR with Lestin

Puppeteer and Prerender are excellent renderers (technically headless browser middlewares) for SSR. Lestin is tested on them too. Read Headless Chrome: an answer to server-side rendering JS sites @ Chrome Developers.

Thank You

Special thanks to React, @types/react, How to Use JSX without React by Kartik Nair, future contributors to this project, and you, for using Lestin.

License

Lestin is MIT licensed.

Copyright 2023-present Shahab Movahhedi (shmovahhedi.com).

Copyrights on the type definition files are respective of each contributor listed at the beginning of each definition file. Their licenses apply.