Registry / testing / rollup-plugin-es6-class-minify

rollup-plugin-es6-class-minify

JSON →
library2.0.0jsnpmunverified

A Rollup plugin that minifies ES6 class member names (fields and methods) by renaming identifiers prefixed with underscore (`_`). Version 2.0.0 requires Node.js >=13. It works alongside standard JavaScript minifiers (like Terser) which cannot rename class properties. The plugin operates on the AST during bundling, replacing `_`-prefixed names with short alternatives. It supports repeated use across multiple bundles with consistent mappings by reusing the plugin instance. Input files must use underscore-prefixed class members for minification to apply.

npm install rollup-plugin-es6-class-minify
INSTALL
IMPORT
SIG · ROLLUP-PLUGIN-ES6-
R
rollup-plugin-es6-class-minify
testingjavascriptv2.0.0
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.

rollupPluginES6ClassMinify
import { rollupPluginES6ClassMinify } from 'rollup-plugin-es6-class-minify'
import rollupPluginES6ClassMinify from 'rollup-plugin-es6-class-minify'
The package exports a named function, not a default export. Using default import will result in undefined.
rollupPluginES6ClassMinify
const { rollupPluginES6ClassMinify } = require('rollup-plugin-es6-class-minify')
const rollupPluginES6ClassMinify = require('rollup-plugin-es6-class-minify')
CommonJS users must destructure the named export. Direct require returns an object with the function.
rollupPluginES6ClassMinify
import { rollupPluginES6ClassMinify } from 'rollup-plugin-es6-class-minify'
import { es6ClassMinify } from 'rollup-plugin-es6-class-minify'
The export name is exactly 'rollupPluginES6ClassMinify'. Using a different alias at import will fail.

Shows basic usage of the plugin with Rollup. Creates a plugin instance and adds it to the plugins array.

import { rollup } from 'rollup'; import { rollupPluginES6ClassMinify } from 'rollup-plugin-es6-class-minify'; const es6ClassMinify = rollupPluginES6ClassMinify(); rollup({ input: 'main.js', plugins: [es6ClassMinify] }).then(bundle => bundle.write({ format: 'es', dir: 'dist' })); console.log('Build complete. Class members prefixed with _ are minified.');
Debug
Known issues
gotchaOnly class members (fields/methods) prefixed with underscore (`_`) are minified. Members without underscore are left unchanged.
fix
Prefix all class fields and methods intended for minification with an underscore, e.g., `_count`, `_increment()`.
affects: >=0.0.0
gotchaThe plugin does NOT minify variable names, function names, or any code outside classes. It must be combined with a standard minifier (e.g., Terser) for full minification.
fix
Add another minifier plugin like `rollup-plugin-terser` after this plugin in the plugins array.
affects: >=0.0.0
gotchaIf the plugin instance is reused across multiple bundles, the mappings are shared, ensuring consistent short names across bundles. If you create separate instances, the same original name may get different short names in different bundles.
fix
To maintain cross-bundle consistency, reuse the same plugin instance (as shown in the docs).
affects: >=2.0.0
breakingVersion 2.0.0 drops support for Node.js 10 and 12 due to engine requirement `>=13`.
fix
Upgrade Node.js to version 13 or higher.
affects: >=2.0.0
Errors
Common errors & fixes
TypeError: Cannot read properties of undefined (reading 'map')
Using default import instead of named import from the package.
fix
Use import { rollupPluginES6ClassMinify } from 'rollup-plugin-es6-class-minify'
Error: [object Object] is not a function
Directly using the result of require without destructuring.
fix
const { rollupPluginES6ClassMinify } = require('rollup-plugin-es6-class-minify');
Unexpected token: punc (.)
Forgetting to add the plugin to the Rollup config or using unsupported JavaScript syntax.
fix
Ensure the plugin is included in the 'plugins' array and that your code uses underscore-prefixed class members.
Upgrade
Version history
2.0.0latest on npm
Audit
Dependencies
rolluprequiredThis package is a Rollup plugin and requires Rollup to be installed (peer dependency).
Agent activity
6 hits · last 30 days
node
6
Resources
rollup-plugin-es6-class-minify — npm install rollup-plugin-es6-class-minify · libregistry