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

uglify-loader

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

uglify-loader - npm Package Compare versions

Comparing version 1.3.0 to 1.4.0

59

index.js
var UglifyJS = require("uglify-js");
var loaderUtils = require('loader-utils');
var sourceMap = require('source-map');
function mergeSourceMap(map, inputMap) {
var inputMapConsumer = new sourceMap.SourceMapConsumer(inputMap);
var outputMapConsumer = new sourceMap.SourceMapConsumer(map);
var mergedGenerator = new sourceMap.SourceMapGenerator({
file: inputMapConsumer.file,
sourceRoot: inputMapConsumer.sourceRoot
});
var source = outputMapConsumer.sources[0];
inputMapConsumer.eachMapping(function (mapping) {
var generatedPosition = outputMapConsumer.generatedPositionFor({
line: mapping.generatedLine,
column: mapping.generatedColumn,
source: source
});
if (generatedPosition.column != null) {
mergedGenerator.addMapping({
source: mapping.source,
original: mapping.source == null ? null : {
line: mapping.originalLine,
column: mapping.originalColumn
},
generated: generatedPosition
});
}
});
var mergedMap = mergedGenerator.toJSON();
inputMap.mappings = mergedMap.mappings;
return inputMap
};
module.exports = function(source, inputSourceMap) {

@@ -8,3 +45,3 @@ var callback = this.async();

if (this.cacheable) {
this.cacheable();
this.cacheable();
}

@@ -19,11 +56,15 @@

var result = UglifyJS.minify(source, opts);
var sourceFilename = loaderUtils.getRemainingRequest(this);
var current = loaderUtils.getCurrentRequest(this);
var sourceMap = JSON.parse(result.map);
sourceMap.sources = [sourceFilename];
sourceMap.file = current;
sourceMap.sourcesContent = [source];
callback(null, result.code, sourceMap);
};
if (inputSourceMap) {
callback(null, result.code, mergeSourceMap(sourceMap, inputSourceMap));
} else {
var sourceFilename = loaderUtils.getRemainingRequest(this);
var current = loaderUtils.getCurrentRequest(this);
sourceMap.sources = [sourceFilename];
sourceMap.file = current;
sourceMap.sourcesContent = [source];
callback(null, result.code, sourceMap);
}
};

3

package.json
{
"name": "uglify-loader",
"version": "1.3.0",
"version": "1.4.0",
"description": "Uglify.js loader for webpack",

@@ -25,4 +25,5 @@ "main": "index.js",

"loader-utils": "^0.2.7",
"source-map": "^0.5.6",
"uglify-js": "^2.4.16"
}
}
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