Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

minifyify

Package Overview
Dependencies
Maintainers
1
Versions
98
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

minifyify - npm Package Compare versions

Comparing version 0.0.3 to 0.1.0

Jakefile

16

package.json

@@ -8,6 +8,9 @@ {

"browserify",
"transform",
"minify",
"envify",
"uglifyify",
"compress"
],
"version": "0.0.3",
"version": "0.1.0",
"repository": {

@@ -17,3 +20,3 @@ "type": "git",

},
"main": "./index.js",
"main": "./lib/index.js",
"dependencies": {

@@ -23,6 +26,11 @@ "concat-stream": "1.0.x",

"source-map": "0.1.x",
"uglify-js": "2.3.x"
"uglify-js": "2.3.x",
"through": "2.3.x",
"lodash": "1.3.x"
},
"scripts": {},
"devDependencies": {},
"devDependencies": {
"browserify": "latest"
, "jake": "latest"
},
"optionalDependencies": {},

@@ -29,0 +37,0 @@ "engines": {

Minifyify
---------
##### Minify your browserify bundle without losing the sourcemap
#### Tiny, Debuggable Browserify Bundles
Before, you had to choose between sane debugging and sane load times. Now, you can have both.
Browserify in debug mode tacks on a massive sourceMappingURL with your uncompressed source code, on top of the already uncompressed bundle, resulting in a single massive Javascript file **more than twice as large as your original source code.**
Minifyify minifies your bundle and pulls the source map out into a separate file. Now you can **deploy a minified bundle in production, and still have a sourcemap handy for when things inevitably break**.
**Bonus:** Since Minifyify is a transform, dead code paths are removed before Browserify processes `require()`s. You only get the modules you actually use in the final bundle. Works great with [envify](https://npmjs.org/package/envify)!
## Usage
Just like how you would use `concat-stream`.
```js
var mold = require('mold-source-map')
, browserify = require('browserify')
var browserify = require('browserify')
, minifyify = require('minifyify')
, bundle = browserify();
, bundle = new browserify()
, minifier;
bundle.add(something);
// Create a new minifier object for each bundle
// (All options are optional, but highly recommended)
minifier = new minifyify({
source: 'bundle.js' // Where you intend to place the generated bundle
, map: 'bundle.map' // Where you intend to place the generated sourcemap
, transformPaths: // Great for shortening your source paths
function (filePath) {
// This will make all paths relative to 'project_dir'
return path.relative('project_dir', filePath);
}
});
bundle.add('entryScript.js');
// Note: Pass browserify the transformer, not the minifier object
bundle.transform(minifier.transformer);
// You *must* run in debug mode!
bundle.bundle({debug: true})
.on('error', function (err) { console.error(err); })
// Shorten your source maps
.pipe(mold.transformSourcesRelativeTo(path.dirname(inputFile)))
// Magic happens here
.pipe(minifyify(function (src, map) {
// Don't forget to append the sourceMappingURL yourself
fs.writeFileSync(OUTPUT_FILE, src + ';\n//@ sourceMappingURL=/scripts.map\n');
fs.writeFileSync(OUTPUT_MAP, map);
});
// Pipe to the consumer to receive your minified code and accompanying sourcemap
.pipe(minifier.consumer(function(code, map) {
fs.writeFileSync('www/bundle.js', code);
fs.writeFileSync('www/bundle.map', map);
}));
```

@@ -31,0 +47,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc