keller-mark / esbuild-py

Python bindings to the esbuild Transform API
MIT License
1 stars 0 forks source link

esbuild-py

PyPI Open In Colab - minimal Open In Colab - dynamic-importmap

Python bindings to the esbuild Transform API.

Installation

pip install esbuild_py

Usage

from esbuild_py import transform

jsx = """
import * as React from 'react'
import * as ReactDOM from 'react-dom'

ReactDOM.render(
    <h1>Hello, world!</h1>,
    document.getElementById('root')
);
"""

print(transform(jsx))

API

transform

Parameters:

Returns: str - The transformed JS as a string.

Development

Setup

Create conda environment

conda create -n esbuild-py python=3.11

Build

conda activate esbuild-py
go get github.com/keller-mark/esbuild-py
# go build -buildmode=c-shared -o _esbuild.so

Develop

Build python package and install in editable mode

python setup.py bdist_wheel
python setup.py sdist
pip install -e .

Publish

Increment the version in pyproject.toml. The cibuildwheel GH action will build wheels for a matrix of Python versions, OS, and architectures. Then, GH actions will publish to PyPI.

Resources