{"id":19165,"library":"babel-plugin-show-source","title":"babel-plugin-show-source","description":"A Babel plugin that transforms functions to include their source code via Function.prototype.toString() for runtime introspection. Current stable version is 0.2.1 (pre-1.0.0, still experimental). The release cadence is low; last update was 2023. It is a niche tool intended for debugging, serialization, or educational demos where preserving function text is needed. Note the pre-release versioning and possible breaking changes in minor versions.","status":"active","version":"0.2.1","language":"javascript","source_language":"en","source_url":"https://github.com/nouvist/babel-plugin-show-source","tags":["javascript","babel-plugin","show-source","to-string","babel-plugin-show-source","typescript"],"install":[{"cmd":"npm install babel-plugin-show-source","lang":"bash","label":"npm"},{"cmd":"yarn add babel-plugin-show-source","lang":"bash","label":"yarn"},{"cmd":"pnpm add babel-plugin-show-source","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required peer dependency; plugin runs in Babel pipeline.","package":"@babel/core","optional":false}],"imports":[{"note":"Plugin is ESM-first; if using CommonJS, use dynamic import or ensure your environment supports require of ESM.","wrong":"const showSource = require('babel-plugin-show-source');","symbol":"default","correct":"import showSource from 'babel-plugin-show-source'"}],"quickstart":{"code":"// babel.config.js\nmodule.exports = {\n  plugins: [\n    'babel-plugin-show-source',\n    // or with options:\n    // ['babel-plugin-show-source', { /* options */ }]\n  ]\n};\n\n// Input file (source.js)\nfunction greet(name) {\n  return `Hello, ${name}!`;\n}\nconsole.log(greet.toString());\n\n// After transformation, greet.toString() returns the full source code\n// Output: 'function greet(name) { return `Hello, ${name}!`; }'","lang":"javascript","description":"Shows how to add the plugin to Babel config and demonstrates the transformation: after building, greet.toString() will return the original source code instead of '[Function]'."},"warnings":[{"fix":"Avoid using conflicting options; test with your Babel configuration.","message":"Plugin may break if Babel options like 'compact' or 'retainLines' are used.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Check updated output, adjust any string comparisons if needed.","message":"Version 0.2.0 changed the output format; source string may differ in whitespace from original.","severity":"breaking","affected_versions":">=0.2.0"},{"fix":"Use 'plugins' array directly instead of 'env' or 'overrides' options.","message":"The 'show-source' option in Babel config is deprecated in favor of direct plugin usage.","severity":"deprecated","affected_versions":">=0.1.5"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run `npm install --save-dev babel-plugin-show-source` or `yarn add -D babel-plugin-show-source`.","cause":"Missing dependency; not installed in node_modules.","error":"Error: Cannot find module 'babel-plugin-show-source'"},{"fix":"Use `import showSource from 'babel-plugin-show-source'` in ESM or ensure proper default import resolution in CommonJS.","cause":"Incorrect import; attempting to use default import as a function.","error":"TypeError: plugin is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}