babel-preset-es2040
raw JSON → 1.1.1 verified Sat Apr 25 auth: no javascript deprecated
A Babel preset that enables a very small subset of ES6 features deemed essential by its authors, deliberately omitting most ES2015+ syntax. Version 1.1.1 is the latest and final release. It is an experimental, opinionated alternative to larger presets like babel-preset-env. Note: the name 'es2040' is ironic, indicating a minimal, possibly frivolous approach. The package is not actively maintained and is not recommended for new projects.
Common errors
error Module not found: Can't resolve 'babel-preset-es2040' in ... ↓
cause Babel cannot locate the preset if not installed or if the name resolution is incorrect.
fix
Run
npm install --save-dev babel-preset-es2040 and ensure it's in node_modules. error Error: [BABEL] unknown preset: es2040 ↓
cause Babel 7 requires the full package name if the default resolution fails.
fix
Change .babelrc to {"presets": ["babel-preset-es2040"]}.
error SyntaxError: Unexpected token (something like import/const/arrow etc.) ↓
cause The preset does not include the plugin for that feature.
fix
Use a different preset like babel-preset-env that supports the needed syntax.
Warnings
deprecated Package is no longer maintained and may not work with modern Babel versions (v7+). ↓
fix Migrate to babel-preset-env or a custom preset with chosen plugins.
breaking Babel 7 dropped support for presets without babel-preset- prefix in the name, requiring full package name in .babelrc. ↓
fix Use { "presets": ["babel-preset-es2040"] } or switch to a compatible preset.
gotcha Only a tiny subset of ES6 features are supported; most modern syntax will fail to compile. ↓
fix Check the list of supported plugins in the package source, or use a more comprehensive preset.
gotcha Package name includes 'es2040' but actually targets a subset of ES6 (ES2015), not ES2020. ↓
fix Do not assume it provides ES2020 features; refer to source for actual plugins.
Install
npm install babel-preset-es2040 yarn add babel-preset-es2040 pnpm add babel-preset-es2040 Imports
- default export wrong
import preset from 'babel-preset-es2040'correctmodule.exports = require('babel-preset-es2040') - .babelrc config wrong
{"presets": ["babel-preset-es2040"]}correct{"presets": ["es2040"]} - Node API usage wrong
require('babel-core').transform('code', { presets: [require('babel-preset-es2040')] })correctrequire('babel-core').transform('code', { presets: ['es2040'] })
Quickstart
npm install --save-dev babel-preset-es2040
# .babelrc
{
"presets": ["es2040"]
}
# Then run babel on your files
npx babel script.js --presets es2040