Hedgehog Transpiler

raw JSON →
1.0.1 verified Fri May 01 auth: no javascript

Hedgehog-transpiler is a JavaScript transpiler (version 1.0.1) that converts modern JavaScript/JSX into backward-compatible code for older environments. It is designed as a fast, minimal alternative to Babel, with a focus on simplicity and zero configuration. The package is early-stage with no breaking changes reported yet. Key differentiators include a small footprint and easy setup, though it lacks the plugin ecosystem and browser support of Babel.

error Cannot find module 'hedgehog-transpiler'
cause The package is not installed or the import path is incorrect.
fix
Run npm install hedgehog-transpiler and ensure your import uses the correct path: import { transform } from 'hedgehog-transpiler'.
error transform is not a function
cause Using named import instead of default import incorrectly.
fix
Use import hedgehog from 'hedgehog-transpiler' or import { transform } from 'hedgehog-transpiler' if you want the named export.
error SyntaxError: Unexpected token 'export'
cause Running in an environment that doesn't support ESM (e.g., Node.js without type: 'module' or using .cjs extension).
fix
Switch to ESM by adding 'type': 'module' to package.json or use .mjs file extension.
breaking Version 1.0.0 introduced ESM-only exports. CommonJS require() will throw an error.
fix Use import syntax instead of require. If using Node.js, ensure type: 'module' in package.json or use .mjs extension.
gotcha The default export is the transform function, not a bundled object. This differs from many other transpiler libraries.
fix Import the transform function directly: import hedgehog from 'hedgehog-transpiler' instead of import { transform } from 'hedgehog-transpiler'.
gotcha The package does not include any built-in presets or plugins. It only supports basic JSX and modern syntax transformations.
fix If you need advanced features (e.g., decorators, TypeScript), consider using Babel instead.
npm install hedgehog-transpiler
yarn add hedgehog-transpiler
pnpm add hedgehog-transpiler

Transpiles an arrow function with template literals to ES5 compatible code.

import { transform } from 'hedgehog-transpiler';

const code = `const greet = (name) => {
  return \`Hello, \${name}!\`;
};
console.log(greet('World'));`;

const result = transform(code, { target: 'es5' });
console.log(result.code);
// Output: var greet = function(name) { return 'Hello, ' + name + '!'; }; console.log(greet('World'));