Registry / devops / babel-plugin-strip-function-call

babel-plugin-strip-function-call

JSON →
library1.0.2jsnpmunverified

A Babel plugin that removes specific function calls (e.g., console.log) from your production code. Version 1.0.2 is the latest stable release, updated via bug fixes only. It is similar to webpack's strip-loader but tailored for Babel environments. The plugin is minimal, allowing you to specify an array of function call patterns to strip. It does not support computed property patterns (e.g., console["log"]) by design. Best paired with a process.env.NODE_ENV check for conditional stripping in production builds. Active development is low; the plugin is maintained but rarely updated.

npm install babel-plugin-strip-function-call
INSTALL
IMPORT
SIG · BABEL-PLUGIN-STRIP
B
babel-plugin-strip-function-call
devopsjavascriptv1.0.2
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.

strip-function-call
module.exports = require('babel-plugin-strip-function-call');
import strip from 'babel-plugin-strip-function-call';
The plugin uses CommonJS module.exports. In Babel config (.babelrc or babel.config.js), you reference it as a string 'babel-plugin-strip-function-call' or the short form 'strip-function-call'. Do not try to import it as an ES module.
Babel plugin configuration
{ "plugins": [ ["strip-function-call", { "strip": ["console.log"] }] ] }
{ "plugins": [ "strip-function-call" ] }
When using the plugin, you must configure it with at least a 'strip' array. Without options, it will do nothing. Also note the plugin name is 'strip-function-call', not 'babel-plugin-strip-function-call' inside the plugins array.
Env-specific usage
{ "env": { "production": { "plugins": [ ["strip-function-call", { "strip": ["console.log"] }] ] } } }
{ "plugins": [ ["strip-function-call", { "strip": ["console.log"] }] ] }
It is common to accidentally apply the plugin in all environments instead of only production. Use Babel's env option to restrict stripping to NODE_ENV=production. This prevents losing debugging statements in development.

Demonstrates Babel configuration to strip console.log calls only in production builds, with input/output example.

// .babelrc example: { "env": { "production": { "plugins": [ ["strip-function-call", { "strip": ["console.log"] }] ] } } } // Input: console.log('Hello World'); // Output (production): // (empty - line removed) // Note: The plugin only removes exact matches, not computed member expressions like console["log"]().
Debug
Known issues
gotchaDoes not strip computed property patterns like console["log"](...) by design.
fix
Use a different plugin or custom Babel visitor if you need to strip computed calls.
affects: >=1.0.0
gotchaThe plugin name in Babel config must be 'strip-function-call', not 'babel-plugin-strip-function-call'.
fix
Use 'strip-function-call' as the plugin name inside your .babelrc or babel.config.js.
affects: >=1.0.0
gotchaIf you do not specify a 'strip' array, the plugin will do nothing silently.
fix
Always provide a 'strip' option with an array of function call strings. Example: { "strip": ["console.log"] }
affects: >=1.0.0
gotchaThe plugin is not a preset; it must be listed under 'plugins', not 'presets'.
fix
Place it in the 'plugins' array of your Babel config.
affects: >=1.0.0
Errors
Common errors & fixes
Cannot find module 'babel-plugin-strip-function-call'
The plugin is not installed or npm install failed.
fix
Run 'npm install babel-plugin-strip-function-call --save-dev'.
Error: [BABEL] unknown: Plugin "strip-function-call" threw: Error: Cannot read property 'split' of undefined
The plugin is configured but the 'strip' option is missing or undefined.
fix
Ensure the plugin configuration includes a 'strip' array: e.g., ["strip-function-call", { "strip": ["console.log"] }]
console.log still appears after build
The plugin may not be applied due to missing env configuration or incorrect plugin name.
fix
Check that NODE_ENV is set to 'production' and that the plugin name is 'strip-function-call' inside Babel config.
Upgrade
Version history
1.0.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
babel-plugin-strip-function-call — npm install babel-plugin-strip-function-call · libregistry