Skip to content

Commit 4aee846

Browse files
committed
feat(server-utils): initial module scaffolding
This is phase 1 of the plan to move all server utils into a single reusable package that can be shared across SSJS SDKs. Right now it does not do anything, but in subsequent steps: 1. Code will be moved out of @sentry/core/server, into @sentry-internal/server-utils. 2. @sentry/core/server will live on, but re-export the contents of the server-utils module. 3. To minimize the cyclical dependency (ie, server-utils depends on core for isomorphic utilities, core depends on server-utils for ./server exports), server-utils will have a types-only dependency on core, which can be removed in v11. For now, an nx override allows the cycle explicitly.
1 parent 5bd7ea2 commit 4aee846

14 files changed

Lines changed: 222 additions & 0 deletions

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@
8787
"packages/replay-internal",
8888
"packages/replay-canvas",
8989
"packages/replay-worker",
90+
"packages/server-utils",
9091
"packages/solid",
9192
"packages/solidstart",
9293
"packages/svelte",

packages/core/package.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,40 @@
9292
"extends": "../../package.json"
9393
},
9494
"sideEffects": false,
95+
"dependencies": {
96+
"@sentry-internal/server-utils": "10.54.0"
97+
},
9598
"devDependencies": {
9699
"zod": "^3.24.1"
100+
},
101+
"nx": {
102+
"targets": {
103+
"build:transpile": {
104+
"dependsOn": []
105+
},
106+
"build:types": {
107+
"dependsOn": []
108+
},
109+
"build:dev": {
110+
"dependsOn": []
111+
},
112+
"build:tarball": {
113+
"dependsOn": [
114+
"build:transpile",
115+
"build:types"
116+
]
117+
},
118+
"test:unit": {
119+
"dependsOn": [
120+
"build:transpile",
121+
"build:types"
122+
]
123+
},
124+
"lint": {
125+
"dependsOn": [
126+
"build:types"
127+
]
128+
}
129+
}
97130
}
98131
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"$schema": "../../node_modules/oxlint/configuration_schema.json",
3+
"extends": ["../../.oxlintrc.base.json"]
4+
}

packages/server-utils/LICENSE

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

packages/server-utils/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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+
# Sentry JavaScript SDK Server Utilities
8+
9+
[![npm version](https://img.shields.io/npm/v/@sentry-internal/server-utils.svg)](https://www.npmjs.com/package/@sentry-internal/server-utils)
10+
[![npm dm](https://img.shields.io/npm/dm/@sentry-internal/server-utils.svg)](https://www.npmjs.com/package/@sentry-internal/server-utils)
11+
[![npm dt](https://img.shields.io/npm/dt/@sentry-internal/server-utils.svg)](https://www.npmjs.com/package/@sentry-internal/server-utils)
12+
13+
## Links
14+
15+
- [Official SDK Docs](https://docs.sentry.io/quickstart/)
16+
17+
## General
18+
19+
Common server-side utilities used by the Sentry JavaScript Server SDKs (Node, Bun, Deno, Cloudflare, AWS Lambda, Google
20+
Cloud Functions, Vercel Edge).
21+
22+
Note: This package is only meant to be used internally, and as such is not part of our public API contract and does not
23+
follow semver.

packages/server-utils/package.json

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
{
2+
"name": "@sentry-internal/server-utils",
3+
"version": "10.54.0",
4+
"description": "Server Utilities for all Sentry JavaScript Server SDKs",
5+
"repository": "git://github.com/getsentry/sentry-javascript.git",
6+
"homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/server-utils",
7+
"author": "Sentry",
8+
"license": "MIT",
9+
"engines": {
10+
"node": ">=18"
11+
},
12+
"files": [
13+
"/build"
14+
],
15+
"main": "build/cjs/index.js",
16+
"module": "build/esm/index.js",
17+
"types": "build/types/index.d.ts",
18+
"exports": {
19+
"./package.json": "./package.json",
20+
".": {
21+
"import": {
22+
"types": "./build/types/index.d.ts",
23+
"default": "./build/esm/index.js"
24+
},
25+
"require": {
26+
"types": "./build/types/index.d.ts",
27+
"default": "./build/cjs/index.js"
28+
}
29+
}
30+
},
31+
"typesVersions": {
32+
"<5.0": {
33+
"build/types/index.d.ts": [
34+
"build/types-ts3.8/index.d.ts"
35+
]
36+
}
37+
},
38+
"publishConfig": {
39+
"access": "public"
40+
},
41+
"dependencies": {
42+
"@sentry/core": "10.54.0"
43+
},
44+
"scripts": {
45+
"build": "run-p build:transpile build:types",
46+
"build:dev": "yarn build",
47+
"build:transpile": "rollup -c rollup.npm.config.mjs",
48+
"build:types": "run-s build:types:core build:types:downlevel",
49+
"build:types:core": "tsc -p tsconfig.types.json",
50+
"build:types:downlevel": "yarn downlevel-dts build/types build/types-ts3.8 --to ts3.8",
51+
"build:watch": "run-p build:transpile:watch",
52+
"build:dev:watch": "run-p build:transpile:watch",
53+
"build:transpile:watch": "rollup -c rollup.npm.config.mjs --watch",
54+
"build:tarball": "npm pack",
55+
"circularDepCheck": "madge --circular src/index.ts",
56+
"clean": "rimraf build coverage sentry-internal-server-utils-*.tgz",
57+
"lint:fix": "OXLINT_TSGOLINT_DANGEROUSLY_SUPPRESS_PROGRAM_DIAGNOSTICS=true oxlint . --fix --type-aware",
58+
"lint": "OXLINT_TSGOLINT_DANGEROUSLY_SUPPRESS_PROGRAM_DIAGNOSTICS=true oxlint . --type-aware",
59+
"lint:es-compatibility": "es-check es2020 ./build/cjs/*.js && es-check es2020 ./build/esm/*.js --module",
60+
"test:unit": "vitest run",
61+
"test": "vitest run",
62+
"test:watch": "vitest --watch",
63+
"yalc:publish": "yalc publish --push --sig"
64+
},
65+
"volta": {
66+
"extends": "../../package.json"
67+
},
68+
"sideEffects": false
69+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { makeBaseNPMConfig, makeNPMConfigVariants } from '@sentry-internal/rollup-utils';
2+
3+
export default makeNPMConfigVariants(
4+
makeBaseNPMConfig({
5+
packageSpecificConfig: {
6+
output: {
7+
// set exports to 'named' or 'auto' so that rollup doesn't warn
8+
exports: 'named',
9+
// set preserveModules to true because we don't want to bundle everything into one file.
10+
preserveModules:
11+
process.env.SENTRY_BUILD_PRESERVE_MODULES === undefined
12+
? true
13+
: Boolean(process.env.SENTRY_BUILD_PRESERVE_MODULES),
14+
},
15+
},
16+
}),
17+
);

packages/server-utils/src/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// Public surface intentionally left empty in this initial scaffold.
2+
// Symbols will land here as code is migrated out of `@sentry/core` per the
3+
// server-utils migration plan.
4+
export {};
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { describe, expect, it } from 'vitest';
2+
3+
import * as ServerUtils from '../src/index';
4+
5+
describe('@sentry-internal/server-utils', () => {
6+
it('loads the package entry point', () => {
7+
expect(ServerUtils).toBeDefined();
8+
});
9+
});
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "../tsconfig.test.json"
3+
}

0 commit comments

Comments
 (0)