Skip to content

Commit

Permalink
remove lodash, update deps
Browse files Browse the repository at this point in the history
  • Loading branch information
bholloway committed Feb 13, 2019
1 parent 179d8be commit d1180e9
Show file tree
Hide file tree
Showing 6 changed files with 106 additions and 175 deletions.
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
6
4 changes: 1 addition & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
*/
'use strict';

var assign = require('lodash.assign');

module.exports = assign(require('./lib/loader'), {
module.exports = Object.assign(require('./lib/loader'), {
moduleFilenameTemplate: require('./lib/module-filename-template'),
codec : require('./codec')
});
10 changes: 5 additions & 5 deletions lib/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
var path = require('path');

var loaderUtils = require('loader-utils'),
camelcase = require('camelcase'),
defaults = require('lodash.defaults');
camelcase = require('camelcase');

var PACKAGE_NAME = require('../package.json').name;

Expand All @@ -27,10 +26,11 @@ function loader(content, sourceMap) {
// webpack 2: prefer loader options
// webpack 3: deprecate loader.options object
// webpack 4: loader.options no longer defined
var options = defaults(
{sep: path.sep},
var options = Object.assign(
{},
this.options && this.options[camelcase(PACKAGE_NAME)],
loaderUtils.getOptions(this),
this.options && this.options[camelcase(PACKAGE_NAME)]
{sep: path.sep}
);

// process the source-map
Expand Down
14 changes: 6 additions & 8 deletions lib/process/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
'use strict';

var assign = require('lodash.assign'),
defaults = require('lodash.defaults'),
camelcase = require('camelcase');
var camelcase = require('camelcase');

var debugMessage = require('./debug-message'),
toRegExp = require('./to-reg-exp'),
Expand All @@ -17,21 +15,21 @@ var CODECS = require('../../codec');
/**
* Process the given source-map per the given options.
* @param {{resourcePath:string, context:string, output:{path:string}}} context A loader or compilation
* @param {{debug:boolean, fail:boolean, format:string|boolean, root:string, codecs:object}} options Options hash
* @param {{debug:boolean, fail:boolean, format:string|boolean, root:string, codecs:object}} opt Options hash
* @param {object|string} sourceMapOrSource An incoming source-map or single source path
* @returns {undefined|object|string} An amended source-map or source path else undefined
*/
function process(context, options, sourceMapOrSource) {
function process(context, opt, sourceMapOrSource) {

// default options
defaults(options, {
var options = Object.assign({
sep : '/',
debug : false,
fail : false,
format: false,
root : false,
codecs: CODECS
});
}, opt);

// validate codecs
var codecs = options.codecs
Expand All @@ -58,7 +56,7 @@ function process(context, options, sourceMapOrSource) {
throwErrors(context.resourcePath, absoluteSources);

// output map is a copy unless absent or we are removing
outputMap = (!inputMap || (options.format === 'remove')) ? undefined : assign({}, inputMap);
outputMap = (!inputMap || (options.format === 'remove')) ? undefined : Object.assign({}, inputMap);

// some change in format
if (options.format) {
Expand Down
Loading

0 comments on commit d1180e9

Please sign in to comment.