Registry / babel-plugin-transform-es2015-block-scoped-functions

babel-plugin-transform-es2015-block-scoped-functions

JSON →
library6.22.0jsnpmunverified

Babel plugin (v6.22.0) that transforms function declarations inside blocks to be block-scoped, ensuring compatibility with ES2015 semantics in older environments. This plugin is part of Babel's deprecated 'es2015' preset and is no longer maintained independently. It converts block-level function declarations to variable assignments with the same name, preventing hoisting issues. For modern Babel usage (v7+), use @babel/plugin-transform-block-scoped-functions instead.

npm install babel-plugin-transform-es2015-block-scoped-functions
INSTALL
IMPORT
SIG · BABEL-PLUGIN-TRANS
B
babel-plugin-transform-es2015-block-scoped-functions
javascriptv6.22.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

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

plugin (default)
{ "plugins": ["transform-es2015-block-scoped-functions"] }
Used in .babelrc or babel.config.js plugin array
plugin (programmatic)
require('babel-core').transform(code, { plugins: ['transform-es2015-block-scoped-functions'] })
import { transform } from 'babel-core'; transform(code, { plugins: ['transform-es2015-block-scoped-functions'] })
This old plugin is CJS-only; cannot use ESM import syntax in older Babel versions
require('babel-plugin-transform-es2015-block-scoped-functions')
const plugin = require('babel-plugin-transform-es2015-block-scoped-functions');
import plugin from 'babel-plugin-transform-es2015-block-scoped-functions';
Package does not provide ESM exports; use require only

Shows how to configure and use the plugin to block-scope function declarations within blocks.

// .babelrc { "plugins": ["transform-es2015-block-scoped-functions"] } // Input function f() { return 1; } { function f() { return 2; } } f(); // now returns 1 instead of 2 in older engines // Output (transformed) function f() { return 1; } { var _f = function f() { return 2; }; } f(); // returns 1 // Via Node API var babel = require('babel-core'); var result = babel.transform('{ function foo() {} }', { plugins: ['transform-es2015-block-scoped-functions'] }); console.log(result.code);
Debug
Known issues
deprecatedThis package is deprecated as of Babel v7. Use @babel/plugin-transform-block-scoped-functions instead.
fix
Replace with @babel/plugin-transform-block-scoped-functions in Babel v7 projects.
affects: >=6.0.0
breakingPlugin renaming: babel-plugin-transform-es2015-block-scoped-functions has been renamed to @babel/plugin-transform-block-scoped-functions in Babel v7.
fix
Use @babel/plugin-transform-block-scoped-functions or include in @babel/preset-env (which automatically includes it when needed).
affects: >=7.0.0
gotchaDoes not work with Babel v7 or later; only compatible with babel-core v6.
fix
Upgrade to @babel/core v7 and use @babel/plugin-transform-block-scoped-functions.
affects: >=7.0.0
gotchaPlugin only applies to function declarations at block level; does not affect arrow functions or function expressions.
fix
No fix needed; understand the scope of the plugin.
affects: >=6.0.0
Errors
Common errors & fixes
Error: Cannot find module 'babel-plugin-transform-es2015-block-scoped-functions'
Package not installed or using wrong Babel version.
fix
npm install babel-plugin-transform-es2015-block-scoped-functions --save-dev (for Babel 6) or use @babel/plugin-transform-block-scoped-functions (for Babel 7+)
Plugin/Preset files are not allowed to export objects, only functions
Using the plugin with Babel v7 which expects @babel/plugin prefix.
fix
Switch to @babel/plugin-transform-block-scoped-functions.
Error: Invalid plugin "transform-es2015-block-scoped-functions" specified in
Typo or wrong configuration format.
fix
Ensure plugin name is correct and in quotes: "transform-es2015-block-scoped-functions"
Upgrade
Version history
6.22.0latest on npm
Audit
Dependencies
babel-corerequiredRequires babel-core to run as a plugin
Agent activity
4 hits · last 30 days
node
4
Resources
babel-plugin-transform-es2015-block-scoped-functions — npm install babel-plugin-transform-es2015-block-scoped-functions · libregistry