From 55307320011791e626f353aee0cf7eed932e00ca Mon Sep 17 00:00:00 2001 From: Tim Fish Date: Tue, 24 Jun 2025 19:09:57 +0200 Subject: [PATCH 1/2] feat(node): Add `@sentry/node-native` package --- .github/ISSUE_TEMPLATE/bug.yml | 1 + .../e2e-tests/verdaccio-config/config.yaml | 6 ++ package.json | 1 + packages/node-native/.eslintrc.js | 11 +++ packages/node-native/LICENSE | 21 +++++ packages/node-native/README.md | 21 +++++ packages/node-native/package.json | 78 +++++++++++++++++++ packages/node-native/rollup.npm.config.mjs | 15 ++++ packages/node-native/src/index.ts | 1 + packages/node-native/tsconfig.json | 10 +++ packages/node-native/tsconfig.types.json | 11 +++ packages/node-native/vite.config.ts | 8 ++ 12 files changed, 184 insertions(+) create mode 100644 packages/node-native/.eslintrc.js create mode 100644 packages/node-native/LICENSE create mode 100644 packages/node-native/README.md create mode 100644 packages/node-native/package.json create mode 100644 packages/node-native/rollup.npm.config.mjs create mode 100644 packages/node-native/src/index.ts create mode 100644 packages/node-native/tsconfig.json create mode 100644 packages/node-native/tsconfig.types.json create mode 100644 packages/node-native/vite.config.ts diff --git a/.github/ISSUE_TEMPLATE/bug.yml b/.github/ISSUE_TEMPLATE/bug.yml index ba0bdd8df4c3..38da90a027b8 100644 --- a/.github/ISSUE_TEMPLATE/bug.yml +++ b/.github/ISSUE_TEMPLATE/bug.yml @@ -37,6 +37,7 @@ body: - '@sentry/node - koa' - '@sentry/node - hapi' - '@sentry/node - connect' + - '@sentry/node-native' - '@sentry/angular' - '@sentry/astro' - '@sentry/aws-serverless' diff --git a/dev-packages/e2e-tests/verdaccio-config/config.yaml b/dev-packages/e2e-tests/verdaccio-config/config.yaml index c5400118d12c..d96c3cc6905e 100644 --- a/dev-packages/e2e-tests/verdaccio-config/config.yaml +++ b/dev-packages/e2e-tests/verdaccio-config/config.yaml @@ -104,6 +104,12 @@ packages: unpublish: $all # proxy: npmjs # Don't proxy for E2E tests! + '@sentry/node-native': + access: $all + publish: $all + unpublish: $all + # proxy: npmjs # Don't proxy for E2E tests! + '@sentry/opentelemetry': access: $all publish: $all diff --git a/package.json b/package.json index 75bd3b8f8380..fe2058e2cb09 100644 --- a/package.json +++ b/package.json @@ -68,6 +68,7 @@ "packages/nestjs", "packages/nextjs", "packages/node", + "packages/node-native", "packages/nuxt", "packages/opentelemetry", "packages/pino-transport", diff --git a/packages/node-native/.eslintrc.js b/packages/node-native/.eslintrc.js new file mode 100644 index 000000000000..ab3515d9ad37 --- /dev/null +++ b/packages/node-native/.eslintrc.js @@ -0,0 +1,11 @@ +module.exports = { + env: { + node: true, + }, + extends: ['../../.eslintrc.js'], + + ignorePatterns: ['build/**/*', 'examples/**/*', 'vitest.config.ts'], + rules: { + '@sentry-internal/sdk/no-class-field-initializers': 'off', + }, +}; diff --git a/packages/node-native/LICENSE b/packages/node-native/LICENSE new file mode 100644 index 000000000000..0da96cd2f885 --- /dev/null +++ b/packages/node-native/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2025 Functional Software, Inc. dba Sentry + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/node-native/README.md b/packages/node-native/README.md new file mode 100644 index 000000000000..00779a75666e --- /dev/null +++ b/packages/node-native/README.md @@ -0,0 +1,21 @@ +

+ + Sentry + +

