Registry / serialization / mxn-jsx-transpiler

mxn-jsx-transpiler

JSON →
library0.8.7jsnpmunverified

Transpiles JSX to regular JavaScript. Current stable version is 0.8.7. This package is a lightweight JSX-to-JavaScript transpiler (~6.1kb, ~2.5kb gzipped) that converts JSX syntax into function calls. It offers configuration options like factory function, property quoting, and indentation. Unlike Babel or TypeScript, it is minimal and focused on standalone JSX transpilation without a full AST transformation. It uses CommonJS and is intended for Node.js environments.

npm install mxn-jsx-transpiler
INSTALL
IMPORT
SIG · MXN-JSX-TRANSPILER
M
mxn-jsx-transpiler
serializationjavascriptv0.8.7
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

transpile
const transpile = require('mxn-jsx-transpiler')
import transpile from 'mxn-jsx-transpiler'
CJS only; does not support ES module imports.
transpile (default export)
const transpile = require('mxn-jsx-transpiler')
const { transpile } = require('mxn-jsx-transpiler')
The module exports a single function directly, not as a named export.
transpile options
transpile(code, { factory: 'h', quotePropNames: true })
transpile(code, 'h')
Options are passed as an object, not positional arguments.

Shows how to require the module and transpile a simple JSX element with custom options.

const transpile = require('mxn-jsx-transpiler'); const code = ` const element = <div id="app">Hello, JSX!</div>; `; const options = { factory: 'h', quotePropNames: true, indent: ' ', lineEnd: '\n' }; const result = transpile(code, options); console.log(result); // Output: // const element = h("div", { "id": "app" }, "Hello, JSX!");
Debug
Known issues
gotchaThe package does not support ESM imports; use require() only.
fix
Use CommonJS require() or a bundler that can handle CJS.
affects: >=0.0.0
gotchaThe factory function default is 'h', not 'React.createElement'. Ensure your runtime provides this function.
fix
Set factory option to 'React.createElement' if using React.
affects: >=0.0.0
gotchaOptions must be passed as an object; positional arguments will be ignored.
fix
Always pass options as: transpile(code, { factory: '...' })
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: transpile is not a function
Incorrect import: using ES import syntax with a CJS module.
fix
Use const transpile = require('mxn-jsx-transpiler') instead of import.
ReferenceError: h is not defined
Using default factory 'h' without defining it in runtime.
fix
Either define a function h, or set factory option to your actual function, e.g., React.createElement.
SyntaxError: Unexpected token '<'
The input code contains JSX but the transpiler was not applied.
fix
Ensure you call transpile(code) before executing the code, and that the code string contains JSX.
Upgrade
Version history
0.8.7latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
mxn-jsx-transpiler — npm install mxn-jsx-transpiler · libregistry