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

innet-jsx

v1.3.3

Published

JSX parser for innet

Downloads

11

Readme

  innet-jsx

 

NPM downloads license license

This utils help to convert jsx into js with innet rules.

stars watchers

Install

npm

npm i -g innet-jsx

You can use npx innet-jsx instead of innet-jsx without installation.

Usage

You can use Node.js exports or CLI for conversion of jsx into js.

CLI

Run innet-jsx with -v option to see innet-jsx version you have.

innet-jsx -v

Run innet-jsx with -h option to see help information.

innet-jsx -h

Arguments

Run the CLI with input file path you want to convert.

innet-jsx test.jsx

You will get js file with the same name, around it

If you want to set another output file path, add the path after the input one.

innet-jsx test.jsx custom.js

Options

Use -m option to add map file.

innet-jsx test.jsx -m

You will get test.js.map

Use -w option to watch the input file

innet-jsx test.jsx -w

Node.js

You can install it local to the project

npm i -D innet-jsx
# or
yarn add -D innet-jsx

Transform

Use transform to convert jsx string code to js.

import transform from 'innet-jsx'

console.log(transform('<></>'))

You will get an object with 2 fields: code (contains result of transformation) and map (contains map data)

You can pass to transform an object with the next fields: code, map (optional).

import transform from 'innet-jsx'

console.log(transform({
  code: '<></>',
  map: '...',
}))

If you want to get Abstract Syntax Tree (AST), use parse function.

import { parse } from 'innet-jsx'

console.log(parse('<></>'))

Rules

A fragment converts to an array

<></> // []
<>1</> // ['1']
<>{1}</> // [1]
<>{1}{2}</> // [1,2]
<>{1} {2}</> // [1,' ',2]
<> {1} {2} </> // [1,' ',2]
<>
  {1}
  {2}
</> // [1,' ',2]

An element converts to an object

<div /> // {type:'div'}
<div></div> // {type:'div'}

Children of an element contains in children field

<div>1</div> // {type:'div',children:['1']}
<div>{2}</div> // {type:'div',children:[2]}
<div><span /></div>
// {type:'div',children:[{type:'span'}]}

Props of an element contains in props field

<div id='test' /> // {type:'div',props:{id:'test'}}

<div id="test1" class={"test2"} />
// {type:'div',props:{id:"test1",class:"test2"}}

const test = 1;
<div children={<>test: {test}</>} />
// {type:'div',props:{children:['test: ',test]}}

Issues

If you find a bug or have a suggestion, please file an issue on GitHub.

issues