{"id":19100,"library":"babel-plugin-minify-type-constructors","title":"babel-plugin-minify-type-constructors","description":"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.","status":"maintenance","version":"0.4.3","language":"javascript","source_language":"en","source_url":"https://github.com/babel/minify/tree/master/packages/babel-plugin-minify-type-constructors","tags":["javascript","babel-plugin"],"install":[{"cmd":"npm install babel-plugin-minify-type-constructors","lang":"bash","label":"npm"},{"cmd":"yarn add babel-plugin-minify-type-constructors","lang":"bash","label":"yarn"},{"cmd":"pnpm add babel-plugin-minify-type-constructors","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required as a peer dependency for Babel plugin API","package":"@babel/core","optional":true}],"imports":[{"note":"CommonJS style; works in Node.js with Babel.","wrong":"","symbol":"default","correct":"module.exports = require('babel-plugin-minify-type-constructors');"},{"note":"ESM import; requires bundler or Node.js with ESM support.","wrong":"","symbol":"default","correct":"import minifyTypeConstructors from 'babel-plugin-minify-type-constructors';"},{"note":"In Babel config, use the full package name.","wrong":"plugins: ['minify-type-constructors']","symbol":"default","correct":"plugins: ['babel-plugin-minify-type-constructors']"}],"quickstart":{"code":"// babel.config.js\nmodule.exports = {\n  plugins: [\n    'babel-plugin-minify-type-constructors'\n  ]\n};\n\n// Input: var a = new Boolean(true); var b = new String('hello');\n// Output: var a = !!true; var b = 'hello';","lang":"javascript","description":"Shows how to add the plugin to Babel config and the type constructor minification transform."},"warnings":[{"fix":"Use only in modern environments or apply polyfills.","message":"Not recommended for full IE8 and lower support due to potential issues with object wrappers.","severity":"breaking","affected_versions":">=0.4.0"},{"fix":"Migrate to babel-preset-minify (which includes this plugin) or other minifiers.","message":"The babel-minify project is no longer actively maintained. Prefer babel-preset-minify or community alternatives.","severity":"deprecated","affected_versions":">=0.4.0"},{"fix":"Use version 0.4.3 or upgrade to a later patch if available.","message":"Potential breaking due to missing dependencies in babel-minify@0.5.0 and 0.5.1.","severity":"gotcha","affected_versions":"0.5.0 - 0.5.1"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"npm install babel-plugin-minify-type-constructors --save-dev","cause":"Package not installed or missing in node_modules.","error":"Error: Cannot find module 'babel-plugin-minify-type-constructors'"},{"fix":"Review transformed code and possibly disable plugin for sensitive cases.","cause":"Plugin transforms `new Boolean(x)` to `!!x`, which may not be equivalent in all edge cases (e.g., `new Boolean(false)` is truthy).","error":"ReferenceError: Boolean is not defined (or similar) in transformed code"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}