Skip to content

Commit 148dd43

Browse files
authored
chore(sveltekit): Add boilerplate SvelteKit SDK package (#7365)
Add the usual files for a new package, a few dependencies as well as craft/publish config entries to keep the package from being published accidentally for now.
1 parent f8b56b0 commit 148dd43

20 files changed

+535
-6
lines changed

.craft.yml

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ targets:
2222
- name: github
2323
includeNames: /^sentry-.*$/
2424
- name: npm
25+
excludeNames: /^sentry-sveltekit-.*$/
2526
- name: registry
2627
sdks:
2728
'npm:@sentry/browser':

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
"packages/replay-worker",
5959
"packages/serverless",
6060
"packages/svelte",
61+
"packages/sveltekit",
6162
"packages/tracing",
6263
"packages/types",
6364
"packages/typescript",

packages/e2e-tests/verdaccio-config/config.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,12 @@ packages:
128128
unpublish: $all
129129
# proxy: npmjs # Don't proxy for E2E tests!
130130

131+
'@sentry/sveltekit':
132+
access: $all
133+
publish: $all
134+
unpublish: $all
135+
# proxy: npmjs # Don't proxy for E2E tests!
136+
131137
'@sentry/tracing':
132138
access: $all
133139
publish: $all

packages/sveltekit/.eslintrc.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module.exports = {
2+
env: {
3+
browser: true,
4+
node: true,
5+
},
6+
extends: ['../../.eslintrc.js'],
7+
};

packages/sveltekit/LICENSE

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Copyright (c) 2023 Sentry (https://sentry.io) and individual contributors. All rights reserved.
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
4+
documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
5+
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
6+
persons to whom the Software is furnished to do so, subject to the following conditions:
7+
8+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
9+
Software.
10+
11+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
12+
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
13+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
14+
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

packages/sveltekit/README.md

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<p align="center">
2+
<a href="https://sentry.io/?utm_source=github&utm_medium=logo" target="_blank">
3+
<img src="https://sentry-brand.storage.googleapis.com/sentry-wordmark-dark-280x84.png" alt="Sentry" width="280" height="84">
4+
</a>
5+
</p>
6+
7+
# Official Sentry SDK for SvelteKit
8+
9+
[![npm version](https://img.shields.io/npm/v/@sentry/sveltekit.svg)](https://www.npmjs.com/package/@sentry/sveltekit)
10+
[![npm dm](https://img.shields.io/npm/dm/@sentry/sveltekit.svg)](https://www.npmjs.com/package/@sentry/sveltekit)
11+
[![npm dt](https://img.shields.io/npm/dt/@sentry/sveltekit.svg)](https://www.npmjs.com/package/@sentry/sveltekit)
12+
13+
<!--
14+
TODO: No docs yet, comment back in once we have docs
15+
## Links
16+
17+
- [Official SDK Docs](https://docs.sentry.io/platforms/javascript/guides/sveltekit/)
18+
- [TypeDoc](http://getsentry.github.io/sentry-javascript/) -->
19+
20+
## SDK Status
21+
22+
This SDK is currently in **Alpha state** and we're still experimenting with APIs and functionality. We therefore make no guarantees in terms of semver or breaking changes. If you want to try this SDK and come across a problem, please open a [GitHub Issue](https://github.com/getsentry/sentry-javascript/issues/new/choose).
23+
24+
## Compatibility
25+
26+
Currently, the minimum supported version of SvelteKit is `1.0.0`.
27+
28+
## General
29+
30+
This package is a wrapper around `@sentry/node` for the server and `@sentry/svelte` for the client, with added functionality related to SvelteKit.
31+
32+
TODO: Add usage instructions

packages/sveltekit/jest.config.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
const baseConfig = require('../../jest/jest.config.js');
2+
3+
module.exports = baseConfig;

packages/sveltekit/package.json

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
{
2+
"name": "@sentry/sveltekit",
3+
"version": "7.41.0",
4+
"description": "Official Sentry SDK for SvelteKit",
5+
"repository": "git://github.com/getsentry/sentry-javascript.git",
6+
"homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/sveltekit",
7+
"author": "Sentry",
8+
"license": "MIT",
9+
"engines": {
10+
"node": ">=16"
11+
},
12+
"main": "build/cjs/index.server.js",
13+
"module": "build/esm/index.server.js",
14+
"browser": "build/esm/index.client.js",
15+
"types": "build/types/index.types.d.ts",
16+
"publishConfig": {
17+
"access": "public"
18+
},
19+
"peerDependencies": {
20+
"@sveltejs/kit": "1.x"
21+
},
22+
"dependencies": {
23+
"@sentry/core": "7.41.0",
24+
"@sentry/node": "7.41.0",
25+
"@sentry/svelte": "7.41.0",
26+
"@sentry/types": "7.41.0",
27+
"@sentry/utils": "7.41.0"
28+
},
29+
"devDependencies": {
30+
"@sveltejs/kit": "^1.10.0",
31+
"vite": "^4.0.0"
32+
},
33+
"scripts": {
34+
"build": "run-p build:transpile build:types",
35+
"build:dev": "yarn build",
36+
"build:transpile": "rollup -c rollup.npm.config.js",
37+
"build:types": "tsc -p tsconfig.types.json",
38+
"build:watch": "run-p build:transpile:watch build:types:watch",
39+
"build:dev:watch": "yarn build:watch",
40+
"build:transpile:watch": "rollup -c rollup.npm.config.js --watch",
41+
"build:types:watch": "tsc -p tsconfig.types.json --watch",
42+
"build:tarball": "ts-node ../../scripts/prepack.ts && npm pack ./build",
43+
"circularDepCheck": "madge --circular src/index.client.ts && madge --circular src/index.server.ts && madge --circular src/index.types.ts",
44+
"clean": "rimraf build coverage sentry-sveltekit-*.tgz",
45+
"fix": "run-s fix:eslint fix:prettier",
46+
"fix:eslint": "eslint . --format stylish --fix",
47+
"fix:prettier": "prettier --write \"{src,test,scripts}/**/**.ts\"",
48+
"lint": "run-s lint:prettier lint:eslint",
49+
"lint:eslint": "eslint . --format stylish",
50+
"lint:prettier": "prettier --check \"{src,test,scripts}/**/**.ts\"",
51+
"test": "yarn test:unit",
52+
"test:unit": "jest",
53+
"test:watch": "jest --watch"
54+
},
55+
"volta": {
56+
"extends": "../../package.json"
57+
}
58+
}
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { makeBaseNPMConfig, makeNPMConfigVariants } from '../../rollup/index.js';
2+
3+
export default
4+
makeNPMConfigVariants(
5+
makeBaseNPMConfig({
6+
entrypoints: [
7+
'src/index.server.ts',
8+
'src/index.client.ts',
9+
'src/client/index.ts',
10+
'src/server/index.ts',
11+
],
12+
}),
13+
)
14+
;
+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export * from '@sentry/svelte';
2+
3+
// Just here so that eslint is happy until we export more stuff here
4+
export const PLACEHOLDER_CLIENT = 'PLACEHOLDER';
+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export * from './client';
2+
3+
/**
4+
* This const serves no purpose besides being an identifier for this file that the SDK multiplexer loader can use to
5+
* determine that this is in fact a file that wants to be multiplexed.
6+
*/
7+
export const _SENTRY_SDK_MULTIPLEXER = true;
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
export * from './server';
2+
3+
// This file is the main entrypoint on the server and/or when the package is `require`d
4+
5+
/**
6+
* This const serves no purpose besides being an identifier for this file that the SDK multiplexer loader can use to
7+
* determine that this is in fact a file that wants to be multiplexed.
8+
*/
9+
export const _SENTRY_SDK_MULTIPLEXER = true;

packages/sveltekit/src/index.types.ts

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/* eslint-disable import/export */
2+
3+
// We export everything from both the client part of the SDK and from the server part.
4+
// Some of the exports collide, which is not allowed, unless we redifine the colliding
5+
// exports in this file - which we do below.
6+
export * from './client';
7+
export * from './server';
8+
9+
import type { Integration, Options, StackParser } from '@sentry/types';
10+
11+
import type * as clientSdk from './client';
12+
import type * as serverSdk from './server';
13+
14+
/** Initializes Sentry SvelteKit SDK */
15+
export declare function init(options: Options | clientSdk.BrowserOptions | serverSdk.NodeOptions): void;
16+
17+
// We export a merged Integrations object so that users can (at least typing-wise) use all integrations everywhere.
18+
export declare const Integrations: typeof clientSdk.Integrations & typeof serverSdk.Integrations;
19+
20+
export declare const defaultIntegrations: Integration[];
21+
export declare const defaultStackParser: StackParser;
22+
23+
export declare function close(timeout?: number | undefined): PromiseLike<boolean>;
24+
export declare function flush(timeout?: number | undefined): PromiseLike<boolean>;
25+
export declare function lastEventId(): string | undefined;
+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export * from '@sentry/node';
2+
3+
// Just here so that eslint is happy until we export more stuff here
4+
export const PLACEHOLDER_SERVER = 'PLACEHOLDER';

packages/sveltekit/test/index.test.ts

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import * as SentryClient from '../src/client';
2+
import * as SentryServer from '../src/server';
3+
4+
describe('SvelteKit SDK', () => {
5+
// This is a place holder test at best to satisfy the test runner
6+
it('exports client and server SDKs', () => {
7+
expect(SentryClient).toBeDefined();
8+
expect(SentryServer).toBeDefined();
9+
expect(SentryClient.init).toBeDefined();
10+
expect(SentryServer.init).toBeDefined();
11+
});
12+
});

packages/sveltekit/tsconfig.json

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"extends": "../../tsconfig.json",
3+
4+
"include": ["src/**/*"],
5+
6+
"compilerOptions": {
7+
// package-specific options
8+
}
9+
}

packages/sveltekit/tsconfig.test.json

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
4+
"include": ["test/**/*"],
5+
6+
"compilerOptions": {
7+
// should include all types from `./tsconfig.json` plus types for all test frameworks used
8+
"types": ["node", "jest"]
9+
}
10+
}
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
4+
"compilerOptions": {
5+
"declaration": true,
6+
"declarationMap": true,
7+
"emitDeclarationOnly": true,
8+
"outDir": "build/types"
9+
}
10+
}

scripts/node-unit-tests.ts

+9-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const DEFAULT_SKIP_TESTS_PACKAGES = [
1616
];
1717

1818
// These packages don't support Node 8 for syntax or dependency reasons.
19-
const NODE_8_SKIP_TESTS_PACKAGES = ['@sentry/gatsby', '@sentry/serverless', '@sentry/nextjs', '@sentry/remix'];
19+
const NODE_8_SKIP_TESTS_PACKAGES = ['@sentry/gatsby', '@sentry/serverless', '@sentry/nextjs', '@sentry/remix', '@sentry/sveltekit'];
2020

2121
// We have to downgrade some of our dependencies in order to run tests in Node 8 and 10.
2222
const NODE_8_LEGACY_DEPENDENCIES = [
@@ -28,12 +28,15 @@ const NODE_8_LEGACY_DEPENDENCIES = [
2828
2929
];
3030

31-
const NODE_10_SKIP_TESTS_PACKAGES = ['@sentry/remix'];
31+
const NODE_10_SKIP_TESTS_PACKAGES = ['@sentry/remix', '@sentry/sveltekit'];
3232
const NODE_10_LEGACY_DEPENDENCIES = ['[email protected]', '[email protected]'];
3333

34-
const NODE_12_SKIP_TESTS_PACKAGES = ['@sentry/remix'];
34+
const NODE_12_SKIP_TESTS_PACKAGES = ['@sentry/remix', '@sentry/sveltekit'];
3535
const NODE_12_LEGACY_DEPENDENCIES = ['[email protected]'];
3636

37+
const NODE_14_SKIP_TESTS_PACKAGES = ['@sentry/sveltekit'];
38+
39+
3740
type JSONValue = string | number | boolean | null | JSONArray | JSONObject;
3841

3942
type JSONObject = {
@@ -131,6 +134,9 @@ function runTests(): void {
131134
installLegacyDeps(NODE_12_LEGACY_DEPENDENCIES);
132135
es6ifyTestTSConfig('utils');
133136
break;
137+
case '14':
138+
NODE_14_SKIP_TESTS_PACKAGES.forEach(dep => ignores.add(dep));
139+
break;
134140
}
135141

136142
runWithIgnores(Array.from(ignores));

0 commit comments

Comments
 (0)