Registry / devops / bit-bundler-minifyjs

bit-bundler-minifyjs

JSON →
library3.1.0jsnpmunverified

bit-bundler-minifyjs is a specialized plugin designed to integrate JavaScript minification capabilities into the bit-bundler ecosystem. It acts as a lightweight wrapper around the UglifyJS library, leveraging its robust optimization and minification features. The current stable version is 3.1.0. While no explicit release cadence is stated, the package has seen recent maintenance releases (e.g., v3.0.4), indicating ongoing support for critical fixes. Its primary differentiator is its seamless integration with bit-bundler, allowing developers to configure minification options per bundle, which is particularly useful in code-splitting scenarios. It also provides convenience options like `banner` and `sourceMap` that abstract UglifyJS's underlying configuration, streamlining its usage within the bit-bundler build process.

npm install bit-bundler-minifyjs
INSTALL
IMPORT
SIG · BIT-BUNDLER-MINIFY
B
bit-bundler-minifyjs
devopsjavascriptv3.1.0
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.

bit-bundler-minifyjs (string)
var bitbundler = new Bitbundler({ bundler: [ "bit-bundler-minifyjs" ] });
import MinifyJS from 'bit-bundler-minifyjs';
When used within the `bit-bundler` configuration array, the plugin is referenced by its package name string. `bit-bundler` internally resolves and loads it using CommonJS `require`.
minifyjs (function)
const minifyjs = require('bit-bundler-minifyjs'); // ... then use in bundler config: // bundler: [minifyjs({ banner: '/*! My App */' })]
const minifyjs = new (require('bit-bundler-minifyjs'))();
When needing to pass options directly to the plugin, `require` the module, which exports a function that accepts an options object and returns the plugin instance.
minifyjs (with code splitting)
Bitbundler.bundle({ /* ... */ }, { bundler: [ ["bit-bundler-splitter", { /* ... */ }], ["bit-bundler-minifyjs", { vendor: { sourceMap: false } }] ] });
For per-bundle configuration with `bit-bundler-splitter`, options for `bit-bundler-minifyjs` are nested under a key matching the split bundle's name (e.g., 'vendor').

This quickstart demonstrates how to integrate `bit-bundler-minifyjs` into a basic `bit-bundler` setup to minify a JavaScript file.

const Bitbundler = require("bit-bundler"); const path = require("path"); const fs = require("fs"); // Create a dummy input file for a runnable example const inJsContent = ` console.log("Hello from in.js"); function calculateSquare(num) { return num * num; } console.log(calculateSquare(7)); `; const inJsPath = path.join(__dirname, "in.js"); fs.writeFileSync(inJsPath, inJsContent); const outJsPath = path.join(__dirname, "out.js"); // Clean up previous run's output if it exists if (fs.existsSync(outJsPath)) { fs.unlinkSync(outJsPath); } // Configure bit-bundler with the minifyjs plugin const bitbundler = new Bitbundler({ bundler: [ "bit-bundler-minifyjs" // The plugin is added here ] }); // Bundle and minify the JavaScript file bitbundler.bundle({ src: inJsPath, dest: outJsPath }).then(() => { console.log(`Successfully bundled and minified to: ${outJsPath}`); // Optional: Read a sample of the output to confirm minification const minifiedContent = fs.readFileSync(outJsPath, 'utf8'); console.log("Minified content sample (first 100 chars):"); console.log(minifiedContent.substring(0, 100) + "..."); }).catch(err => { console.error("Bundling failed:", err); }).finally(() => { // Clean up dummy input and output files if (fs.existsSync(inJsPath)) fs.unlinkSync(inJsPath); if (fs.existsSync(outJsPath)) fs.unlinkSync(outJsPath); });
Debug
Known issues
breakingThe way `bundle.dest` was used to feed a map of files to UglifyJS was removed in v3.0.4 because `bundle.dest` is not always a file path string and could cause crashes. This functionality was moved to be handled internally within `bit-bundler` itself.
fix
Do not rely on `bundle.dest` for directly providing file maps to UglifyJS via this plugin. Ensure you are on a version of `bit-bundler` that handles this internally, or adjust your build process to explicitly manage file maps if necessary.
affects: >=3.0.4
gotchaOptions for `bit-bundler-minifyjs` are directly forwarded to UglifyJS, but some options like `banner` and `sourceMap` are specific to the plugin and override or map to UglifyJS options (`output.preamble`).
fix
When configuring, check the plugin's README for its specific options (e.g., `banner`, `sourceMap`) before directly referencing UglifyJS options. Understand how the plugin's options map to UglifyJS's underlying configuration.
affects: >=1.0
gotchaSourcemaps are generated inline by default. If you need to split them into a separate file, you will need to use an additional plugin like `bit-bundler-extractsm`.
fix
To extract sourcemaps, install and configure `bit-bundler-extractsm` alongside `bit-bundler-minifyjs` in your `bit-bundler` setup.
affects: >=1.0
Upgrade
Version history
3.1.0latest on npm
Audit
Dependencies
bit-bundlerrequiredThis package is a plugin for bit-bundler and requires it for core functionality.
uglify-jsrequiredIt's a wrapper for UglifyJS, which performs the actual JavaScript minification.
Agent activity
4 hits · last 30 days
node
4
Resources
bit-bundler-minifyjs — npm install bit-bundler-minifyjs · libregistry