Skip to content

Commit

Permalink
Drop camelcase
Browse files Browse the repository at this point in the history
Camelcase package was used in two cases

1. Converting package name which is simply hardcoded.
2. Converting codec name to format compatible. "format" is more often
used option so we assume codec names are camel cased as well.
  • Loading branch information
TrySound committed Aug 8, 2020
1 parent 72f9df1 commit 03910d7
Show file tree
Hide file tree
Showing 13 changed files with 23 additions and 49 deletions.
2 changes: 1 addition & 1 deletion codec/absolute.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ function encode(absolute) {
* @returns {string|undefined} The source-map root applicable to any encoded uri
*/
function root() {
}
}
4 changes: 2 additions & 2 deletions codec/bower-component.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @type {{name:string, decode:function, abstract:boolean}}
*/
module.exports = {
name : 'bower-component',
name : 'bowerComponent',
decode : decode,
abstract: true
};
Expand All @@ -18,4 +18,4 @@ module.exports = {
*/
function decode(uri) {
return /^\/?([\w-]+)\s+\(bower component\)$/.test(uri);
}
}
4 changes: 2 additions & 2 deletions codec/npm-module.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ var getContextDirectory = require('./utility/get-context-directory');
* @type {{name:string, decode: function}}
*/
module.exports = {
name : 'npm-module',
name : 'npmModule',
decode: decode
};

Expand All @@ -32,4 +32,4 @@ function decode(uri) {
isValid = !!absFile && fs.existsSync(absFile) && fs.statSync(absFile).isFile();
return isValid && absFile;
}
}
}
4 changes: 2 additions & 2 deletions codec/output-relative.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ var getOutputDirectory = require('./utility/get-output-directory');
* @type {{name:string, decode: function, encode: function, root: function}}
*/
module.exports = {
name : 'output-relative',
name : 'outputRelative',
decode: decode,
encode: encode,
root : getOutputDirectory
Expand Down Expand Up @@ -46,4 +46,4 @@ function encode(absolute) {
else {
return path.relative(base, absolute);
}
}
}
4 changes: 2 additions & 2 deletions codec/project-relative.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ var getContextDirectory = require('./utility/get-context-directory'),
* @type {{name:string, decode: function, encode: function, root: function}}
*/
module.exports = {
name : 'project-relative',
name : 'projectRelative',
decode: decode,
encode: encode,
root : getContextDirectory
Expand Down Expand Up @@ -47,4 +47,4 @@ function encode(absolute) {
else {
return '/' + enhancedRelative(base, absolute);
}
}
}
4 changes: 2 additions & 2 deletions codec/source-relative.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ var path = require('path'),
* @type {{name:string, decode: function, encode: function, root: function}}
*/
module.exports = {
name : 'source-relative',
name : 'sourceRelative',
decode: decode,
encode: encode,
root : root
Expand Down Expand Up @@ -49,4 +49,4 @@ function encode(absolute) {
function root() {
/* jshint validthis:true */
return this.context;
}
}
4 changes: 2 additions & 2 deletions codec/webpack-bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @type {{name:string, decode:function, abstract:boolean}}
*/
module.exports = {
name : 'webpack-bootstrap',
name : 'webpackBootstrap',
decode : decode,
abstract: true
};
Expand All @@ -18,4 +18,4 @@ module.exports = {
*/
function decode(uri) {
return /^webpack\/bootstrap\s+\w{20}$/.test(uri);
}
}
4 changes: 2 additions & 2 deletions codec/webpack-protocol.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ var projectRelative = require('./project-relative');
* @type {{name:string, decode: function, encode: function, root: function}}
*/
module.exports = {
name : 'webpack-protocol',
name : 'webpackProtocol',
decode: decode,
encode: encode,
root : root
Expand Down Expand Up @@ -42,4 +42,4 @@ function encode(absolute) {
* @returns {string|undefined} The source-map root applicable to any encoded uri
*/
function root() {
}
}
9 changes: 3 additions & 6 deletions lib/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@

var path = require('path');

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

var PACKAGE_NAME = require('../package.json').name;
var loaderUtils = require('loader-utils');

var process = require('./process');

Expand All @@ -28,7 +25,7 @@ function loader(content, sourceMap) {
// webpack 4: loader.options no longer defined
var options = Object.assign(
{},
this.options && this.options[camelcase(PACKAGE_NAME)],
this.options && this.options.adjustSourcemapLoader,
loaderUtils.getOptions(this),
{sep: path.sep}
);
Expand All @@ -40,4 +37,4 @@ function loader(content, sourceMap) {
this.callback(null, content, outputMap);
}

module.exports = loader;
module.exports = loader;
6 changes: 2 additions & 4 deletions lib/process/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
'use strict';

var camelcase = require('camelcase');

var debugMessage = require('./debug-message'),
toRegExp = require('./to-reg-exp'),
throwErrors = require('./throw-errors'),
Expand Down Expand Up @@ -104,7 +102,7 @@ function process(context, opt, sourceMapOrSource) {
return inputMap ? outputMap : outputSources ? outputSources[0] : undefined;

function testNamedCodec(value) {
return (camelcase(value.name) === options.format);
return (value.name === options.format);
}

function insertAbstractSources(value, i) {
Expand All @@ -116,4 +114,4 @@ function process(context, opt, sourceMapOrSource) {
}
}

module.exports = process;
module.exports = process;
24 changes: 2 additions & 22 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
},
"homepage": "https://github.com/bholloway/adjust-sourcemap-loader",
"dependencies": {
"camelcase": "5.0.0",
"loader-utils": "1.2.3",
"object-path": "0.11.4",
"regex-parser": "2.2.10"
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ Where `...` is a hash of any of the following options.

* **`fail`** : `boolean` Implies an **Error** if a source-map source cannot be decoded.

* **`format`** : `string` Optional output format for source-map `sources`. Must be the camel-case name of one of the available `codecs`. Omitting the format will result in **no change** and the outgoing source-map will match the incomming one.
* **`format`** : `string` Optional output format for source-map `sources`. Must be the name of one of the available `codecs`. Omitting the format will result in **no change** and the outgoing source-map will match the incomming one.

* **`root`** : `boolean` A boolean flag that indices that a `sourceRoot` path sould be included in the output map. This is contingent on a `format` being specified.

Expand Down

0 comments on commit 03910d7

Please sign in to comment.