Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,9 @@ const tsConfig = require(baseTscConfigPath);
// TS 3.8 fails build when it encounters a config option it does not understand, so we remove it :(
delete tsConfig.compilerOptions.noUncheckedIndexedAccess;

// TS 3.8 doesn't support "bundler" moduleResolution (introduced in TS 5.0)
if (tsConfig.compilerOptions.moduleResolution === 'bundler') {
tsConfig.compilerOptions.moduleResolution = 'node';
}

writeFileSync(baseTscConfigPath, JSON.stringify(tsConfig, null, 2));
5 changes: 5 additions & 0 deletions dev-packages/node-integration-tests/scripts/use-ts-3_8.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,9 @@ const tsConfig = require(baseTscConfigPath);
// TS 3.8 fails build when it encounters a config option it does not understand, so we remove it :(
delete tsConfig.compilerOptions.noUncheckedIndexedAccess;

// TS 3.8 doesn't support "bundler" moduleResolution (introduced in TS 5.0)
if (tsConfig.compilerOptions.moduleResolution === 'bundler') {
tsConfig.compilerOptions.moduleResolution = 'node';
}

writeFileSync(baseTscConfigPath, JSON.stringify(tsConfig, null, 2));
26 changes: 24 additions & 2 deletions packages/angular/tsconfig.ngc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,34 @@
// This tsconfig is used when building @sentry/angular with the Angular
// compiler and `ng-packagr`. It configures a production build conforming
// to the Angular Package Format (APF).
//
// Does NOT extend the shared base tsconfig because ng-packagr ships its own
// older TypeScript that doesn't support "moduleResolution": "bundler".
{
"extends": "./tsconfig.json",
"include": ["**/*.ts", "src/**/*"],
"exclude": ["patch-vitest.ts", "setup-test.ts"],
"compilerOptions": {
"target": "es2020",
"declaration": false,
"declarationMap": false,
"downlevelIteration": true,
"experimentalDecorators": true,
"importHelpers": true,
"inlineSources": true,
"isolatedModules": true,
"lib": ["DOM", "es2020"],
"moduleResolution": "node",
"noErrorTruncation": true,
"noFallthroughCasesInSwitch": true,
"noImplicitReturns": true,
"noUnusedLocals": false,
"noUnusedParameters": false,
"noUncheckedIndexedAccess": true,
"preserveWatchOutput": true,
"skipLibCheck": true,
"sourceMap": true,
"strict": true,
"strictBindCallApply": false,
"target": "es2020",
"baseUrl": "./"
},
"angularCompilerOptions": {
Expand Down
3 changes: 1 addition & 2 deletions packages/svelte/src/config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type { PreprocessorGroup } from 'svelte/types/compiler/preprocess';
import { componentTrackingPreprocessor, defaultComponentTrackingOptions } from './preprocessors';
import type { SentryPreprocessorGroup, SentrySvelteConfigOptions, SvelteConfig } from './types';
import type { PreprocessorGroup, SentryPreprocessorGroup, SentrySvelteConfigOptions, SvelteConfig } from './types';

const defaultSentryOptions: SentrySvelteConfigOptions = {
componentTracking: defaultComponentTrackingOptions,
Expand Down
8 changes: 6 additions & 2 deletions packages/svelte/src/preprocessors.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import MagicString from 'magic-string';
import type { PreprocessorGroup } from 'svelte/types/compiler/preprocess';
import type { ComponentTrackingInitOptions, SentryPreprocessorGroup, TrackComponentOptions } from './types';
import type {
ComponentTrackingInitOptions,
PreprocessorGroup,
SentryPreprocessorGroup,
TrackComponentOptions,
} from './types';

export const defaultComponentTrackingOptions: Required<ComponentTrackingInitOptions> = {
trackComponents: true,
Expand Down
32 changes: 30 additions & 2 deletions packages/svelte/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { CompileOptions } from 'svelte/types/compiler';
import type { PreprocessorGroup } from 'svelte/types/compiler/preprocess';
import type { CompileOptions } from 'svelte/compiler';

// Adds an id property to the preprocessor object we can use to check for duplication
// in the preprocessors array
Expand Down Expand Up @@ -70,3 +69,32 @@ export type TrackComponentOptions = {
*/
componentName?: string;
} & SpanOptions;

// vendor those types from svelte/types/compiler/preprocess
export interface Processed {
code: string;
map?: string | object;
dependencies?: string[];
toString?: () => string;
}
export declare type MarkupPreprocessor = (options: {
content: string;
filename?: string;
}) => Processed | void | Promise<Processed | void>;
export declare type Preprocessor = (options: {
/**
* The script/style tag content
*/
content: string;
attributes: Record<string, string | boolean>;
/**
* The whole Svelte file content
*/
markup: string;
filename?: string;
}) => Processed | void | Promise<Processed | void>;
export interface PreprocessorGroup {
markup?: MarkupPreprocessor;
style?: Preprocessor;
script?: Preprocessor;
}
2 changes: 1 addition & 1 deletion packages/typescript/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"inlineSources": true,
"isolatedModules": true,
"lib": ["es2020"],
"moduleResolution": "node",
"moduleResolution": "bundler",
"noErrorTruncation": true,
"noFallthroughCasesInSwitch": true,
"noImplicitReturns": true,
Expand Down
Loading