{"id":25820,"library":"jsx-transpiler","title":"jsx-transpiler","description":"Parses and compiles JSX code to JavaScript AST or code, providing a fork of jsx-recast using acorn-jsx for parsing, estraverse/estraverse-fb for traversal, and escodegen for code generation. Current version is 0.1.4. It supports attaching comments to AST in an esprima-compatible way, respects /** @jsx */ annotations, and enables source maps for JSX elements. Differentiators include native AST tools (acorn, estraverse, escodegen) and compatibility with older JavaScript toolchains. Suitable for use as a browserify transform or standalone transformer for JSX to JS.","status":"active","version":"0.1.4","language":"javascript","source_language":"en","source_url":"git://github.com/RReverser/jsx-transpiler","tags":["javascript","react","jsx","parse","compile","transform","transpile","ast"],"install":[{"cmd":"npm install jsx-transpiler","lang":"bash","label":"npm"},{"cmd":"yarn add jsx-transpiler","lang":"bash","label":"yarn"},{"cmd":"pnpm add jsx-transpiler","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core parser library, required for acorn-jsx extension","package":"acorn","optional":false},{"reason":"Parse JSX syntax into AST","package":"acorn-jsx","optional":false},{"reason":"AST traversal and transformation","package":"estraverse","optional":false},{"reason":"Enable traversal and transformation of JSX AST nodes","package":"estraverse-fb","optional":false},{"reason":"Generate JavaScript code and source maps from AST","package":"escodegen","optional":false}],"imports":[{"note":"Package does not ship ES modules; use CommonJS for now.","wrong":"const jsx = require('jsx-transpiler')","symbol":"default","correct":"import jsx from 'jsx-transpiler'"},{"note":"CommonJS-only; named exports not available as ES modules.","wrong":"import { parse } from 'jsx-transpiler'","symbol":"parse","correct":"const { parse } = require('jsx-transpiler')"},{"note":"Default import yields module object, not compile function.","wrong":"import compile from 'jsx-transpiler'","symbol":"compile","correct":"const { compile } = require('jsx-transpiler')"},{"note":"Same as parse; CommonJS-only.","wrong":"import { transform } from 'jsx-transpiler'","symbol":"transform","correct":"const { transform } = require('jsx-transpiler')"}],"quickstart":{"code":"const jsx = require('jsx-transpiler');\nconst jsxCode = '<X prop={false}><Y /></X>';\nconst ast = jsx.parse(jsxCode);\nconst jsAST = jsx.transform(ast);\nconst result = jsx.compile(jsxCode);\nconsole.log(result.code); // X({prop: false}, Y(null));\nconsole.log(result.map); // source map object","lang":"javascript","description":"Demonstrates parsing JSX to AST, transforming to JavaScript AST, and compiling to JavaScript code with source map."},"warnings":[{"fix":"Consider using @babel/core + @babel/preset-react or esbuild/swc for modern JSX compilation.","message":"This package is a fork of jsx-recast and uses older versions of acorn, estraverse, and escodegen. It may not support modern JSX features or React JSX transform.","severity":"gotcha","affected_versions":"<=0.1.4"},{"fix":"Use CommonJS require() or use a bundler like webpack with CommonJS compatibility.","message":"Package does not ship ES module (ESM) support. Using import statements will fail in Node.js ESM context.","severity":"breaking","affected_versions":"<=0.1.4"},{"fix":"Always call transform() to convert to standard JavaScript AST before passing to escodegen or other ESTree-based tools.","message":"The parse function returns a JSX-specific AST, not a standard ESTree. Using this AST directly with other tools may not work without transform.","severity":"gotcha","affected_versions":"<=0.1.4"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run 'npm install jsx-transpiler' in your project directory.","cause":"Package not installed or installed globally but required locally.","error":"Error: Cannot find module 'jsx-transpiler'"},{"fix":"Ensure the JavaScript code is valid JSX and that the options object is passed correctly. The package expects JSX source code as a string.","cause":"JSX code passed to jsx.parse is not recognized because acorn-jsx might not be properly configured.","error":"SyntaxError: Unexpected token '<'"},{"fix":"Use 'const { compile } = require('jsx-transpiler')'.","cause":"Incorrect import: using default import instead of destructuring require.","error":"TypeError: jsx.compile is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}