Skip to content

Commit

Permalink
feat: remove lodash dependency
Browse files Browse the repository at this point in the history
This module is not using the vast majority of Lodash's functions. The
small handful used can be replaced by more targeted dependencies that
still supports the full range of Node.js versions gulp-uglify supports.

Bug: #351
  • Loading branch information
terinjokes committed Mar 1, 2019
1 parent bcdda44 commit a56d1c7
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ matrix:
- node_js: 10
script: npm run lint
script:
- node --throw-deprecation ./node_modules/.bin/tape --require intelli-espower-loader test/*.js
- node --throw-deprecation ./node_modules/.bin/tape test/*.js
3 changes: 1 addition & 2 deletions lib/create-error.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
'use strict';
var curry = require('lodash/fp/curry');
var GulpUglifyError = require('./gulp-uglify-error');

function createError(file, msg, cause) {
Expand All @@ -10,4 +9,4 @@ function createError(file, msg, cause) {
return perr;
}

module.exports = curry(createError);
module.exports = createError;
6 changes: 3 additions & 3 deletions lib/log.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
'use strict';
var hasLog = require('has-gulplog');
var each = require('lodash/fp/forEach');
var each = require('array-each');

var levels = ['debug', 'info', 'warn', 'error'];

each(function(level) {
each(levels, function(level) {
module.exports[level] = function() {
if (hasLog()) {
var log = require('gulplog');

log[level].apply(log, arguments);
}
};
}, levels);
});
7 changes: 4 additions & 3 deletions lib/minify.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
'use strict';
var Buffer = require('safe-buffer').Buffer;
var applySourceMap = require('vinyl-sourcemaps-apply');
var isObject = require('lodash/fp/isObject');
var defaultsDeep = require('lodash/fp/defaultsDeep');
var isObject = require('isobject');
var extend = require('extend-shallow');
var createError = require('./create-error');

module.exports = function(uglify, log) {
Expand All @@ -12,7 +12,8 @@ module.exports = function(uglify, log) {
opts = {};
}

return defaultsDeep(
return extend(
{},
{
output: {}
},
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
"author": "Terin Stock <terinjokes@gmail.com>",
"bugs": "https://github.com/terinjokes/gulp-uglify/issues",
"dependencies": {
"array-each": "^1.0.1",
"extend-shallow": "^3.0.2",
"gulplog": "^1.0.0",
"has-gulplog": "^0.1.0",
"lodash": "^4.13.1",
"isobject": "^3.0.1",
"make-error-cause": "^1.1.1",
"safe-buffer": "^5.1.2",
"through2": "^2.0.0",
Expand All @@ -21,7 +23,6 @@
"eslint-plugin-no-use-extend-native": "^0.3.12",
"eslint-plugin-prettier": "^2.0.1",
"eslint-plugin-unicorn": "^2.1.0",
"intelli-espower-loader": "^1.0.1",
"power-assert": "^1.4.1",
"prettier": "^1.1.0",
"source-list-map": "^1.1.2",
Expand Down Expand Up @@ -70,7 +71,7 @@
],
"scripts": {
"lint": "eslint *.js lib test",
"test": "tape --require intelli-espower-loader test/*.js"
"test": "tape test/*.js"
},
"greenkeeper": {
"ignore": [
Expand Down

0 comments on commit a56d1c7

Please sign in to comment.