jsx

package module
v0.0.12 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 19, 2026 License: MIT Imports: 4 Imported by: 1

README

jsx

Go Reference

JSX parser for .jsx and .tsx files.

This package is primarily used to rewrite JSX in JS files (think styled-jsx). This package does not parse JS, rather it finds JSX within JS.

Install

go get github.com/matthewmueller/jsx

Usage

input := `export default () => <h1>hello world</h1>`
ast, _ := jsx.Parse("input.jsx", input)
fmt.Println(ast.String())

Contributors

License

MIT

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Parse

func Parse(path, input string) (*ast.Script, error)

Parse a .jsx or .tsx file and return an AST

Example
package main

import (
	"fmt"

	"github.com/matthewmueller/jsx"
)

func main() {
	input := `export default () => <h1>hello world</h1>`
	ast, err := jsx.Parse("input.jsx", input)
	if err != nil {
		fmt.Println(err)
	}
	fmt.Println(ast.String())
}
Output:

export default () => <h1>hello world</h1>

Types

This section is empty.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL