babel-preset-stage-1
raw JSON → 6.24.1 verified Sat Apr 25 auth: no javascript deprecated
Babel preset that includes all stage 1 ECMAScript proposal plugins. This package is deprecated and removed in Babel 7+; stage presets were removed in favor of individual proposal plugins. Version 6.24.1 is the last stable release of the legacy Babel 6 line. Use @babel/preset-env with specific proposal plugins (e.g., @babel/plugin-proposal-xxx) instead. No longer maintained.
Common errors
error Error: Plugin/Preset files are not allowed to export objects, only functions. ↓
cause Using a Babel 6 preset with Babel 7 or vice versa.
fix
Ensure your Babel version matches the preset version. Use @babel/preset-env for Babel 7, or downgrade to Babel 6.
error Cannot find module 'babel-preset-stage-1' ↓
cause Preset not installed or not in node_modules.
fix
Run 'npm install --save-dev babel-preset-stage-1' and verify it is listed in package.json.
error ReferenceError: [BABEL] unknown: Decorators transform is necessary. ↓
cause Trying to use decorators without the proper plugin configuration.
fix
The stage-1 preset should include decorators. If not, add 'babel-plugin-transform-decorators-legacy' explicitly.
Warnings
deprecated Stage presets are removed in Babel 7. Use @babel/preset-env and individual @babel/plugin-proposal-* plugins. ↓
fix Upgrade to Babel 7 and replace 'stage-1' with specific proposal plugins like @babel/plugin-proposal-decorators, @babel/plugin-proposal-export-namespace-from, etc.
breaking Babel 6 stage presets include unstable proposals that may change or be removed in future ECMAScript specs. ↓
fix Pin exact Babel versions and test regularly with newer presets. Consider using @babel/preset-env with targeted proposals in Babel 7.
gotcha The decorator plugin in stage-1 is the legacy (stage 1) decorator proposal, which is incompatible with the stage 2 decorators in Babel 7. ↓
fix If upgrading to Babel 7, use @babel/plugin-proposal-decorators with the 'legacy' option for backward compatibility.
deprecated babel-preset-stage-1 is no longer maintained. Last version 6.24.1 dates back to 2017. ↓
fix Do not use for new projects. Migrate to Babel 7 or later.
Install
npm install babel-preset-stage-1 yarn add babel-preset-stage-1 pnpm add babel-preset-stage-1 Imports
- default wrong
import stage1 from 'babel-preset-stage-1'correctmodule.exports = require('babel-preset-stage-1') - babel-preset-stage-1 in .babelrc wrong
{"presets": ["babel-preset-stage-1"]}correct{"presets": ["stage-1"]} - babel-preset-stage-1 via Node API wrong
require('babel-core').transform(code, { presets: ['stage-1'] })correctrequire('babel-core').transform(code, { presets: [require('babel-preset-stage-1')] })
Quickstart
// Install: npm install --save-dev babel-preset-stage-1 babel-cli
// .babelrc
{
"presets": ["stage-1"]
}
// Or via Node API
const babel = require('babel-core');
const result = babel.transform('class A { @decorator method() {} }', {
presets: ['stage-1']
});
console.log(result.code);