Skip to content

Commit 0bbc03b

Browse files
committed
fix: vendor svelte preprocessor types
1 parent ccd0461 commit 0bbc03b

File tree

3 files changed

+37
-6
lines changed

3 files changed

+37
-6
lines changed

packages/svelte/src/config.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import type { PreprocessorGroup } from 'svelte/types/compiler/preprocess';
21
import { componentTrackingPreprocessor, defaultComponentTrackingOptions } from './preprocessors';
3-
import type { SentryPreprocessorGroup, SentrySvelteConfigOptions, SvelteConfig } from './types';
2+
import type { PreprocessorGroup, SentryPreprocessorGroup, SentrySvelteConfigOptions, SvelteConfig } from './types';
43

54
const defaultSentryOptions: SentrySvelteConfigOptions = {
65
componentTracking: defaultComponentTrackingOptions,

packages/svelte/src/preprocessors.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import MagicString from 'magic-string';
2-
import type { PreprocessorGroup } from 'svelte/types/compiler/preprocess';
3-
import type { ComponentTrackingInitOptions, SentryPreprocessorGroup, TrackComponentOptions } from './types';
2+
import type {
3+
ComponentTrackingInitOptions,
4+
PreprocessorGroup,
5+
SentryPreprocessorGroup,
6+
TrackComponentOptions,
7+
} from './types';
48

59
export const defaultComponentTrackingOptions: Required<ComponentTrackingInitOptions> = {
610
trackComponents: true,

packages/svelte/src/types.ts

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import type { CompileOptions } from 'svelte/types/compiler';
2-
import type { PreprocessorGroup } from 'svelte/types/compiler/preprocess';
1+
import type { CompileOptions } from 'svelte/compiler';
32

43
// Adds an id property to the preprocessor object we can use to check for duplication
54
// in the preprocessors array
@@ -70,3 +69,32 @@ export type TrackComponentOptions = {
7069
*/
7170
componentName?: string;
7271
} & SpanOptions;
72+
73+
// vendor those types from svelte/types/compiler/preprocess
74+
export interface Processed {
75+
code: string;
76+
map?: string | object;
77+
dependencies?: string[];
78+
toString?: () => string;
79+
}
80+
export declare type MarkupPreprocessor = (options: {
81+
content: string;
82+
filename?: string;
83+
}) => Processed | void | Promise<Processed | void>;
84+
export declare type Preprocessor = (options: {
85+
/**
86+
* The script/style tag content
87+
*/
88+
content: string;
89+
attributes: Record<string, string | boolean>;
90+
/**
91+
* The whole Svelte file content
92+
*/
93+
markup: string;
94+
filename?: string;
95+
}) => Processed | void | Promise<Processed | void>;
96+
export interface PreprocessorGroup {
97+
markup?: MarkupPreprocessor;
98+
style?: Preprocessor;
99+
script?: Preprocessor;
100+
}

0 commit comments

Comments
 (0)