Registry / devops / jsmin-sourcemap

jsmin-sourcemap

JSON →
library0.16.0jsnpmunverified

A command-line tool and library that applies JSMin minification while generating source maps. Version 0.16.0 is the latest release; the project has seen sporadic updates with no recent activity. It differentiates from plain JSMin by producing source maps for debugging minified JavaScript, useful in build pipelines. The library offers a Node.js API and CLI interface with basic minification and source map generation.

npm install jsmin-sourcemap
INSTALL
IMPORT
SIG · JSMIN-SOURCEMAP
J
jsmin-sourcemap
devopsjavascriptv0.16.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.

jsminSourcemap
import { jsminSourcemap } from 'jsmin-sourcemap';
const jsminSourcemap = require('jsmin-sourcemap');
ESM import preferred; CJS require works but may be deprecated.
jsminSourcemap
const jsminSourcemap = require('jsmin-sourcemap');
CommonJS import for Node.js, still supported.

Shows how to minify a JavaScript file and generate a source map using the jsminSourcemap function.

import { jsminSourcemap } from 'jsmin-sourcemap'; import fs from 'fs'; const code = fs.readFileSync('input.js', 'utf8'); const result = jsminSourcemap(code, { sourceFile: 'input.js', destFile: 'output.min.js' }); console.log(result.code); // Minified code console.log(result.map); // Source map (string) fs.writeFileSync('output.min.js', result.code); fs.writeFileSync('output.min.js.map', result.map);
Debug
Known issues
gotchaThe jsminSourcemap function expects a string of code; if you pass an object or buffer, it may fail silently.
fix
Ensure the first argument is a string (use .toString() or .utf8Slice() if needed).
affects: >=0.1.0
gotchaSource map generation requires the 'sourceFile' option; if omitted, the source map may be incorrect.
fix
Always provide the 'sourceFile' option (and optionally 'destFile') to get correct source mappings.
affects: >=0.1.0
breakingStarting from version 0.12.0, the output source map format changed from inline base64 to separate file reference. If you relied on inline maps, upgrade with caution.
fix
If you need inline maps, set the 'inlineMap' option to true in the options object.
affects: >=0.12.0
deprecatedThe CLI tool has been deprecated since version 0.15.0; use the API programmatically instead.
fix
Migrate to using the JavaScript API (jsminSourcemap function) and maintain your own CLI wrapper if needed.
affects: >=0.15.0
gotchaThe package does not support TypeScript type definitions; you must write your own or ignore type errors.
fix
Add a declaration file (e.g., declare module 'jsmin-sourcemap') or use @ts-ignore.
affects: >=0.1.0
Errors
Common errors & fixes
TypeError: Cannot read property 'code' of undefined
The jsminSourcemap function returned undefined, likely due to invalid input (non-string code).
fix
Ensure the first argument is a valid JavaScript string and not empty.
Error: sourceFile must be a non-empty string
The 'sourceFile' option is missing or empty.
fix
Pass a sourceFile property in the options object.
Error: destFile must be a string if provided
The 'destFile' option is not a string (e.g., number or object).
fix
Ensure destFile is a string (filename) or omit it.
Upgrade
Version history
0.16.0latest on npm
Audit
Dependencies
jsminrequiredCore minification engine; jsmin-sourcemap wraps jsmin for minification.
source-maprequiredFor generating and manipulating source maps.
Agent activity
7 hits · last 30 days
node
6
Resources
jsmin-sourcemap — npm install jsmin-sourcemap · libregistry