@parcel/utils
Advanced tools
Comparing version 2.0.0-nightly.295 to 2.0.0-nightly.298
@@ -28,3 +28,3 @@ "use strict"; | ||
let sourceMap = new _sourceMap.default(); | ||
sourceMap.addRawMappings(rawMap.mappings, rawMap.sources, rawMap.names); | ||
sourceMap.addRawMappings(rawMap); | ||
let parsedMapData = sourceMap.getMap(); | ||
@@ -31,0 +31,0 @@ |
@@ -17,18 +17,16 @@ "use strict"; | ||
var _path = require("./path"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function normalizePath(p) { | ||
return p.replace(/\\/g, '/'); | ||
} | ||
function isGlob(p) { | ||
return (0, _isGlob2.default)(normalizePath(p)); | ||
return (0, _isGlob2.default)((0, _path.normalizeSeparators)(p)); | ||
} | ||
function isGlobMatch(filePath, glob) { | ||
return (0, _micromatch.isMatch)(filePath, normalizePath(glob)); | ||
return (0, _micromatch.isMatch)(filePath, (0, _path.normalizeSeparators)(glob)); | ||
} | ||
function globSync(p, options) { | ||
return _fastGlob.default.sync(normalizePath(p), options); | ||
return _fastGlob.default.sync((0, _path.normalizeSeparators)(p), options); | ||
} | ||
@@ -71,3 +69,3 @@ | ||
return (0, _fastGlob.default)(normalizePath(p), options); | ||
return (0, _fastGlob.default)((0, _path.normalizeSeparators)(p), options); | ||
} |
@@ -22,3 +22,2 @@ "use strict"; | ||
urlJoin: true, | ||
loadSourceMapUrl: true, | ||
relativeUrl: true, | ||
@@ -120,8 +119,2 @@ createDependencyLocation: true, | ||
}); | ||
Object.defineProperty(exports, "loadSourceMapUrl", { | ||
enumerable: true, | ||
get: function () { | ||
return _loadSourceMapUrl.default; | ||
} | ||
}); | ||
Object.defineProperty(exports, "relativeUrl", { | ||
@@ -199,4 +192,2 @@ enumerable: true, | ||
var _loadSourceMapUrl = _interopRequireDefault(require("./loadSourceMapUrl")); | ||
var _relativeUrl = _interopRequireDefault(require("./relativeUrl")); | ||
@@ -420,2 +411,15 @@ | ||
var _sourcemap = require("./sourcemap"); | ||
Object.keys(_sourcemap).forEach(function (key) { | ||
if (key === "default" || key === "__esModule") return; | ||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; | ||
Object.defineProperty(exports, key, { | ||
enumerable: true, | ||
get: function () { | ||
return _sourcemap[key]; | ||
} | ||
}); | ||
}); | ||
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } | ||
@@ -422,0 +426,0 @@ |
@@ -7,3 +7,4 @@ "use strict"; | ||
exports.normalizeSeparators = normalizeSeparators; | ||
exports.relatifyPath = relatifyPath; | ||
exports.normalizePath = normalizePath; | ||
exports.relativePath = relativePath; | ||
@@ -14,22 +15,18 @@ var _path = _interopRequireDefault(require("path")); | ||
const COMMON_SEPARATORS = ['/', '\\']; | ||
const SEPARATOR_REGEX = /[\\]+/g; | ||
function normalizeSeparators(filePath) { | ||
let ret = filePath; | ||
return filePath.replace(SEPARATOR_REGEX, '/'); | ||
} | ||
for (let separator of COMMON_SEPARATORS) { | ||
ret = ret.split(separator).join(_path.default.sep); | ||
function normalizePath(filePath, leadingDotSlash = true) { | ||
if (leadingDotSlash && filePath[0] !== '.' && filePath[0] !== '/') { | ||
return normalizeSeparators('./' + filePath); | ||
} else { | ||
return normalizeSeparators(filePath); | ||
} | ||
return ret; | ||
} | ||
function relatifyPath(from, to) { | ||
let filename = _path.default.relative(from, to); | ||
if (filename[0] !== '.') { | ||
filename = './' + filename; | ||
} | ||
return filename.replace(/\\+/g, '/'); | ||
function relativePath(from, to, leadingDotSlash = true) { | ||
return normalizePath(_path.default.relative(from, to), leadingDotSlash); | ||
} |
@@ -10,2 +10,4 @@ "use strict"; | ||
var _path2 = require("./path"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -16,9 +18,3 @@ | ||
}) { | ||
let p = _path.default.relative(_path.default.dirname(from.filePath), to.filePath).replace(/\\/g, '/'); | ||
if (opts.leadingDotSlash && p[0] !== '.') { | ||
p = './' + p; | ||
} | ||
return p; | ||
return (0, _path2.relativePath)(_path.default.dirname(from.filePath), to.filePath, opts.leadingDotSlash); | ||
} |
{ | ||
"name": "@parcel/utils", | ||
"version": "2.0.0-nightly.295+3f9c496b", | ||
"version": "2.0.0-nightly.298+8fdd6193", | ||
"description": "Blazing fast, zero configuration web application bundler", | ||
@@ -20,7 +20,7 @@ "license": "MIT", | ||
"@iarna/toml": "^2.2.0", | ||
"@parcel/codeframe": "2.0.0-nightly.295+3f9c496b", | ||
"@parcel/diagnostic": "2.0.0-nightly.295+3f9c496b", | ||
"@parcel/logger": "2.0.0-nightly.295+3f9c496b", | ||
"@parcel/markdown-ansi": "2.0.0-nightly.295+3f9c496b", | ||
"@parcel/source-map": "2.0.0-alpha.4.11", | ||
"@parcel/codeframe": "2.0.0-nightly.298+8fdd6193", | ||
"@parcel/diagnostic": "2.0.0-nightly.298+8fdd6193", | ||
"@parcel/logger": "2.0.0-nightly.298+8fdd6193", | ||
"@parcel/markdown-ansi": "2.0.0-nightly.298+8fdd6193", | ||
"@parcel/source-map": "2.0.0-alpha.4.13", | ||
"ansi-html": "^0.0.7", | ||
@@ -46,3 +46,3 @@ "chalk": "^2.4.2", | ||
}, | ||
"gitHead": "3f9c496b1ee7c72a4c051e903001462ce6eef449" | ||
"gitHead": "8fdd6193a20d0e82e7639115fe31dd0ff145589b" | ||
} |
@@ -41,3 +41,3 @@ // @flow | ||
let sourceMap = new SourceMap(); | ||
sourceMap.addRawMappings(rawMap.mappings, rawMap.sources, rawMap.names); | ||
sourceMap.addRawMappings(rawMap); | ||
let parsedMapData = sourceMap.getMap(); | ||
@@ -44,0 +44,0 @@ |
@@ -9,13 +9,10 @@ // @flow | ||
import {isMatch} from 'micromatch'; | ||
import {normalizeSeparators} from './path'; | ||
function normalizePath(p: string): string { | ||
return p.replace(/\\/g, '/'); | ||
} | ||
export function isGlob(p: FilePath) { | ||
return _isGlob(normalizePath(p)); | ||
return _isGlob(normalizeSeparators(p)); | ||
} | ||
export function isGlobMatch(filePath: FilePath, glob: Glob) { | ||
return isMatch(filePath, normalizePath(glob)); | ||
return isMatch(filePath, normalizeSeparators(glob)); | ||
} | ||
@@ -27,3 +24,3 @@ | ||
): Array<FilePath> { | ||
return fastGlob.sync(normalizePath(p), options); | ||
return fastGlob.sync(normalizeSeparators(p), options); | ||
} | ||
@@ -72,3 +69,3 @@ | ||
// $FlowFixMe Added in Flow 0.121.0 upgrade in #4381 | ||
return fastGlob(normalizePath(p), options); | ||
return fastGlob(normalizeSeparators(p), options); | ||
} |
@@ -22,3 +22,2 @@ // @flow strict-local | ||
export {default as urlJoin} from './urlJoin'; | ||
export {default as loadSourceMapUrl} from './loadSourceMapUrl'; | ||
export {default as relativeUrl} from './relativeUrl'; | ||
@@ -47,1 +46,2 @@ export {default as createDependencyLocation} from './dependency-location'; | ||
export * from './escape-markdown'; | ||
export * from './sourcemap'; |
// @flow strict-local | ||
import type {FilePath} from '@parcel/types'; | ||
import path from 'path'; | ||
const COMMON_SEPARATORS = ['/', '\\']; | ||
const SEPARATOR_REGEX = /[\\]+/g; | ||
export function normalizeSeparators(filePath: FilePath): FilePath { | ||
let ret = filePath; | ||
return filePath.replace(SEPARATOR_REGEX, '/'); | ||
} | ||
for (let separator of COMMON_SEPARATORS) { | ||
ret = ret.split(separator).join(path.sep); | ||
export type PathOptions = { | ||
noLeadingDotSlash?: boolean, | ||
... | ||
}; | ||
export function normalizePath( | ||
filePath: FilePath, | ||
leadingDotSlash: boolean = true, | ||
): FilePath { | ||
if (leadingDotSlash && filePath[0] !== '.' && filePath[0] !== '/') { | ||
return normalizeSeparators('./' + filePath); | ||
} else { | ||
return normalizeSeparators(filePath); | ||
} | ||
return ret; | ||
} | ||
export function relatifyPath(from: string, to: string) { | ||
let filename = path.relative(from, to); | ||
if (filename[0] !== '.') { | ||
filename = './' + filename; | ||
} | ||
return filename.replace(/\\+/g, '/'); | ||
export function relativePath( | ||
from: string, | ||
to: string, | ||
leadingDotSlash: boolean = true, | ||
) { | ||
return normalizePath(path.relative(from, to), leadingDotSlash); | ||
} |
@@ -6,2 +6,3 @@ // @flow strict-local | ||
import path from 'path'; | ||
import {relativePath} from './path'; | ||
@@ -13,10 +14,7 @@ export function relativeBundlePath( | ||
) { | ||
let p = path | ||
.relative(path.dirname(from.filePath), to.filePath) | ||
.replace(/\\/g, '/'); | ||
if (opts.leadingDotSlash && p[0] !== '.') { | ||
p = './' + p; | ||
} | ||
return p; | ||
return relativePath( | ||
path.dirname(from.filePath), | ||
to.filePath, | ||
opts.leadingDotSlash, | ||
); | ||
} |
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
153201
102
4846
8
+ Added@parcel/source-map@2.0.0-alpha.4.13(transitive)
- Removed@parcel/source-map@2.0.0-alpha.4.11(transitive)