@babel/core
Babel is the standard JavaScript compiler that transforms modern JavaScript and TypeScript syntax into backward-compatible versions that run in older browsers a…
Installation
npm install -D @babel/core @babel/preset-env
yarn add -D @babel/core @babel/preset-env
pnpm add -D @babel/core @babel/preset-env
Import
import * as babel from '@babel/core';
Quick Example
// babel.config.json
{
"presets": [
["@babel/preset-env", { "targets": "> 0.5%, not dead" }],
"@babel/preset-typescript",
"@babel/preset-react"
]
}About @babel/core
Babel is the standard JavaScript compiler that transforms modern JavaScript and TypeScript syntax into backward-compatible versions that run in older browsers and environments. Babel parses source code into an abstract syntax tree (AST), applies a series of transformation plugins, and generates the output code with source maps. The plugin architecture is Babel's core strength — each syntax transformation is handled by a separate plugin, and plugins are grouped into presets for convenience. @babel/preset-env automatically determines which transformations and polyfills are needed based on your target browser/runtime configuration, using browserslist queries. @babel/preset-react handles JSX transformation, and @babel/preset-typescript strips TypeScript type annotations. Babel's plugin ecosystem includes transforms for decorators, class properties, optional chaining, pipeline operators, and numerous experimental proposals. While SWC and esbuild have become faster alternatives for straightforward compilation, Babel remains essential for projects using custom AST transforms, specialized syntax plugins, or Babel-specific features like babel-plugin-macros. Babel's infrastructure also powers tools like ESLint (via @babel/eslint-parser) and Prettier for parsing modern syntax.
Quick Facts
| Package | @babel/core |
| Category | Build Tool |
| Weekly Downloads | 30M+ |
| License | MIT |
| Install | npm install -D @babel/core @babel/preset-env |
Related Packages
SWC (Speedy Web Compiler) is a Rust-based JavaScript/TypeScript compiler that provides a drop-in rep…
esbuild is an extremely fast JavaScript and TypeScript bundler and minifier written in Go that is 10…
TypeScript is a strongly typed programming language that builds on JavaScript, adding static type de…
Webpack is a powerful and highly configurable static module bundler for modern JavaScript applicatio…
Vite is a next-generation frontend build tool created by Evan You (creator of Vue.js) that provides …
Browse npm Packages by Category
Explore our reference of 200 popular npm packages with install commands, examples, and quick-start guides.