+ +# Native Tools for the Official Sentry Node.js SDK + +[![npm version](https://img.shields.io/npm/v/@sentry/node-native.svg)](https://www.npmjs.com/package/@sentry/node-native) +[![npm dm](https://img.shields.io/npm/dm/@sentry/node-native.svg)](https://www.npmjs.com/package/@sentry/node-native) +[![npm dt](https://img.shields.io/npm/dt/@sentry/node-native.svg)](https://www.npmjs.com/package/@sentry/node-native) + +## Installation + +```bash +# Using yarn +yarn add @sentry/node @sentry/node-native + +# Using npm +npm install --save @sentry/node @sentry/node-native +``` diff --git a/packages/node-native/package.json b/packages/node-native/package.json new file mode 100644 index 000000000000..5077a2019502 --- /dev/null +++ b/packages/node-native/package.json @@ -0,0 +1,78 @@ +{ + "name": "@sentry/node-native", + "version": "9.27.0", + "description": "Native Tools for the Official Sentry Node.js SDK", + "repository": "git://github.com/getsentry/sentry-javascript.git", + "homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/node-native", + "author": "Sentry", + "license": "MIT", + "main": "build/cjs/index.js", + "module": "build/esm/index.js", + "types": "build/types/index.d.ts", + "exports": { + "./package.json": "./package.json", + ".": { + "import": { + "types": "./build/types/index.d.ts", + "default": "./build/esm/index.js" + }, + "require": { + "types": "./build/types/index.d.ts", + "default": "./build/cjs/index.js" + } + } + }, + "typesVersions": { + "<5.0": { + "build/types/index.d.ts": [ + "build/types-ts3.8/index.d.ts" + ] + } + }, + "engines": { + "node": ">=18" + }, + "publishConfig": { + "access": "public" + }, + "files": [ + "/build", + "package.json" + ], + "scripts": { + "clean": "rm -rf build", + "lint": "eslint . --format stylish", + "lint:es-compatibility": "es-check es2022 ./build/cjs/*.js && es-check es2022 ./build/esm/*.js --module", + "fix": "eslint . --format stylish --fix", + "build": "yarn build:types && yarn build:transpile", + "build:transpile": "yarn rollup -c rollup.npm.config.mjs", + "build:types:downlevel": "yarn downlevel-dts build/types build/types-ts3.8 --to ts3.8", + "build:types": "tsc -p tsconfig.types.json && yarn build:types:downlevel", + "build:types:watch": "tsc -p tsconfig.types.json --watch", + "build:dev": "yarn clean && yarn build", + "build:transpile:watch": "rollup -c rollup.npm.config.mjs --watch", + "build:watch": "run-p build:transpile:watch build:types:watch", + "build:tarball": "npm pack" + }, + "dependencies": { + "@sentry/core": "9.31.0", + "@sentry/node": "9.31.0" + }, + "devDependencies": { + "@types/node": "^18.19.1" + }, + "volta": { + "extends": "../../package.json" + }, + "sideEffects": false, + "nx": { + "targets": { + "build:transpile": { + "dependsOn": [ + "^build:transpile", + "^build:types" + ] + } + } + } +} diff --git a/packages/node-native/rollup.npm.config.mjs b/packages/node-native/rollup.npm.config.mjs new file mode 100644 index 000000000000..b58b8e8ac027 --- /dev/null +++ b/packages/node-native/rollup.npm.config.mjs @@ -0,0 +1,15 @@ +import { makeBaseNPMConfig, makeNPMConfigVariants } from '@sentry-internal/rollup-utils'; + +export default makeNPMConfigVariants( + makeBaseNPMConfig({ + entrypoints: ['src/index.ts'], + packageSpecificConfig: { + output: { + dir: 'build', + // set exports to 'named' or 'auto' so that rollup doesn't warn + exports: 'named', + preserveModules: true, + }, + }, + }), +); diff --git a/packages/node-native/src/index.ts b/packages/node-native/src/index.ts new file mode 100644 index 000000000000..cb0ff5c3b541 --- /dev/null +++ b/packages/node-native/src/index.ts @@ -0,0 +1 @@ +export {}; diff --git a/packages/node-native/tsconfig.json b/packages/node-native/tsconfig.json new file mode 100644 index 000000000000..29acbf3f36e9 --- /dev/null +++ b/packages/node-native/tsconfig.json @@ -0,0 +1,10 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "module": "esnext", + "lib": ["es2018"], + "outDir": "build", + "types": ["node"] + }, + "include": ["src/**/*"] +} diff --git a/packages/node-native/tsconfig.types.json b/packages/node-native/tsconfig.types.json new file mode 100644 index 000000000000..7a01535e9a4c --- /dev/null +++ b/packages/node-native/tsconfig.types.json @@ -0,0 +1,11 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "declaration": true, + "declarationMap": true, + "emitDeclarationOnly": true, + "outDir": "build/types", + "types": ["node"] + }, + "files": ["src/index.ts"] +} diff --git a/packages/node-native/vite.config.ts b/packages/node-native/vite.config.ts new file mode 100644 index 000000000000..f18ec92095bc --- /dev/null +++ b/packages/node-native/vite.config.ts @@ -0,0 +1,8 @@ +import baseConfig from '../../vite/vite.config'; + +export default { + ...baseConfig, + test: { + ...baseConfig.test, + }, +}; From 84d18ea78b54006764702ff8b078646f457cb474 Mon Sep 17 00:00:00 2001 From: Tim Fish Date: Tue, 24 Jun 2025 19:35:18 +0200 Subject: [PATCH 2/2] Add missing tsconfig --- packages/node-native/tsconfig.test.json | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 packages/node-native/tsconfig.test.json diff --git a/packages/node-native/tsconfig.test.json b/packages/node-native/tsconfig.test.json new file mode 100644 index 000000000000..c401c76a5305 --- /dev/null +++ b/packages/node-native/tsconfig.test.json @@ -0,0 +1,12 @@ +{ + "extends": "./tsconfig.json", + + "include": ["test/**/*", "src/**/*.d.ts", "vite.config.ts"], + + "compilerOptions": { + // should include all types from `./tsconfig.json` plus types for all test frameworks used + "types": ["node"] + + // other package-specific, test-specific options + } +}