Comparing version 0.0.3 to 0.1.0
@@ -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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
17818
14
433
50
6
2
2
1
+ Addedlodash@1.3.x
+ Addedthrough@2.3.x
+ Addedlodash@1.3.1(transitive)
+ Addedthrough@2.3.8(transitive)