Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@cypress/vite-dev-server

Package Overview
Dependencies
Maintainers
0
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cypress/vite-dev-server - npm Package Compare versions

Comparing version 5.2.0 to 5.2.1

31

dist/plugins/sourcemap.js

@@ -13,15 +13,11 @@ "use strict";

try {
if (/\.js$/i.test(id) && !/\/\/# sourceMappingURL=/i.test(code)) {
// Remove query parameters from the id. This is necessary because some files
// have a cache buster query parameter (e.g. `?v=12345`)
const queryParameterLessId = id.split('?')[0];
// Check if the file has a JavaScript extension and does not have an inlined sourcemap
if (/\.(js|jsx|ts|tsx|vue|svelte|mjs|cjs)$/i.test(queryParameterLessId) && !/\/\/# sourceMappingURL=data/i.test(code)) {
/*
The Vite dev server and plugins automatically generate sourcemaps for most files, but they are
only included in the served files if any transpilation actually occurred (JSX, TS, etc). This
means that files that are "pure" JS won't include sourcemaps, so JS spec files that don't require
transpilation won't get code frames in the runner.
A sourcemap for these files is generated (just not served) which is in effect an "identity"
sourcemap mapping 1-to-1 to the output file. We can grab this and pass it along as a sourcemap
we want Vite to embed into the output, giving Cypress a sourcemap to use for codeFrame lookups.
@see https://rollupjs.org/guide/en/#thisgetcombinedsourcemap
We utilize a 'post' plugin here and manually append the sourcemap content to the code. We *should*
The Vite dev server and plugins automatically generate sourcemaps for most files, but there are
some files that don't have sourcemaps generated for them or are not inlined. We utilize a 'post' plugin
here and manually append the sourcemap content to the code in these cases. We *should*
be able to pass the sourcemap along using the `map` attribute in the return value, but Babel-based

@@ -33,3 +29,12 @@ plugins don't work with this which causes sourcemaps to break for files that go through common

const sourcemap = this.getCombinedSourcemap();
code += `\n//# sourceMappingURL=${sourcemap.toUrl()}`;
const sourcemapUrl = sourcemap.toUrl();
if (/\/\/# sourceMappingURL=/i.test(code)) {
// If the code already has a sourceMappingURL, it is not an inlined sourcemap
// and we should replace it with the new sourcemap
code = code.replace(/\/\/# sourceMappingURL=(.*)$/m, `//# sourceMappingURL=${sourcemapUrl}`);
}
else {
// If the code does not have a sourceMappingURL, we should append the new sourcemap
code += `\n//# sourceMappingURL=${sourcemapUrl}`;
}
return {

@@ -36,0 +41,0 @@ code,

{
"name": "@cypress/vite-dev-server",
"version": "5.2.0",
"version": "5.2.1",
"description": "Launches Vite Dev Server for Component Testing",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc