Registry / devops / bit-bundler-extractsm

bit-bundler-extractsm

JSON →
library2.1.4jsnpmunverified

bit-bundler-extractsm is a specialized plugin for the `bit-bundler` ecosystem, designed to manage source maps during the bundling process. Its primary function is to extract inline or generated source maps from bundled JavaScript files and write them to separate, dedicated `.map` files, typically alongside their corresponding JavaScript output. As of version `2.1.4`, it offers stable functionality for `bit-bundler` users. While its release cadence is not strictly defined, it appears to be actively maintained for bug fixes and compatibility, with recent updates addressing specific edge cases. A key differentiator is its deep integration with `bit-bundler`'s plugin architecture, allowing granular control over source map extraction, including the ability to entirely remove source maps from bundles or to manage them differently across various bundle splits. This makes it essential for optimizing production builds by separating source map files, preventing them from being included in the main application bundle.

npm install bit-bundler-extractsm
INSTALL
IMPORT
SIG · BIT-BUNDLER-EXTRAC
B
bit-bundler-extractsm
devopsjavascriptv2.1.4
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.

Bitbundler
var Bitbundler = require("bit-bundler");
import Bitbundler from 'bit-bundler';
The core `bit-bundler` library is typically imported via CommonJS `require()` in environments where this plugin is most often used, as shown in the README examples.
Plugin Registration String
bundler: ["bit-bundler-extractsm"]
import { extractsm } from 'bit-bundler-extractsm';
`bit-bundler-extractsm` is registered as a plugin by its package name string within `bit-bundler`'s configuration array, not via a direct JavaScript import or require statement into user code.
Direct Module Reference (Rare)
const extractsmModule = require('bit-bundler-extractsm');
import * as extractsmModule from 'bit-bundler-extractsm';
While the module can technically be `require()`d, `bit-bundler-extractsm` is almost exclusively used as a named plugin string within `bit-bundler`'s configuration rather than directly invoking functions from `extractsmModule` in user code.

This example demonstrates how to use `bit-bundler-extractsm` with `bit-bundler` and `bit-bundler-minifyjs` to bundle `in.js` into `out.js` and extract its source map into a separate `out.js.map` file.

