Registry / testing / babel-plugin-minprops

babel-plugin-minprops

JSON →
library2.0.1jsnpmunverified

Babel plugin that minifies object properties by renaming those prefixed with a configurable marker (default `$__`) to short names in production builds. Version 2.0.1 is stable, with no recent updates. Unlike general minifiers that cannot safely rename properties due to cross-file references, minprops explicitly marks internal properties for renaming, reducing bundle size. It integrates with Babel and supports configuration via package.json. Alternative to manual property mangling or closure compiler's property renaming, but requires prefixing all internal properties.

npm install babel-plugin-minprops
INSTALL
IMPORT
SIG · BABEL-PLUGIN-MINPR
B
babel-plugin-minprops
testingjavascriptv2.0.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

default
import minprops from 'babel-plugin-minprops'
const minprops = require('babel-plugin-minprops')
ESM import works with Babel >=7; CommonJS require also works as plugin is CJS-compatible.
minprops
module.exports = { plugins: [['babel-plugin-minprops', { exclude: ['id'] }]] }
module.exports = { plugins: ['babel-plugin-minprops'] }
Options are passed as second element of array; common mistake: omitting array wrapper or passing options incorrectly.
matchPrefix
module.exports = { plugins: [['babel-plugin-minprops', { matchPrefix: '$' }]] }
module.exports = { plugins: [['babel-plugin-minprops', { prefix: '$' }]] }
Option key is 'matchPrefix', not 'prefix'. Default is '$__'.

Configures babel-plugin-minprops with exclude list and custom prefix, shows how properties prefixed with $__ are renamed.

// Install: npm install --save-dev babel-plugin-minprops // babel.config.js module.exports = { plugins: [ ['babel-plugin-minprops', { exclude: ['id'], matchPrefix: '$__' }] ] }; // Input code: class Foo { $__privateMethod() { return 42; } } const foo = new Foo(); console.log(foo.$__privateMethod()); // Output: properties prefixed with $__ get renamed to short names like 'a'.
Debug
Known issues
breakingPlugin may rename properties that conflict with short reserved names or existing short properties.
fix
Use the 'exclude' option to prevent renaming to specific short property names that might cause conflicts.
affects: >=2.0.0
breakingThe default prefix '$__' may collide with properties from other libraries or your own code that happen to be named with that prefix.
fix
Change the prefix to something unique using the 'matchPrefix' option, e.g., '__internal'.
affects: >=2.0.0
gotchaOnly properties prefixed with the marker are renamed; other properties remain unchanged. This may mislead developers into thinking all properties are minified.
fix
Ensure all intended internal properties use the configured prefix.
affects: >=2.0.0
gotchaThe plugin does not handle computed property keys or destructured property assignments; those properties will not be renamed.
fix
Avoid using dynamic property names for internal properties that you want minified.
affects: >=2.0.0
deprecatedVersion 2.x uses options from package.json 'minprops' key; but only works if plugin is configured to read it via 'configFile' option?
fix
Use Babel config options directly or ensure your project has the 'minprops' key in package.json with correct structure.
affects: 2.0.0 - 2.0.1
Errors
Common errors & fixes
Error: [BABEL] unknown plugin "babel-plugin-minprops" specified in "plugins"
Plugin not installed or not in node_modules.
fix
Run 'npm install --save-dev babel-plugin-minprops' and check that package.json includes it.
TypeError: Cannot read property 'exclude' of undefined
Options object is malformed; likely using 'minprops' key inside plugin array incorrectly.
fix
Use: plugins: [['babel-plugin-minprops', { exclude: [] }]]
ReferenceError: $__ is not defined at runtime
Property prefixed with $__ was renamed to a short name but the runtime code still references the original name.
fix
Ensure both source and consumer code use the same prefix and that the plugin runs on all relevant files (including entry points).
Upgrade
Version history
2.0.1latest on npm
Audit
Dependencies
@babel/coreoptionalRequires Babel core to function as a plugin
Agent activity
17 hits · last 30 days
node
16
OpenAI (training)
1
Resources
babel-plugin-minprops — npm install babel-plugin-minprops · libregistry