Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

@vitest/utils

Package Overview
Dependencies
Maintainers
5
Versions
178
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vitest/utils - npm Package Compare versions

Comparing version
4.1.0-beta.4
to
4.1.0-beta.5
+6
dist/source-map/node.d.ts
interface ExtractedSourceMap {
map: any;
}
declare function extractSourcemapFromFile(code: string, filePath: string): ExtractedSourceMap | undefined;
export { extractSourcemapFromFile };
import { existsSync, readFileSync } from 'node:fs';
import path from 'node:path';
import convertSourceMap from 'convert-source-map';
// based on vite
// https://github.com/vitejs/vite/blob/84079a84ad94de4c1ef4f1bdb2ab448ff2c01196/packages/vite/src/node/server/sourcemap.ts#L149
function extractSourcemapFromFile(code, filePath) {
const map = (convertSourceMap.fromSource(code) || convertSourceMap.fromMapFileSource(code, createConvertSourceMapReadMap(filePath)))?.toObject();
return map ? { map } : undefined;
}
function createConvertSourceMapReadMap(originalFileName) {
return (filename) => {
// convertSourceMap can detect invalid filename from comments.
// fallback to empty source map to avoid errors.
const targetPath = path.resolve(path.dirname(originalFileName), filename);
if (existsSync(targetPath)) {
return readFileSync(targetPath, "utf-8");
}
return "{}";
};
}
export { extractSourcemapFromFile };
+11
-2
{
"name": "@vitest/utils",
"type": "module",
"version": "4.1.0-beta.4",
"version": "4.1.0-beta.5",
"description": "Shared Vitest utility functions",

@@ -59,2 +59,6 @@ "license": "MIT",

},
"./source-map/node": {
"types": "./dist/source-map/node.d.ts",
"default": "./dist/source-map/node.js"
},
"./serialize": {

@@ -73,2 +77,5 @@ "types": "./dist/serialize.d.ts",

"dist/source-map.d.ts"
],
"source-map/node": [
"dist/source-map/node.d.ts"
]

@@ -82,7 +89,9 @@ }

"dependencies": {
"convert-source-map": "^2.0.0",
"tinyrainbow": "^3.0.3",
"@vitest/pretty-format": "4.1.0-beta.4"
"@vitest/pretty-format": "4.1.0-beta.5"
},
"devDependencies": {
"@jridgewell/trace-mapping": "0.3.31",
"@types/convert-source-map": "^2.0.3",
"@types/estree": "^1.0.8",

@@ -89,0 +98,0 @@ "diff-sequences": "^29.6.3",

Sorry, the diff of this file is too big to display