{"id":19169,"library":"babel-plugin-strip-function-call","title":"babel-plugin-strip-function-call","description":"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.","status":"active","version":"1.0.2","language":"javascript","source_language":"en","source_url":"https://github.com/azu/babel-plugin-strip-function-call","tags":["javascript","babel","plugin","optimize","production"],"install":[{"cmd":"npm install babel-plugin-strip-function-call","lang":"bash","label":"npm"},{"cmd":"yarn add babel-plugin-strip-function-call","lang":"bash","label":"yarn"},{"cmd":"pnpm add babel-plugin-strip-function-call","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"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.","wrong":"import strip from 'babel-plugin-strip-function-call';","symbol":"strip-function-call","correct":"module.exports = require('babel-plugin-strip-function-call');"},{"note":"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.","wrong":"{\n  \"plugins\": [\n    \"strip-function-call\"\n  ]\n}","symbol":"Babel plugin configuration","correct":"{\n  \"plugins\": [\n    [\"strip-function-call\", { \"strip\": [\"console.log\"] }]\n  ]\n}"},{"note":"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.","wrong":"{\n  \"plugins\": [\n    [\"strip-function-call\", { \"strip\": [\"console.log\"] }]\n  ]\n}","symbol":"Env-specific usage","correct":"{\n  \"env\": {\n    \"production\": {\n      \"plugins\": [\n        [\"strip-function-call\", { \"strip\": [\"console.log\"] }]\n      ]\n    }\n  }\n}"}],"quickstart":{"code":"// .babelrc example:\n{\n  \"env\": {\n    \"production\": {\n      \"plugins\": [\n        [\"strip-function-call\", { \"strip\": [\"console.log\"] }]\n      ]\n    }\n  }\n}\n\n// Input:\nconsole.log('Hello World');\n\n// Output (production):\n// (empty - line removed)\n\n// Note: The plugin only removes exact matches, not computed member expressions like console[\"log\"]().","lang":"json","description":"Demonstrates Babel configuration to strip console.log calls only in production builds, with input/output example."},"warnings":[{"fix":"Use a different plugin or custom Babel visitor if you need to strip computed calls.","message":"Does not strip computed property patterns like console[\"log\"](...) by design.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use 'strip-function-call' as the plugin name inside your .babelrc or babel.config.js.","message":"The plugin name in Babel config must be 'strip-function-call', not 'babel-plugin-strip-function-call'.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Always provide a 'strip' option with an array of function call strings. Example: { \"strip\": [\"console.log\"] }","message":"If you do not specify a 'strip' array, the plugin will do nothing silently.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Place it in the 'plugins' array of your Babel config.","message":"The plugin is not a preset; it must be listed under 'plugins', not 'presets'.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run 'npm install babel-plugin-strip-function-call --save-dev'.","cause":"The plugin is not installed or npm install failed.","error":"Cannot find module 'babel-plugin-strip-function-call'"},{"fix":"Ensure the plugin configuration includes a 'strip' array: e.g., [\"strip-function-call\", { \"strip\": [\"console.log\"] }]","cause":"The plugin is configured but the 'strip' option is missing or undefined.","error":"Error: [BABEL] unknown: Plugin \"strip-function-call\" threw: Error: Cannot read property 'split' of undefined"},{"fix":"Check that NODE_ENV is set to 'production' and that the plugin name is 'strip-function-call' inside Babel config.","cause":"The plugin may not be applied due to missing env configuration or incorrect plugin name.","error":"console.log still appears after build"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}