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

gulp-uglify

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gulp-uglify - npm Package Compare versions

Comparing version 0.2.1 to 0.3.0

test/sourcemap.js

15

CHANGELOG.md
# gulp-uglify changelog
## 0.3.0
- Removed support for old style source maps
- Added support for gulp-sourcemap
- Updated tape development dependency
- Dropped support for Node 0.9
- UglifyJS errors are no longer swallowed
## 0.2.1
- Correct source map output
- Remove `gulp` dependency by using `vinyl` in testing
- Passthrough null files correctly
- Report error if attempting to use a stream-backed file
## 0.2.0

@@ -4,0 +19,0 @@

41

index.js

@@ -5,3 +5,2 @@ 'use strict';

merge = require('deepmerge'),
Vinyl = require('vinyl'),
uglifyError = require('./lib/error.js');

@@ -20,3 +19,6 @@

if (file.isStream()) {
return callback(uglifyError('Streaming not supported'));
return callback(uglifyError('Streaming not supported', {
fileName: file.path,
showStack: false
}));
}

@@ -30,7 +32,8 @@

var mangled,
map,
sourceMap;
originalSourceMap;
if (options.outSourceMap === true) {
options.outSourceMap = file.relative + '.map';
if (file.sourceMap) {
options.outSourceMap = file.relative;
options.inSourceMap = file.sourceMap;
originalSourceMap = file.sourceMap;
}

@@ -50,21 +53,19 @@

file.contents = new Buffer(mangled.code);
this.push(file);
} catch (e) {
console.warn('Error caught from uglify: ' + e.message + ' in ' + file.path + '. Returning unminifed code');
this.push(file);
return callback();
return callback(uglifyError(e.message, {
fileName: file.path,
lineNumber: e.line,
stack: e.stack,
showStack: false
}));
}
if (options.outSourceMap) {
sourceMap = JSON.parse(mangled.map);
sourceMap.sources = [ file.relative ];
map = new Vinyl({
cwd: file.cwd,
base: file.base,
path: file.path + '.map',
contents: new Buffer(JSON.stringify(sourceMap))
});
this.push(map);
if (file.sourceMap) {
file.sourceMap = JSON.parse(mangled.map);
file.sourceMap.sourcesContent = originalSourceMap.sourcesContent;
file.sourceMap.sources = originalSourceMap.sources;
}
this.push(file);
callback();

@@ -71,0 +72,0 @@ }

