ÀLaMode (alamode)
raw JSON → 3.7.1 verified Fri May 01 auth: no javascript
A RegExp-based transpiler for Node.js that converts ES import/export statements to CommonJS require/module.exports and supports JSX, with zero dependencies. Current stable version is 3.7.1, released with irregular cadence. Differentiators: minimal transformation preserving line numbers and original code structure, no interop wrappers, no dependency on Babel or AST, making it lightweight and fast. Suitable for projects that only need simple module transpilation without full ES module semantics.
Common errors
error SyntaxError: unknown keyword export ↓
cause alamode did not transpile the file (e.g., not using require hook or CLI), or the file is not matched by the require hook pattern.
fix
Ensure the file is processed by alamode: use CLI or require hook with correct extension (.js). Check that the source code uses static import/export.
error Cannot find module 'alamode' ↓
cause alamode is not installed or not in the require path.
fix
Run 'npm install alamode' or 'yarn add alamode'. Ensure node_modules is accessible.
error TypeError: alamode is not a function ↓
cause Using wrong import style: default import vs named import.
fix
Use 'import alamode from 'alamode'' (default) or 'const alamode = require('alamode').default' (CJS).
Warnings
gotcha alamode does not handle dynamic imports (import()) or re-exports (export * from). It only supports static import/export statements. ↓
fix For dynamic imports, use native ESM or a more complete transpiler. For re-exports, rewrite as individual exports.
gotcha The require hook (--require alamode/register) only affects .js files, not .mjs or .cjs. It also does not transform files in node_modules by default. ↓
fix Explicitly include files via --require with full path or use the CLI for building.
gotcha JSX transpilation does not support source maps and may break on complex JSX expressions (e.g., spread attributes, fragments). ↓
fix Review transpiled JSX output; consider using Babel for complex JSX.
deprecated The '--harmony' flag or older Node.js versions (<10) may cause syntax errors due to unsupported ES features. ↓
fix Use Node.js >=10 for full support.
Install
npm install alamode yarn add alamode pnpm add alamode Imports
- default wrong
const alamode = require('alamode')correctimport alamode from 'alamode' - transpile wrong
const { transpile } = require('alamode')correctimport { transpile } from 'alamode' - alamode wrong
import alamode from 'alamode'correctconst alamode = require('alamode')
Quickstart
import alamode from 'alamode';
const source = `
import { join } from 'path';
export const greet = (name) => `Hello, ${name}!`;
`;
const result = alamode(source);
console.log(result.code);
// Output:
// const { join } = require('path');
// const greet = (name) => `Hello, ${name}!`;
// module.exports.greet = greet;