smart-source-map-loader
Advanced tools
Comparing version 1.2.0 to 1.3.0
@@ -37,3 +37,3 @@ "use strict"; | ||
const url = m[5] || m[8]; | ||
const body = code.substr(0, code.length - footer.length); | ||
const body = code.substring(0, code.length - footer.length); | ||
return { | ||
@@ -40,0 +40,0 @@ body, |
@@ -12,6 +12,9 @@ "use strict"; | ||
* Exception class. | ||
* | ||
* @param {string} message Exception message. | ||
*/ | ||
class Exception extends Error { | ||
/** | ||
* Exception constructor. | ||
* | ||
* @param {string} message Exception message. | ||
*/ | ||
constructor(message) { | ||
@@ -18,0 +21,0 @@ super(`${_meta.NAME}: ${message}`); |
@@ -14,2 +14,3 @@ "use strict"; | ||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; | ||
if (key in exports && exports[key] === _meta[key]) return; | ||
Object.defineProperty(exports, key, { | ||
@@ -95,3 +96,3 @@ enumerable: true, | ||
}(); | ||
} // eslint-disable-next-line import/no-default-export, jsdoc/require-jsdoc | ||
} // eslint-disable-next-line import/no-default-export, jsdoc/require-jsdoc, no-unused-vars | ||
@@ -238,3 +239,4 @@ | ||
if (!(0, _util.nullUndefined)(sourceContent) || (0, _util.isDataURI)(source)) { | ||
if ( // eslint-disable-next-line no-undefined | ||
sourceContent !== null && sourceContent !== undefined || (0, _util.isDataURI)(source)) { | ||
continue; | ||
@@ -244,3 +246,3 @@ } // Locate the source file. | ||
const sourcePath = (0, _util.joinURL)(sourceRoot, source); | ||
const sourcePath = `${sourceRoot}/${source}`; | ||
@@ -286,3 +288,3 @@ const sourceRequest = _loaderUtils.default.urlToRequest(sourcePath); // Resolve source file or emit warning and skip. | ||
(0, _util.sourceMapRebase)(mapData, mapFilePath); // All good, pass the body and parsed source map out. | ||
(0, _util.sourceMapRebase)(mapData, mapFilePath.replace(/\\/g, '/')); // All good, pass the body and parsed source map out. | ||
@@ -289,0 +291,0 @@ callback(null, parsed.body, mapData); |
@@ -6,4 +6,4 @@ "use strict"; | ||
}); | ||
exports.data = data; | ||
exports.decodePercents = decodePercents; | ||
exports.data = data; | ||
@@ -41,3 +41,3 @@ /** | ||
const base64 = /;base64$/iu.test(mediaInfo); | ||
const mediaType = base64 ? mediaInfo.substr(0, mediaInfo.length - 5) : mediaInfo; | ||
const mediaType = base64 ? mediaInfo.substring(0, mediaInfo.length - 5) : mediaInfo; | ||
const [mimeType] = mediaType.split(';', 1); | ||
@@ -53,2 +53,7 @@ const m2 = mediaType.match(/;charset=([^;]*)(;|$)/iu); | ||
/** | ||
* Get body. | ||
* | ||
* @returns {Buffer} Buffer data. | ||
*/ | ||
body() { | ||
@@ -55,0 +60,0 @@ return Buffer.from(decodePercents(data), base64 ? 'base64' : 'utf8'); |
@@ -6,18 +6,14 @@ "use strict"; | ||
}); | ||
exports.nullUndefined = nullUndefined; | ||
exports.decodeURISafe = decodeURISafe; | ||
exports.isAbsoluteURL = isAbsoluteURL; | ||
exports.isDataURI = isDataURI; | ||
exports.joinURL = joinURL; | ||
exports.resolveURL = resolveURL; | ||
exports.pathRelativeIfSub = pathRelativeIfSub; | ||
exports.pathResolve = pathResolve; | ||
exports.readFileAsync = readFileAsync; | ||
exports.rebaseURL = rebaseURL; | ||
exports.sourceMapMappings = sourceMapMappings; | ||
exports.sourceMapRebase = sourceMapRebase; | ||
exports.pathRelativeIfSub = pathRelativeIfSub; | ||
exports.stringAbbrev = stringAbbrev; | ||
exports.decodeURISafe = decodeURISafe; | ||
exports.stringOrBufferCast = stringOrBufferCast; | ||
exports.readFileAsync = readFileAsync; | ||
var _url = require("url"); | ||
var _path = require("path"); | ||
@@ -27,16 +23,6 @@ | ||
const rURL = /^(?:[\w+\-.]+:)?\/\//; | ||
const rURL = /^([a-z][a-z0-9.-]*:\/?\/?[^/]*|\/\/[^/]*|)([^?#]*)(.*)$/i; | ||
const rProto = /^[a-z][a-z0-9-.]*:/i; | ||
const rDataURI = /^data:/i; | ||
/** | ||
* Check if value if null or undefined. | ||
* | ||
* @param {*} value Any value. | ||
* @returns {boolean} Is either. | ||
*/ | ||
function nullUndefined(value) { | ||
// eslint-disable-next-line no-undefined | ||
return value === null || value === undefined; | ||
} | ||
/** | ||
* Check if absolute URL. | ||
@@ -48,9 +34,4 @@ * | ||
function isAbsoluteURL(uri) { | ||
if (uri[0] === '/') { | ||
return true; | ||
} | ||
return rURL.test(uri); | ||
return uri[0] === '/' || rProto.test(uri); | ||
} | ||
@@ -69,26 +50,35 @@ /** | ||
/** | ||
* Join URL parts on seperator character. | ||
* Clean a URL path of extra dot notation. | ||
* | ||
* @param {Array} parts URL parts. | ||
* @returns {string} Joined path. | ||
* @param {string} path URL pathname. | ||
* @returns Normalized pathname. | ||
*/ | ||
function joinURL(...parts) { | ||
return parts.join('/'); | ||
} | ||
/** | ||
* Resolve a URL path with no trailing slash. | ||
* | ||
* @param {string} from From path. | ||
* @param {string} to To path. | ||
* @returns {string} Full path. | ||
*/ | ||
function pathResolve(path) { | ||
let p = path; // Multiple slashes to slash. | ||
p = p.replace(/\/\/+/g, '/'); // Dot slash. | ||
function resolveURL(from, to) { | ||
return (0, _url.resolve)(from, to).replace(/\/$/, ''); | ||
p = p.replace(/^(\.\/)+/, ''); // Trailing slash dot to slash. | ||
p = p.replace(/\/\.$/, '/'); // Dot slash path components. | ||
p = p.replace(/\/(\.\/)+/g, '/'); | ||
for (;;) { | ||
// Leading, middle, and trailing, dot dot slash resolving. | ||
const v = p.replace(/(^|\/)(?!\.\.)[^/]+\/\.\.(\/|$)/g, '$1'); | ||
if (v === p) { | ||
break; | ||
} | ||
p = v; | ||
} | ||
return p === '.' ? '' : p; | ||
} | ||
/** | ||
* Rebase a URL path with no trailing slash. | ||
* Rebase a URL path. | ||
* | ||
@@ -106,3 +96,6 @@ * @param {string} from From path. | ||
return resolveURL(from, to); | ||
const [, fb, fp] = from.match(rURL); | ||
const [,, tp, te] = to.match(rURL); | ||
const path = tp ? pathResolve(fp.replace(/[^/]+$/, '') + tp) : fp; | ||
return fb + (fb && path[0] !== '/' ? '/' : '') + path + te; | ||
} | ||
@@ -146,3 +139,12 @@ /** | ||
function pathRelativeIfSub(from, to) { | ||
return to.indexOf(from) ? to : (0, _path.relative)(from, to); | ||
if (from === to) { | ||
return ''; | ||
} | ||
if (!from) { | ||
return to; | ||
} | ||
const pre = (0, _path.join)(from, '_').replace(/_$/, ''); | ||
return to.substring(0, pre.length) === pre ? to.substring(pre.length) : to; | ||
} | ||
@@ -160,7 +162,3 @@ /** | ||
function stringAbbrev(str, max, suffix = '') { | ||
if (str.length <= max) { | ||
return str; | ||
} | ||
return str.substr(0, max - suffix.length) + suffix; | ||
return str.length > max ? str.substring(0, max - suffix.length) + suffix : str; | ||
} | ||
@@ -167,0 +165,0 @@ /** |
{ | ||
"name": "smart-source-map-loader", | ||
"description": "A Smart Source Map Loader for Webpack", | ||
"version": "1.2.0", | ||
"version": "1.3.0", | ||
"keywords": [ | ||
@@ -19,7 +19,7 @@ "source-map", | ||
"author": "Alexander O'Mara", | ||
"copyright": "Copyright (c) 2018-2020 Alexander O'Mara", | ||
"copyright": "Copyright (c) 2018-2022 Alexander O'Mara", | ||
"license": "MPL-2.0", | ||
"main": "lib/index", | ||
"engines": { | ||
"node": ">=6.14.3" | ||
"node": ">=6.14.4" | ||
}, | ||
@@ -31,6 +31,8 @@ "repository": "https://github.com/AlexanderOMara/smart-source-map-loader.git", | ||
"lint": "gulp lint", | ||
"format": "gulp format", | ||
"formatted": "gulp formatted", | ||
"build": "gulp build", | ||
"test": "gulp test", | ||
"all": "gulp all", | ||
"watch": "nodemon --exec 'gulp watched'", | ||
"watch": "gulp watch", | ||
"prepack": "gulp prepack" | ||
@@ -42,36 +44,36 @@ }, | ||
"dependencies": { | ||
"loader-utils": "^2.0.0" | ||
"loader-utils": "^3.2.0" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^7.11.6", | ||
"@babel/preset-env": "^7.11.5", | ||
"@babel/register": "^7.11.5", | ||
"babel-loader": "^8.1.0", | ||
"del": "^6.0.0", | ||
"eslint": "^7.11.0", | ||
"eslint-plugin-import": "^2.22.1", | ||
"eslint-plugin-jsdoc": "^30.6.5", | ||
"execa": "^4.0.3", | ||
"@babel/core": "^7.18.6", | ||
"@babel/preset-env": "^7.18.6", | ||
"@babel/register": "^7.18.6", | ||
"babel-loader": "^8.2.5", | ||
"del": "^6.1.1", | ||
"eslint": "^8.19.0", | ||
"eslint-config-prettier": "^8.5.0", | ||
"eslint-plugin-import": "^2.26.0", | ||
"eslint-plugin-jsdoc": "^39.3.3", | ||
"execa": "^5.1.1", | ||
"gulp": "^4.0.2", | ||
"gulp-babel": "^8.0.0", | ||
"gulp-filter": "^6.0.0", | ||
"gulp-filter": "^7.0.0", | ||
"gulp-insert": "^0.5.0", | ||
"gulp-rename": "^2.0.0", | ||
"gulp-replace": "^1.0.0", | ||
"gulp-sourcemaps": "^2.6.5", | ||
"jasmine": "^3.6.1", | ||
"jasmine-core": "^3.6.0", | ||
"jasmine-spec-reporter": "^6.0.0", | ||
"gulp-replace": "^1.1.3", | ||
"gulp-sourcemaps": "^3.0.0", | ||
"jasmine": "3.6.1", | ||
"jasmine-core": "^3.7.1", | ||
"jasmine-spec-reporter": "^7.0.0", | ||
"memory-fs": "^0.5.0", | ||
"node-require-function": "^1.2.0", | ||
"nodemon": "^2.0.5", | ||
"promise.prototype.finally": "^3.1.2", | ||
"prettier": "^2.7.1", | ||
"promise.prototype.finally": "^3.1.3", | ||
"pump": "^3.0.0", | ||
"rimraf": "^3.0.2", | ||
"source-map-support": "^0.5.19", | ||
"webpack": "^5.1.0", | ||
"source-map-support": "^0.5.21", | ||
"webpack": "^5.73.0", | ||
"webpack-4-0-0": "npm:webpack@4.0.0", | ||
"webpack-4-44-2": "npm:webpack@4.44.2", | ||
"webpack-4-46-0": "npm:webpack@4.46.0", | ||
"webpack-5-0-0": "npm:webpack@5.0.0" | ||
} | ||
} |
@@ -8,9 +8,7 @@ # Smart Source Map Loader | ||
[![dependencies](https://img.shields.io/david/AlexanderOMara/smart-source-map-loader.svg)](https://david-dm.org/AlexanderOMara/smart-source-map-loader) | ||
[![size](https://packagephobia.now.sh/badge?p=smart-source-map-loader)](https://packagephobia.now.sh/result?p=smart-source-map-loader) | ||
[![downloads](https://img.shields.io/npm/dm/smart-source-map-loader.svg)](https://npmcharts.com/compare/smart-source-map-loader?minimal=true) | ||
[![travis-ci](https://travis-ci.org/AlexanderOMara/smart-source-map-loader.svg?branch=master)](https://travis-ci.org/AlexanderOMara/smart-source-map-loader) | ||
[![Build Status](https://github.com/AlexanderOMara/smart-source-map-loader/workflows/main/badge.svg?branch=master)](https://github.com/AlexanderOMara/smart-source-map-loader/actions?query=workflow%3Amain+branch%3Amaster) | ||
# Overview | ||
@@ -22,3 +20,2 @@ | ||
# Features | ||
@@ -35,3 +32,2 @@ | ||
# Usage | ||
@@ -57,11 +53,11 @@ | ||
module.exports = { | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.m?js$/i, | ||
use: ['smart-source-map-loader'], | ||
enforce: 'pre' | ||
} | ||
] | ||
} | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.m?js$/i, | ||
use: ['smart-source-map-loader'], | ||
enforce: 'pre' | ||
} | ||
] | ||
} | ||
}; | ||
@@ -72,2 +68,3 @@ ``` | ||
If you do include them though they will have the correct path in the source map. | ||
@@ -78,6 +75,5 @@ # Bugs | ||
# License | ||
Copyright (c) 2018-2020 Alexander O'Mara | ||
Copyright (c) 2018-2022 Alexander O'Mara | ||
@@ -84,0 +80,0 @@ Licensed under the Mozilla Public License, v. 2.0. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
67469
524
77
+ Addedloader-utils@3.3.1(transitive)
- Removedbig.js@5.2.2(transitive)
- Removedemojis-list@3.0.0(transitive)
- Removedjson5@2.2.3(transitive)
- Removedloader-utils@2.0.4(transitive)
Updatedloader-utils@^3.2.0