{
"name": "gulp-uglify",
"description": "Minify files with UglifyJS.",
"version": "0.2.1",
"version": "0.3.0",
"author": "Terin Stock <terinjokes@gmail.com>",
"bugs": "https://github.com/terinjokes/gulp-uglify/issues",
"dependencies": {

@@ -10,7 +11,8 @@ "deepmerge": "~0.2.7",

"through2": "~0.4.0",
"uglify-js": "~2.4.6",
"vinyl": "~0.2.3"
"uglify-js": "~2.4.6"
},
"devDependencies": {
"tape": "~2.4.2"
"inline-source-map": "^0.3.0",
"tape": "^2.12.3",
"vinyl": "~0.2.3"
},

@@ -17,0 +19,0 @@ "engines": {

@@ -1,19 +0,5 @@

[![Build Status](https://travis-ci.org/terinjokes/gulp-uglify.png?branch=master)](https://travis-ci.org/terinjokes/gulp-uglify)
# gulp-uglify [![Build Status](http://img.shields.io/travis/terinjokes/gulp-uglify.svg)](https://travis-ci.org/terinjokes/gulp-uglify) [![](http://img.shields.io/npm/dm/gulp-uglify.svg)](https://www.npmjs.org/package/gulp-uglify) [![](http://img.shields.io/npm/v/gulp-uglify.svg)](https://www.npmjs.org/package/gulp-uglify) [![](http://img.shields.io/codeclimate/github/terinjokes/gulp-uglify.svg)](https://codeclimate.com/github/terinjokes/gulp-uglify)
## Information
> Minify JavaScript with UglifyJS2.
<table>
<tr>
<td>Package</td><td>gulp-uglify</td>
</tr>
<tr>
<td>Description</td>
<td>Minify files with UglifyJS.</td>
</tr>
<tr>
<td>Node Version</td>
<td>≥ 0.9</td>
</tr>
</table>
## Usage

@@ -26,3 +12,3 @@

gulp.src('lib/*.js')
.pipe(uglify({outSourceMap: true}))
.pipe(uglify())
.pipe(gulp.dest('dist'))

@@ -56,3 +42,3 @@ });

- `all`
Preserve all comments in code blocks

@@ -74,11 +60,1 @@

UglifyJS's behavior.
### Source Maps
You can have UglifyJS’s generated source maps emitted on the stream by passing
`true` for the `outSourceMap` option. The file object’s path will be based on
the input file’s, with ‘.map’ appended.
Input source maps are no supported by this plugin at this time.
'use strict';
var test = require('tape'),
Vinyl = require('vinyl'),
gulpUglify = require('../'),
uglifyjs = require('uglify-js');
gulpUglify = require('../');
var testContentsInput = '"use strict"; (function(console, first, second) { console.log(first + second) }(5, 10))';
var testContentsExpected = uglifyjs.minify(testContentsInput, {fromString: true}).code;
var testContentsInput = 'function errorFunction(error)\n{';

@@ -17,17 +15,18 @@ var testFile1 = new Vinyl({

test('should preserve files in err', function(t) {
t.plan(7);
test('should report files in error', function(t) {
t.plan(6);
var stream = gulpUglify();
stream.on('data', function(newFile) {
t.ok(newFile, 'emits a file');
t.ok(newFile.path, 'file has a path');
t.ok(newFile.relative, 'file has relative path information');
t.ok(newFile.contents, 'file has contents');
stream.on('data', function() {
t.fail('we shouldn\'t have gotten here');
});
t.ok(newFile instanceof Vinyl, 'file is Vinyl');
t.ok(newFile.contents instanceof Buffer, 'file contents are a buffer');
t.equals(String(newFile.contents), testContentsExpected);
stream.on('error', function(e) {
t.ok(e instanceof Error, 'argument should be of type error');
t.equal(e.plugin, 'gulp-uglify', 'error is from gulp-uglify');
t.equal(e.fileName, testFile1.path, 'error reports correct file name');
t.equal(e.lineNumber, 2, 'error reports correct line number');
t.ok(e.stack, 'error has a stack');
t.false(e.showStack, 'error is configured to not print the stack');
});

@@ -34,0 +33,0 @@

'use strict';
var test = require('tape'),
Vinyl = require('vinyl'),
gulpUglify = require('../');
gulpUglify = require('../'),
uglifyjs = require('uglify-js');
var testContentsInput = 'function errorFunction(error) {';
var testContentsInput = '"use strict"; (function(console, first, second) { console.log(first + second) }(5, 10))';
var testContentsExpected = uglifyjs.minify(testContentsInput, {fromString: true}).code;

@@ -29,3 +31,3 @@ var testFile1 = new Vinyl({

t.equals(String(newFile.contents), testContentsInput);
t.equals(String(newFile.contents), testContentsExpected);
});

@@ -32,0 +34,0 @@

@@ -19,3 +19,3 @@ 'use strict';

test('should emit error for stream files', function(t) {
t.plan(3);
t.plan(6);

@@ -32,2 +32,5 @@ var stream = gulpUglify();

t.equal(e.plugin, 'gulp-uglify', 'error is from gulp-uglify');
t.equal(e.fileName, testFile1.path, 'error reports the correct file');
t.ok(e.stack, 'error has a stack');
t.false(e.showStack, 'error is configured to not print stack');
});

@@ -34,0 +37,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