babel
Transpile modern JavaScript into backward-compatible versions.
TLDR
Transpile JavaScript file
SYNOPSIS
babel [options] files
DESCRIPTION
babel is a JavaScript compiler that transforms modern JavaScript (ES6+) into backward-compatible versions for older browsers and environments. It supports JSX, TypeScript, and experimental JavaScript features through plugins and presets.
The tool is essential for modern JavaScript development, enabling use of latest language features while maintaining broad compatibility.
PARAMETERS
-o, --out-file file
Output file-d, --out-dir dir
Output directory-w, --watch
Watch files for changes-s, --source-maps
Generate source maps--presets presets
Transformation presets--plugins plugins
Transformation plugins--config-file path
Configuration file path--no-babelrc
Ignore .babelrc files--minified
Minify output--compact mode
Compact output (true/false/auto)
CONFIGURATION
babel.config.json
Project-wide Babel configuration for presets, plugins, and transformation options..babelrc
Directory-specific Babel configuration, applies to files within the containing directory.
COMMON PRESETS
@babel/preset-env
Transform modern JavaScript for target environments@babel/preset-react
Transform JSX for React@babel/preset-typescript
Transform TypeScript
CAVEATS
Requires Node.js. Configuration can be complex. Build times increase with file count. Some features need polyfills (not just transpilation). Plugin order matters.
HISTORY
Babel was created by Sebastian McKenzie in 2014 (originally as 6to5) to enable developers to use ES6 features before widespread browser support.
