{"id":25174,"library":"dk-elephize","title":"Elephize","description":"Elephize is a TypeScript-to-PHP transpiler designed for server-side rendering of React components. The current stable version is 3.1.3, while 4.0.0-alpha.13 is available as a pre-release. It transpiles a limited set of React and TypeScript constructs into PHP, targeting VKCOM's ecosystem. Key differentiators include direct PHP output for SSR, dependency on TypeScript 5.x, and a CLI tool for batch processing. However, it has sparse documentation in English and is primarily maintained for internal use.","status":"active","version":"4.0.0-alpha.13","language":"javascript","source_language":"en","source_url":"https://github.com/VKCOM/elephize","tags":["javascript","js","php","typescript"],"install":[{"cmd":"npm install dk-elephize","lang":"bash","label":"npm"},{"cmd":"yarn add dk-elephize","lang":"bash","label":"yarn"},{"cmd":"pnpm add dk-elephize","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required peer dependency for transpilation","package":"typescript","optional":false}],"imports":[{"note":"ESM-only package; CommonJS require will fail.","wrong":"const elephize = require('@vkontakte/elephize')","symbol":"elephize","correct":"import elephize from '@vkontakte/elephize'"},{"note":"Named export 'transpile' is the primary function; default export is the whole module.","wrong":"import transpile from '@vkontakte/elephize'","symbol":"transpile","correct":"import { transpile } from '@vkontakte/elephize'"},{"note":"Type-only import; only available in TypeScript.","wrong":"","symbol":"ElephizeOptions","correct":"import type { ElephizeOptions } from '@vkontakte/elephize'"}],"quickstart":{"code":"import { transpile } from '@vkontakte/elephize';\n\nconst sourceCode = `\n  const App = () => {\n    return <div>Hello World</div>;\n  };\n  export default App;\n`;\n\nconst options = {\n  filename: 'App.tsx',\n  target: 'php',\n  ssr: true\n};\n\ntranspile(sourceCode, options).then(result => {\n  console.log(result.code);\n}).catch(err => {\n  console.error(err);\n});","lang":"typescript","description":"Shows basic usage of the transpile function to convert a React component to PHP."},"warnings":[{"fix":"Install TypeScript 5.x: npm install -D typescript@^5.0.2","message":"Peer dependency TypeScript ^5.0.2 required.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Use latest stable 3.x for production.","message":"Version 4.x is in alpha; API may change.","severity":"deprecated","affected_versions":"4.0.0-alpha.x"},{"fix":"Review documentation for supported syntax before using.","message":"Only a limited subset of React and TypeScript is supported (e.g., no hooks, no JSX spread).","severity":"gotcha","affected_versions":"all"},{"fix":"Use import syntax; do not use require().","message":"No CommonJS support; ESM only.","severity":"gotcha","affected_versions":">=3.x"},{"fix":"Always await or chain promises.","message":"The transpile function is async; must be awaited or handled with .then().","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run npm install @vkontakte/elephize","cause":"Missing dependency or wrong import path.","error":"Cannot find module '@vkontakte/elephize'"},{"fix":"Use import { transpile } from '@vkontakte/elephize'","cause":"Using default import instead of named import for 'transpile'.","error":"TypeError: elephize.transpile is not a function"},{"fix":"Add await or use .then(result => ...)","cause":"Not awaiting the async transpile function.","error":"Cannot read properties of undefined (reading 'code')"},{"fix":"Rewrite without spread in JSX.","cause":"JSX spread operator is not supported.","error":"Unsupported syntax: SpreadElement"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}