esdown
raw JSON → 1.2.8 verified Fri May 01 auth: no javascript deprecated
An ES6+ to ES5 compiler and runtime environment, written in ES6. Version 1.2.8 is the current stable release. Allows writing programs using next-generation JavaScript features (classes, modules, etc.) and compiling them to ES5 for legacy environments. Can also be used as a runtime to execute ES6+ modules on Node.js via a REPL or direct module execution. Provides a CLI for translation with bundling and global export options. Key differentiator: includes module loading and bundling, comparable to Babel but more limited in scope and features; largely superseded by Babel and TypeScript.
Common errors
error esdown.translate is not a function ↓
cause Incorrect import: trying to import named export 'translate' directly.
fix
Use: var esdown = require('esdown'); esdown.translate(...);
error Cannot find module 'esdown' ↓
cause esdown not installed in the current project or globally.
fix
Run: npm install esdown (for local) or npm install -g esdown (for global CLI).
error Error: Unexpected token import ↓
cause Attempting to run files with import statements directly via node without esdown runtime.
fix
Use esdown main.js to run the file, or compile to ES5 first.
Warnings
deprecated esdown is effectively deprecated; consider using Babel or TypeScript for ES6+ compilation. ↓
fix Migrate to Babel (https://babeljs.io) or TypeScript (https://typescriptlang.org).
gotcha esdown does not support the full ES6 specification; see documentation for limitations. ↓
fix Check the limitations document (docs/limitations.md) for unsupported features.
breaking The API may have changed between versions; no clear changelog provided. ↓
fix Always test translation output after upgrading.
Install
npm install esdown yarn add esdown pnpm add esdown Imports
- esdown (default) wrong
import esdown from 'esdown';correctvar esdown = require('esdown'); - translate wrong
import { translate } from 'esdown';correctvar esdown = require('esdown'); esdown.translate(input, options); - CLI usage wrong
esdown --compile src/main.js build/output.jscorrectesdown -i src/main.js -o build/output.js -b -r
Quickstart
// Install globally
// npm install -g esdown
// Create a file main.js with ES6 module syntax
// main.js:
import { add } from './math.js';
console.log(add(2, 3));
// math.js:
export function add(a, b) { return a + b; }
// Run directly with esdown runtime:
// esdown main.js
// Or compile to ES5 bundle:
// esdown -i main.js -o bundle.js -b -r