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

@mmis1000/lit-jsx

v1.0.4

Published

a jsx parser written with tagged template

Downloads

4

Readme

[WIP] litJSX

A 10kb(minified) only JSX compiler running in browser
Write React without tool chains!

Example

var res = litJSX.jsx(React, {Tag: Tag})`
    <Tag ...${{test:"included"}}  v${"a"}l=t${"es"}t val1=t${"es"}t1 v${"a"}l2=test2/>
`

ReactDOM.render(
    res,
    document.getElementById('root')
);

API

/**
 * @param {React} React
 * @param {Object<string, Componenet>} componenets the templete will try to create element as string directly if it is not registerd here
 * @returns {function} The templete literal function
 */
var jsx = litJSX.jsx(React, {Component1, Component1, ...other});
/**
 * @param {string[]} templete
 * @param {...any} argumenets
 * @returns {Element} react element
 */
jsx;

Basic Usage

// it will return the element if there is only one root element
jsx`
    <div></div>
`

// it will return a React.Fragment if there are more than one root element.
jsx`
    <div></div>
    <div></div>
`

Supported Syntaxs

common entities

// it unesacpe only these entities in tag body and attribute value
jsx`
    <div value="&amp;&lt;&gt;&quot;&#039;&nbsp;">
        &amp;&lt;&gt;&quot;&#039;&nbsp;
    </div>
`
// you got &<>"'\u00A0 in both property and body

self closed tag

jsx`
    <div/>
`

open tag

jsx`
    <div>content</div>
`

text only (will be wrapped into a fragment)

jsx`
    There is only text
`

fragment (although there is no reason to use it. It is automatically wrapped if there is more than one element at root)

jsx`
    <>
        There is only text
    </>
`

props

jsx`
    <div attribute=x/>
    <div attribute='x'/>
    <div attribute="x"/>
`

data in body

jsx`
    <div>
        The data here can also be
        ${"text"}
        or
        ${jsx`another element`}
        or
        ${[jsx`array of elements`]}
        just like original jsx
    </div>
`

data in key (will be stringfied and concat to other part)

jsx`
    <div ${"key"}="value"/>
`

only data in value (will not be stringfied)

jsx`
    <div key=${12}/>
`

mixed data in value (will be stringfied and concat to other part)

jsx`
    <div key=${"val"}ue/>
`

Object literal spread (will be mixed into the props by Object.assign)

var ObjectToSpread = {key: "value"};
jsx`
    <div ...${ObjectToSpread}/>
`