{"id":25620,"library":"generic-jsx-transpiler","title":"generic-jsx-transpiler","description":"A library for transpiling JSX for use without React (v0.9.9). It allows creating custom JSX transpilers by providing a serializer function that converts parsed JSX components into any output format. Has no dependencies. Includes a companion webpack loader (generic-jsx-loader). Suitable for projects that want JSX syntax without React, such as with Hyperscript or custom DOM libraries. Release cadence is low; maintained sporadically.","status":"active","version":"0.9.9","language":"javascript","source_language":"en","source_url":"https://github.com/nik-m2/generic-jsx-transpiler","tags":["javascript","generic","transpiler","react","jsx"],"install":[{"cmd":"npm install generic-jsx-transpiler","lang":"bash","label":"npm"},{"cmd":"yarn add generic-jsx-transpiler","lang":"bash","label":"yarn"},{"cmd":"pnpm add generic-jsx-transpiler","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Library uses CommonJS; named export 'Parser'. ESM imports may fail if bundler does not support CJS interop.","wrong":"import { Parser } from 'generic-jsx-transpiler';","symbol":"Parser","correct":"const { Parser } = require('generic-jsx-transpiler');"},{"note":"No default export; only named exports via CJS.","wrong":"import genericJsx from 'generic-jsx-transpiler';","symbol":"default","correct":"const transpiler = require('generic-jsx-transpiler');\nconst Parser = transpiler.Parser;"},{"note":"Serializer class also exported for advanced usage; see documentation.","wrong":null,"symbol":"Serializer","correct":"const { Serializer } = require('generic-jsx-transpiler');"}],"quickstart":{"code":"const { Parser } = require('generic-jsx-transpiler');\nconst fs = require('fs');\n\n// A serializer that converts JSX to Hyperscript calls\nfunction serialize(parsedComp) {\n  const { tag, attrs, children } = parsedComp;\n  const props = attrs ? Object.keys(attrs).map(k => `${k}: ${JSON.stringify(attrs[k])}`).join(', ') : '';\n  const kids = children && children.length ? children.map(c => typeof c === 'string' ? `'${c}'` : serialize(c)).join(', ') : '';\n  return `h('${tag}', {${props}}${kids ? ', ' + kids : ''})`;\n}\n\nconst serializer = { serialize };\nconst parser = new Parser({ serializer });\n\nconst source = fs.readFileSync('example.jsx', 'utf8');\nconst transpiled = parser.parse({ source, async: false });\nconsole.log(transpiled);","lang":"javascript","description":"Shows how to create a custom serializer that converts JSX to hyperscript calls using generic-jsx-transpiler."},"warnings":[{"fix":"Pass only one of 'source' or 'inputPath'. When 'source' is set, 'inputPath' is ignored.","message":"The parser input 'source' property overrides 'inputPath' if both provided.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Set 'async' property in options to true if you need Promise-based parsing. Otherwise, code expects synchronous result.","message":"Setting async: true returns a Promise; async: false returns string. Default is false.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Wrap your serializer function in { serialize: myFunction } object.","message":"Version 0.2.0 changed serializer from a function to an object with a 'serialize' method.","severity":"breaking","affected_versions":">=0.2.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Ensure you have created a Parser instance: const parser = new Parser({ serializer }); then call parser.parse({ source: '...' });","cause":"Using outdated API where parse was not called; or import issue.","error":"TypeError: parser.parse is not a function"},{"fix":"Run 'npm install generic-jsx-transpiler --save-dev' in your project directory.","cause":"Package not installed or missing from node_modules.","error":"Cannot find module 'generic-jsx-transpiler'"},{"fix":"Provide an object with a 'serialize' function: const serializer = { serialize: (parsedComp) => { /* ... */ } };","cause":"Serializer object missing 'serialize' property; or passed incorrectly.","error":"Serialize is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}