Registry / devops / source-js-minifier

source-js-minifier

JSON →
library0.0.4jsnpmunverified

source-js-minifier v0.0.4 is a CLI tool that downloads a webpage from a given URL, fixes relative URLs, minifies CSS stylesheets in-place, and replaces or concatenates JavaScript with a minified version (using terser or a custom minifier built with acorn/recast/astring). It is a demonstration/work-in-progress project with no active release cadence. Key differentiators include optional concatenation of all scripts, CSS minification, and an experimental custom minifier using AST manipulation. However, it is unstable, lacks tests, and is not recommended for production use.

npm install source-js-minifier
INSTALL
IMPORT
SIG · SOURCE-JS-MINIFIER
S
source-js-minifier
devopsjavascriptv0.0.4
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.

none
No programmatic API; CLI tool only
const minifier = require('source-js-minifier');
This package is a CLI tool, not a library. Use via command line: node node_modules/.bin/source-js-minifier or npx.

Downloads example.com, minifies and concatenates all JS, minifies CSS, and opens result in browser.

npx source-js-minifier minify https://example.com --concatenate --css
Debug
Known issues
gotchaPackage is a work-in-progress demonstration; no stability guarantees.
fix
Do not use in production. Evaluate alternatives like terser or html-minifier.
affects: >=0.0.0
gotchanode-fetch only supports ESM; require() usage may fail in older Node.js versions.
fix
Use Node.js >= 18 or add type: 'module' to package.json, or use dynamic import.
affects: <=0.0.4
gotchaOutput files are overwritten in ./output/ without prompt.
fix
Ensure ./output/ is empty or backed up before running.
affects: >=0.0.0
gotchaNo proper error handling; crashes on invalid URLs or network issues.
fix
Validate URL manually and ensure network connectivity.
affects: >=0.0.0
Errors
Common errors & fixes
Error: Cannot find module 'node-fetch'
node-fetch v3+ is ESM-only and may not resolve correctly in a CJS context.
fix
Use Node.js >= 18 or add type: 'module' to package.json, or downgrade node-fetch to v2.
TypeError: fetch is not a function
node-fetch v3 exports default as a named export; CommonJS require() returns the module object.
fix
Use `const fetch = (...args) => import('node-fetch').then(({default: fetch}) => fetch(...args));`
Upgrade
Version history
0.0.4latest on npm
Audit
Dependencies
commanderrequiredCLI command parsing
node-fetchrequiredHTTP requests to download webpage and assets
terserrequiredJavaScript minification
parse5-utilsrequiredHTML parsing and manipulation
openrequiredOpen resultant webpage in browser
clean-cssrequiredCSS minification
acornoptionalJavaScript parsing for custom minifier
recastoptionalAST manipulation for custom minifier
astringoptionalCode generation from AST for custom minifier
Agent activity
2 hits · last 30 days
node
2
Resources
source-js-minifier — npm install source-js-minifier · libregistry