const Bitbundler = require("bit-bundler"); const path = require("path"); const fs = require("fs"); // Create a dummy in.js file for the example const inJsContent = ` // in.js console.log('Hello from in.js'); const add = (a, b) => a + b; console.log('Sum:', add(1, 2)); // This line is often generated by tools like Babel or TypeScript, or explicitly added by minifiers. //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImluLmpzIl0sIm5hbWVzIjpbImNvbnNvbGUiLCJsb2ciLCJhZGQiLCJhIiwiYiJdLCJtYXBwaW5ncyI6IkFBQUE7QUFDQUEsUUFBQUMsR0FBRCxDQUFLLGtCQUFMLENBQUw7QUFDQSxNQUFNQyxHQUFHLENBQUNDLEVBQUQsRUFBU0MsQ0FBVCxDQUFELEdBQWdCRCxDQUFDLEdBQUVDLENBQXJCO0FBQ0FILFFBQUFDLGdBQWdCLENBQUNFLFdBQVdDLENBQUMsQ0FBQyxDQUFFLENBQUMsQ0FBRCxDQUFZLENBQVAsQ0FBckI7QUFDQTtBQUxBIiwic291cmNlc0NvbnRlbnQiOlsiLy8gaW4uanNcbmNvbnNvbGUubG9nKCdIZWxsbyBmcm9tIGluLmpzJyk7XG5jb25zdCBhZGQgPSAocmEsIGIpID0+IGEgKyBiO1xuY29uc29sZS5sb2coJ1N1bTogJywgYWRkKDEsIDIpKTtcbi8vIHRoaXMgaW5saW5lIHNvdXJjZW1hcCBpcyBmb3IgZGVtb25zdHJhdGlvbiBwdXJwb3Nlcywgbm90gCBhIGNhbm9uaWNhbCBzb3VyY2VtYXAgZm9ybWF0XG4jIyMgc291cmNlTWFwZmluZ1VSTA1pbi5qcy5tYXAgYnkgYmFzZTY0IGVuY29kaW5nIGEgZHVubXkgc291cmNlbWFwXG4ifV0sImZpbGUiOiJpbi5qcyJ9 `; const inJsPath = path.join(__dirname, 'in.js'); fs.writeFileSync(inJsPath, inJsContent.trim()); const outJsPath = path.join(__dirname, 'out.js'); const outMapPath = path.join(__dirname, 'out.js.map'); // Clean up previous outputs if they exist if (fs.existsSync(outJsPath)) fs.unlinkSync(outJsPath); if (fs.existsSync(outMapPath)) fs.unlinkSync(outMapPath); console.log('Starting bundling process...'); Bitbundler.bundle({ src: inJsPath, dest: outJsPath }, { bundler: [ // bit-bundler-minifyjs is often used to generate the source map that extractsm will then process "bit-bundler-minifyjs", "bit-bundler-extractsm" ] }).then(() => { console.log(`Bundle created at ${outJsPath}`); console.log(`Source map extracted to ${outMapPath}`); console.log('Verification: out.js should reference out.js.map, and out.js.map should exist.'); // Clean up dummy in.js after bundling fs.unlinkSync(inJsPath); }).catch(err => { console.error('Bundling failed:', err); // Ensure cleanup even on error if (fs.existsSync(inJsPath)) fs.unlinkSync(inJsPath); if (fs.existsSync(outJsPath)) fs.unlinkSync(outJsPath); if (fs.existsSync(outMapPath)) fs.unlinkSync(outMapPath); }); // To run this example: // 1. Ensure you have Node.js installed. // 2. npm install bit-bundler bit-bundler-minifyjs bit-bundler-extractsm // 3. Save the code above as 'bundle.js' // 4. Run: node bundle.js
Debug
Known issues
gotchaWhen `bit-bundler-extractsm` is used without a `dest` option for the main bundle, it might incorrectly generate sourcemap files named `null.map` in `process.cwd()`.
fix
Ensure that your `Bitbundler.bundle` call always specifies a `dest` path for the main output bundle. Upgrade to version `2.1.2` or higher to fix this bug automatically.
affects: <2.1.2
gotcha`bit-bundler-extractsm` requires another bundler plugin (like `bit-bundler-minifyjs`) to actually generate source maps in the first place. If no source maps are being produced by prior steps in the pipeline, `extractsm` will have nothing to extract.
fix
Verify that a plugin preceding `bit-bundler-extractsm` in the `bundler` array (e.g., `bit-bundler-minifyjs`) is configured to generate source maps. Consult the documentation for other `bit-bundler` plugins to ensure they are outputting source maps.
affects: >=1.0.0
gotchaTo remove sourcemaps from a bundle or a specific bundle split, `bit-bundler-extractsm` must be configured with `false` or an object specifying `false` for named splits. Misconfiguration can lead to unexpected source map generation or removal.
fix
To remove all source maps, use `['bit-bundler-extractsm', false]`. For specific bundle splits, provide an object like `['bit-bundler-extractsm', { vendor: false }]` where `vendor` is the name of the bundle split.
affects: >=1.0.0
Errors
Common errors & fixes
Sourcemap files named 'null.map' generated in current working directory.
The `bit-bundler` bundle operation was executed without a `dest` (destination) file path specified, causing `bit-bundler-extractsm` to misinterpret the output target.
fix
Ensure that `Bitbundler.bundle` is always called with a valid `dest` option, like `dest: 'out.js'`. For `bit-bundler-extractsm` versions prior to `2.1.2`, this was a known bug; upgrading to `2.1.2` or newer resolves the underlying issue.
Source map file not generated or extracted (e.g., 'out.js.map' is missing).
Either no upstream `bit-bundler` plugin (e.g., `bit-bundler-minifyjs`, Babel plugin) is configured to produce source maps, or `bit-bundler-extractsm` is explicitly disabled in the bundler configuration.
fix
Confirm that your bundling pipeline includes a plugin that generates source maps and that `bit-bundler-extractsm` is placed after it in the `bundler` array. Also, ensure `bit-bundler-extractsm` is not configured to `false` for the affected bundle or split.
Upgrade
Version history
2.1.4latest on npm
Audit
Dependencies
bit-bundlerrequiredThis is a plugin for bit-bundler and requires the core bundler to operate.
bit-bundler-minifyjsoptionalOften used in conjunction to generate source maps which bit-bundler-extractsm then processes.
Agent activity
5 hits · last 30 days
node
4
Resources
bit-bundler-extractsm — npm install bit-bundler-extractsm · libregistry