@sentry/sveltekit
Advanced tools
Comparing version 7.53.0 to 7.53.1
@@ -0,6 +1,9 @@ | ||
var { | ||
_optionalChain | ||
} = require('@sentry/utils/cjs/buildPolyfills'); | ||
const fs = require('fs'); | ||
const magicast = require('magicast'); | ||
const path = require('path'); | ||
/* eslint-disable @sentry-internal/sdk/no-optional-chaining */ | ||
const WRAPPED_MODULE_SUFFIX = '?sentry-auto-wrap'; | ||
@@ -69,20 +72,46 @@ | ||
const code = (await fs.promises.readFile(id, 'utf8')).toString(); | ||
const mod = magicast.parseModule(code); | ||
const codeWithoutComments = code.replace(/(\/\/.*| ?\/\*[^]*?\*\/)(,?)$/gm, ''); | ||
const hasSentryContent = codeWithoutComments.includes('@sentry/sveltekit'); | ||
if (hasSentryContent) { | ||
const program = mod.$ast.type === 'Program' && mod.$ast; | ||
if (!program) { | ||
// eslint-disable-next-line no-console | ||
debug && console.log(`Skipping wrapping ${id} because it already contains Sentry code`); | ||
debug && console.log(`Skipping wrapping ${id} because it doesn't contain valid JavaScript or TypeScript`); | ||
return false; | ||
} | ||
const hasLoadDeclaration = /((const|let|var|function)\s+load\s*(=|\(|:))|as\s+load\s*(,|})/gm.test( | ||
codeWithoutComments, | ||
); | ||
const hasLoadDeclaration = program.body | ||
.filter((statement) => statement.type === 'ExportNamedDeclaration') | ||
.find(exportDecl => { | ||
// find `export const load = ...` | ||
if (exportDecl.declaration && exportDecl.declaration.type === 'VariableDeclaration') { | ||
const variableDeclarations = exportDecl.declaration.declarations; | ||
return variableDeclarations.find(decl => decl.id.type === 'Identifier' && decl.id.name === 'load'); | ||
} | ||
// find `export function load = ...` | ||
if (exportDecl.declaration && exportDecl.declaration.type === 'FunctionDeclaration') { | ||
const functionId = exportDecl.declaration.id; | ||
return _optionalChain([functionId, 'optionalAccess', _ => _.name]) === 'load'; | ||
} | ||
// find `export { load, somethingElse as load, somethingElse as "load" }` | ||
if (exportDecl.specifiers) { | ||
return exportDecl.specifiers.find(specifier => { | ||
return ( | ||
(specifier.exported.type === 'Identifier' && specifier.exported.name === 'load') || | ||
(specifier.exported.type === 'StringLiteral' && specifier.exported.value === 'load') | ||
); | ||
}); | ||
} | ||
return false; | ||
}); | ||
if (!hasLoadDeclaration) { | ||
// eslint-disable-next-line no-console | ||
debug && console.log(`Skipping wrapping ${id} because it doesn't declare a \`load\` function`); | ||
return false; | ||
} | ||
return !hasSentryContent && hasLoadDeclaration; | ||
return true; | ||
} | ||
@@ -89,0 +118,0 @@ |
@@ -0,6 +1,6 @@ | ||
import { _optionalChain } from '@sentry/utils/esm/buildPolyfills'; | ||
import * as fs from 'fs'; | ||
import { parseModule } from 'magicast'; | ||
import * as path from 'path'; | ||
/* eslint-disable @sentry-internal/sdk/no-optional-chaining */ | ||
const WRAPPED_MODULE_SUFFIX = '?sentry-auto-wrap'; | ||
@@ -69,20 +69,46 @@ | ||
const code = (await fs.promises.readFile(id, 'utf8')).toString(); | ||
const mod = parseModule(code); | ||
const codeWithoutComments = code.replace(/(\/\/.*| ?\/\*[^]*?\*\/)(,?)$/gm, ''); | ||
const hasSentryContent = codeWithoutComments.includes('@sentry/sveltekit'); | ||
if (hasSentryContent) { | ||
const program = mod.$ast.type === 'Program' && mod.$ast; | ||
if (!program) { | ||
// eslint-disable-next-line no-console | ||
debug && console.log(`Skipping wrapping ${id} because it already contains Sentry code`); | ||
debug && console.log(`Skipping wrapping ${id} because it doesn't contain valid JavaScript or TypeScript`); | ||
return false; | ||
} | ||
const hasLoadDeclaration = /((const|let|var|function)\s+load\s*(=|\(|:))|as\s+load\s*(,|})/gm.test( | ||
codeWithoutComments, | ||
); | ||
const hasLoadDeclaration = program.body | ||
.filter((statement) => statement.type === 'ExportNamedDeclaration') | ||
.find(exportDecl => { | ||
// find `export const load = ...` | ||
if (exportDecl.declaration && exportDecl.declaration.type === 'VariableDeclaration') { | ||
const variableDeclarations = exportDecl.declaration.declarations; | ||
return variableDeclarations.find(decl => decl.id.type === 'Identifier' && decl.id.name === 'load'); | ||
} | ||
// find `export function load = ...` | ||
if (exportDecl.declaration && exportDecl.declaration.type === 'FunctionDeclaration') { | ||
const functionId = exportDecl.declaration.id; | ||
return _optionalChain([functionId, 'optionalAccess', _ => _.name]) === 'load'; | ||
} | ||
// find `export { load, somethingElse as load, somethingElse as "load" }` | ||
if (exportDecl.specifiers) { | ||
return exportDecl.specifiers.find(specifier => { | ||
return ( | ||
(specifier.exported.type === 'Identifier' && specifier.exported.name === 'load') || | ||
(specifier.exported.type === 'StringLiteral' && specifier.exported.value === 'load') | ||
); | ||
}); | ||
} | ||
return false; | ||
}); | ||
if (!hasLoadDeclaration) { | ||
// eslint-disable-next-line no-console | ||
debug && console.log(`Skipping wrapping ${id} because it doesn't declare a \`load\` function`); | ||
return false; | ||
} | ||
return !hasSentryContent && hasLoadDeclaration; | ||
return true; | ||
} | ||
@@ -89,0 +115,0 @@ |
{ | ||
"name": "@sentry/sveltekit", | ||
"version": "7.53.0", | ||
"version": "7.53.1", | ||
"description": "Official Sentry SDK for SvelteKit", | ||
@@ -23,10 +23,11 @@ "repository": "git://github.com/getsentry/sentry-javascript.git", | ||
"dependencies": { | ||
"@sentry-internal/tracing": "7.53.0", | ||
"@sentry/core": "7.53.0", | ||
"@sentry/integrations": "7.53.0", | ||
"@sentry/node": "7.53.0", | ||
"@sentry/svelte": "7.53.0", | ||
"@sentry/types": "7.53.0", | ||
"@sentry/utils": "7.53.0", | ||
"@sentry-internal/tracing": "7.53.1", | ||
"@sentry/core": "7.53.1", | ||
"@sentry/integrations": "7.53.1", | ||
"@sentry/node": "7.53.1", | ||
"@sentry/svelte": "7.53.1", | ||
"@sentry/types": "7.53.1", | ||
"@sentry/utils": "7.53.1", | ||
"@sentry/vite-plugin": "^0.6.0", | ||
"magicast": "0.2.6", | ||
"sorcery": "0.11.0" | ||
@@ -33,0 +34,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
360021
2886
11
+ Addedmagicast@0.2.6
+ Added@babel/helper-string-parser@7.25.9(transitive)
+ Added@babel/helper-validator-identifier@7.25.9(transitive)
+ Added@babel/parser@7.26.9(transitive)
+ Added@babel/types@7.26.9(transitive)
+ Added@sentry-internal/tracing@7.53.1(transitive)
+ Added@sentry/browser@7.53.1(transitive)
+ Added@sentry/core@7.53.1(transitive)
+ Added@sentry/integrations@7.53.1(transitive)
+ Added@sentry/node@7.53.1(transitive)
+ Added@sentry/replay@7.53.1(transitive)
+ Added@sentry/svelte@7.53.1(transitive)
+ Added@sentry/types@7.53.1(transitive)
+ Added@sentry/utils@7.53.1(transitive)
+ Addedassert@2.1.0(transitive)
+ Addedast-types@0.15.2(transitive)
+ Addedavailable-typed-arrays@1.0.7(transitive)
+ Addedcall-bind@1.0.8(transitive)
+ Addedcall-bind-apply-helpers@1.0.2(transitive)
+ Addedcall-bound@1.0.3(transitive)
+ Addeddefine-data-property@1.1.4(transitive)
+ Addeddefine-properties@1.2.1(transitive)
+ Addeddunder-proto@1.0.1(transitive)
+ Addedes-define-property@1.0.1(transitive)
+ Addedes-errors@1.3.0(transitive)
+ Addedes-object-atoms@1.1.1(transitive)
+ Addedesprima@4.0.1(transitive)
+ Addedfor-each@0.3.5(transitive)
+ Addedfunction-bind@1.1.2(transitive)
+ Addedget-intrinsic@1.3.0(transitive)
+ Addedget-proto@1.0.1(transitive)
+ Addedgopd@1.2.0(transitive)
+ Addedhas-property-descriptors@1.0.2(transitive)
+ Addedhas-symbols@1.1.0(transitive)
+ Addedhas-tostringtag@1.0.2(transitive)
+ Addedhasown@2.0.2(transitive)
+ Addedis-arguments@1.2.0(transitive)
+ Addedis-callable@1.2.7(transitive)
+ Addedis-generator-function@1.1.0(transitive)
+ Addedis-nan@1.3.2(transitive)
+ Addedis-regex@1.2.1(transitive)
+ Addedis-typed-array@1.1.15(transitive)
+ Addedmagicast@0.2.6(transitive)
+ Addedmath-intrinsics@1.1.0(transitive)
+ Addedobject-is@1.1.6(transitive)
+ Addedobject-keys@1.1.1(transitive)
+ Addedobject.assign@4.1.7(transitive)
+ Addedpossible-typed-array-names@1.1.0(transitive)
+ Addedrecast@0.22.0(transitive)
+ Addedsafe-regex-test@1.1.0(transitive)
+ Addedset-function-length@1.2.2(transitive)
+ Addedsource-map@0.6.1(transitive)
+ Addedtslib@2.8.1(transitive)
+ Addedutil@0.12.5(transitive)
+ Addedwhich-typed-array@1.1.18(transitive)
- Removed@sentry-internal/tracing@7.53.0(transitive)
- Removed@sentry/browser@7.53.0(transitive)
- Removed@sentry/core@7.53.0(transitive)
- Removed@sentry/integrations@7.53.0(transitive)
- Removed@sentry/node@7.53.0(transitive)
- Removed@sentry/replay@7.53.0(transitive)
- Removed@sentry/svelte@7.53.0(transitive)
- Removed@sentry/types@7.53.0(transitive)
- Removed@sentry/utils@7.53.0(transitive)
- Removedmagic-string@0.26.7(transitive)
- Removedsourcemap-codec@1.4.8(transitive)
Updated@sentry/core@7.53.1
Updated@sentry/integrations@7.53.1
Updated@sentry/node@7.53.1
Updated@sentry/svelte@7.53.1
Updated@sentry/types@7.53.1
Updated@sentry/utils@7.53.1