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.2 to 0.0.3

75

index.js

@@ -21,34 +21,23 @@ var concat = require('concat-stream')

// Fixes uglify warnings from the browserify prelude
var fixSourcemapForPrelude = function (sourcemap, cb) {
// Yeah, this is weird, but we want to use the prelude.js that browserify depends on
var BROWSER_PACK_FILE = path.join(__dirname, 'node_modules', 'browserify', 'node_modules', 'browser-pack', '_prelude.js');
var fixSourcemapForPrelude = function (sourcemap) {
var consumer = new SMConsumer(sourcemap)
, preludeConsumer
, generator = SMGenerator.fromSourceMap(consumer)
, srcFile = '/node_modules/browserify/node_modules/browser-pack/_prelude.js'
, preludeParsed
, outputMap;
fs.readFile(BROWSER_PACK_FILE, function (err, preludeData) {
if(err) {
return cb(err);
}
// Just map to the minifed version, after all nothing should be going wrong in there
generator.addMapping({
generated: {line:1, column: 0}
, original: {line:1, column: 0}
, source: srcFile
});
var consumer = new SMConsumer(sourcemap)
, preludeConsumer
, generator = SMGenerator.fromSourceMap(consumer)
, srcFile = '/node_modules/browserify/node_modules/browser-pack/_prelude.js'
, preludeParsed
, outputMap;
// Add the original prelude file
generator.setSourceContent(srcFile, '(`browser-pack` prelude)');
preludeData = preludeData.toString();
outputMap = generator.toString();
// Just map to the minifed version, after all nothing should be going wrong in there
generator.addMapping({
generated: {line:1, column: 0}
, original: {line:1, column: 0}
, source: srcFile
});
// Add the original prelude file
generator.setSourceContent(srcFile, preludeData)
outputMap = generator.toString();
cb(null, outputMap);
});
return outputMap;
};

@@ -131,3 +120,7 @@

fixSourcemapForPrelude(outBuff.map, function (err, newmap) {
outBuff.map = fixSourcemapForPrelude(outBuff.map);
fs.writeFile(TMP_FILE, outBuff.map, function (err) {
var minBuff;
if(err) {

@@ -137,19 +130,11 @@ return cb(err);

fs.writeFile(TMP_FILE, newmap, function (err) {
var minBuff;
minBuff = uglify.minify(outBuff.code, {
inSourceMap: TMP_FILE,
outSourceMap: 'js/scripts.map',
fromString: true
});
if(err) {
return cb(err);
}
minBuff.map = enhanceSourcemapWithContent(outBuff.map, minBuff.map);
minBuff = uglify.minify(outBuff.code, {
inSourceMap: TMP_FILE,
outSourceMap: 'js/scripts.map',
fromString: true
});
minBuff.map = enhanceSourcemapWithContent(outBuff.map, minBuff.map);
cb(minBuff.code, minBuff.map);
});
cb(minBuff.code, minBuff.map);
});

@@ -159,2 +144,2 @@ });

module.exports = minifyify;
module.exports = minifyify;

@@ -11,3 +11,3 @@ {

],
"version": "0.0.2",
"version": "0.0.3",
"repository": {

@@ -22,4 +22,3 @@ "type": "git",

"source-map": "0.1.x",
"uglify-js": "2.3.x",
"browserify": "latest"
"uglify-js": "2.3.x"
},

@@ -26,0 +25,0 @@ "scripts": {},

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