Registry / devops / babel-plugin-minify-type-constructors

babel-plugin-minify-type-constructors

JSON →
library0.4.3jsnpmunverified

A Babel plugin that minifies type constructors like Boolean(), Number(), String(), Array(), and Object() where possible (e.g., replacing `new Boolean(x)` with `!!x` or `new Number(x)` with `+x`). Part of the babel-minify (formerly babili) minification preset. Version 0.4.3 is the latest stable release (2018). The babel-minify project is now in maintenance mode; no new features are expected. This plugin should be used with caution in environments requiring IE8 or lower due to potential compatibility issues. It is designed to work as part of a Babel minification pipeline, complementing other minify plugins.

npm install babel-plugin-minify-type-constructors
INSTALL
IMPORT
SIG · BABEL-PLUGIN-MINIF
B
babel-plugin-minify-type-constructors
devopsjavascriptv0.4.3
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
module.exports = require('babel-plugin-minify-type-constructors');
CommonJS style; works in Node.js with Babel.
default
import minifyTypeConstructors from 'babel-plugin-minify-type-constructors';
ESM import; requires bundler or Node.js with ESM support.
default
plugins: ['babel-plugin-minify-type-constructors']
plugins: ['minify-type-constructors']
In Babel config, use the full package name.

Shows how to add the plugin to Babel config and the type constructor minification transform.

// babel.config.js module.exports = { plugins: [ 'babel-plugin-minify-type-constructors' ] }; // Input: var a = new Boolean(true); var b = new String('hello'); // Output: var a = !!true; var b = 'hello';
Debug
Known issues
breakingNot recommended for full IE8 and lower support due to potential issues with object wrappers.
fix
Use only in modern environments or apply polyfills.
affects: >=0.4.0
deprecatedThe babel-minify project is no longer actively maintained. Prefer babel-preset-minify or community alternatives.
fix
Migrate to babel-preset-minify (which includes this plugin) or other minifiers.
affects: >=0.4.0
gotchaPotential breaking due to missing dependencies in babel-minify@0.5.0 and 0.5.1.
fix
Use version 0.4.3 or upgrade to a later patch if available.
affects: 0.5.0 - 0.5.1
Errors
Common errors & fixes
Error: Cannot find module 'babel-plugin-minify-type-constructors'
Package not installed or missing in node_modules.
fix
npm install babel-plugin-minify-type-constructors --save-dev
ReferenceError: Boolean is not defined (or similar) in transformed code
Plugin transforms `new Boolean(x)` to `!!x`, which may not be equivalent in all edge cases (e.g., `new Boolean(false)` is truthy).
fix
Review transformed code and possibly disable plugin for sensitive cases.
Upgrade
Version history
0.4.3latest on npm
Audit
Dependencies
@babel/coreoptionalRequired as a peer dependency for Babel plugin API
Agent activity
4 hits · last 30 days
node
4
Resources
babel-plugin-minify-type-constructors — npm install babel-plugin-minify-type-constructors · libregistry