Registry / testing / babel-plugin-transform-es2015-parameters

babel-plugin-transform-es2015-parameters

JSON →
library6.24.1jsnpmunverified

Babel plugin to compile ES2015 (ES6) function parameter features—default, rest, and destructuring parameters—to ES5. Version 6.24.1 corresponds to Babel 6.x; it is now deprecated in favor of @babel/plugin-transform-parameters for Babel 7+. This plugin is designed for projects using Babel 6 and requires compat with other transform plugins (e.g., block-scoping) for certain output semantics. It does not transform arrow functions or for-of statements.

npm install babel-plugin-transform-es2015-parameters
INSTALL
IMPORT
SIG · BABEL-PLUGIN-TRANS
B
babel-plugin-transform-es2015-parameters
testingjavascriptv6.24.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

plugin (default)
plugins: ["transform-es2015-parameters"]
plugins: ['babel-plugin-transform-es2015-parameters']
In .babelrc or babel.config.js, use the short name without the 'babel-plugin-' prefix.
require (Node API)
require('babel-core').transform('code', { plugins: ['transform-es2015-parameters'] })
transform('code', { plugins: [require('babel-plugin-transform-es2015-parameters')] })
When using Node API, pass the plugin name as a string, not the required module.

Shows usage with .babelrc and code output demonstrating default and rest parameters transformed to ES5.

// .babelrc { "plugins": ["transform-es2015-parameters", "transform-es2015-block-scoping"] } // Input: ES2015 default/rest parameters function greet(name = 'World', ...greetings) { console.log(`Hello ${name}`); greetings.forEach(g => console.log(g)); } // Output: ES5 (after Babel transformation) "use strict"; function greet() { var name = arguments.length <= 0 || arguments[0] === void 0 ? 'World' : arguments[0]; var greetings = []; for (var _key = 1; _key < arguments.length; _key++) { greetings.push(arguments[_key]); } console.log('Hello ' + name); greetings.forEach(function (g) { return console.log(g); }); }
Debug
Known issues
deprecatedThis package has been deprecated in favor of @babel/plugin-transform-parameters for Babel 7.x.
fix
Migrate to Babel 7 and use @babel/plugin-transform-parameters.
affects: >=6.0.0
gotchaDefault parameters desugar into `let` declarations which require block-scoping support. Without the block-scoping plugin, your target environment may not support `let`.
fix
Include the 'transform-es2015-block-scoping' plugin in your Babel configuration.
affects: >=6.0.0
breakingOnly compatible with Babel 6.x. Using with Babel 7 will cause errors.
fix
Upgrade to @babel/core 7 and use @babel/plugin-transform-parameters.
affects: >=6.0.0
Errors
Common errors & fixes
Error: Plugin [transform-es2015-parameters] is not found
Missing required plugin in node_modules or not installed.
fix
Run `npm install --save-dev babel-plugin-transform-es2015-parameters` and ensure .babelrc references the short name.
ReferenceError: _let is not defined
Default parameters desugar to `let` but transform-es2015-block-scoping is not enabled.
fix
Add 'transform-es2015-block-scoping' to your plugins list.
TypeError: Cannot read property 'traverse' of undefined
Using the plugin with Babel 7 or mismatched babel-core version.
fix
Use Babel 6 or switch to '@babel/plugin-transform-parameters' for Babel 7.
Upgrade
Version history
6.24.1latest on npm
Audit
Dependencies
babel-plugin-transform-es2015-block-scopingoptionalRequired when using default parameters because they desugar to `let` declarations.
Agent activity
22 hits · last 30 days
node
18
OpenAI (training)
2
Amazon
1
Resources
babel-plugin-transform-es2015-parameters — npm install babel-plugin-transform-es2015-parameters · libregistry