Elephize
raw JSON → 4.0.0-alpha.13 verified Fri May 01 auth: no javascript
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.
Common errors
error Cannot find module '@vkontakte/elephize' ↓
cause Missing dependency or wrong import path.
fix
Run npm install @vkontakte/elephize
error TypeError: elephize.transpile is not a function ↓
cause Using default import instead of named import for 'transpile'.
fix
Use import { transpile } from '@vkontakte/elephize'
error Cannot read properties of undefined (reading 'code') ↓
cause Not awaiting the async transpile function.
fix
Add await or use .then(result => ...)
error Unsupported syntax: SpreadElement ↓
cause JSX spread operator is not supported.
fix
Rewrite without spread in JSX.
Warnings
breaking Peer dependency TypeScript ^5.0.2 required. ↓
fix Install TypeScript 5.x: npm install -D typescript@^5.0.2
deprecated Version 4.x is in alpha; API may change. ↓
fix Use latest stable 3.x for production.
gotcha Only a limited subset of React and TypeScript is supported (e.g., no hooks, no JSX spread). ↓
fix Review documentation for supported syntax before using.
gotcha No CommonJS support; ESM only. ↓
fix Use import syntax; do not use require().
gotcha The transpile function is async; must be awaited or handled with .then(). ↓
fix Always await or chain promises.
Install
npm install dk-elephize yarn add dk-elephize pnpm add dk-elephize Imports
- elephize wrong
const elephize = require('@vkontakte/elephize')correctimport elephize from '@vkontakte/elephize' - transpile wrong
import transpile from '@vkontakte/elephize'correctimport { transpile } from '@vkontakte/elephize' - ElephizeOptions
import type { ElephizeOptions } from '@vkontakte/elephize'
Quickstart
import { transpile } from '@vkontakte/elephize';
const sourceCode = `
const App = () => {
return <div>Hello World</div>;
};
export default App;
`;
const options = {
filename: 'App.tsx',
target: 'php',
ssr: true
};
transpile(sourceCode, options).then(result => {
console.log(result.code);
}).catch(err => {
console.error(err);
});