Registry / devops / babel-plugin-show-source

babel-plugin-show-source

JSON →
library0.2.1jsnpmunverified

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.

npm install babel-plugin-show-source
INSTALL
IMPORT
SIG · BABEL-PLUGIN-SHOW-
B
babel-plugin-show-source
devopsjavascriptv0.2.1
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.

default
import showSource from 'babel-plugin-show-source'
const showSource = require('babel-plugin-show-source');
Plugin is ESM-first; if using CommonJS, use dynamic import or ensure your environment supports require of ESM.

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]'.

// babel.config.js module.exports = { plugins: [ 'babel-plugin-show-source', // or with options: // ['babel-plugin-show-source', { /* options */ }] ] }; // Input file (source.js) function greet(name) { return `Hello, ${name}!`; } console.log(greet.toString()); // After transformation, greet.toString() returns the full source code // Output: 'function greet(name) { return `Hello, ${name}!`; }'
Debug
Known issues
gotchaPlugin may break if Babel options like 'compact' or 'retainLines' are used.
fix
Avoid using conflicting options; test with your Babel configuration.
affects: >=0.0.0
breakingVersion 0.2.0 changed the output format; source string may differ in whitespace from original.
fix
Check updated output, adjust any string comparisons if needed.
affects: >=0.2.0
deprecatedThe 'show-source' option in Babel config is deprecated in favor of direct plugin usage.
fix
Use 'plugins' array directly instead of 'env' or 'overrides' options.
affects: >=0.1.5
Errors
Common errors & fixes
Error: Cannot find module 'babel-plugin-show-source'
Missing dependency; not installed in node_modules.
fix
Run `npm install --save-dev babel-plugin-show-source` or `yarn add -D babel-plugin-show-source`.
TypeError: plugin is not a function
Incorrect import; attempting to use default import as a function.
fix
Use `import showSource from 'babel-plugin-show-source'` in ESM or ensure proper default import resolution in CommonJS.
Upgrade
Version history
0.2.1latest on npm
Audit
Dependencies
@babel/corerequiredRequired peer dependency; plugin runs in Babel pipeline.
Agent activity
17 hits · last 30 days
node
14
OpenAI (training)
1
Resources
babel-plugin-show-source — npm install babel-plugin-show-source · libregistry