Skip to content

Commit 39428c8

Browse files
mydeaclaude
andcommitted
feat(server-runtime-injection): Split runtime orchestrion injection into a dedicated package
The runtime diagnostics-channel injection (`register`/`hook`/`import-hook` + the vendored transformer chain meriyah/esquery/astring/source-map/tracing-hooks) must stay EXTERNAL when apps bundle their server, while the rest of `@sentry/server-utils` (barrel + config + bundler plugins) is meant to be bundled. Sharing one package made externalization fiddly. This moves the runtime injection into a new package, `@sentry/server-runtime-injection`, so "keep this external" is a clean package boundary. - New package holds `register`/`hook`/`import-hook` (subpaths `/register`, `/hook`, `/import-hook`) and vendors the transformer chain; it depends on `@sentry/server-utils` and imports `SENTRY_INSTRUMENTATIONS` from `./orchestrion/config` (config stays put). - `@sentry/server-utils` drops the runtime dir/exports and the runtime-only vendored deps; the lone `config/index.ts` bundler re-export moves to a new `./orchestrion/bundler-transforms` subpath so importing config stays transformer-free (bun updated). - References updated: node SDK + test mock, deno import, the shared `--import` template + `makeOrchestrionLoader` guard, Next.js externalization (`ORCHESTRION_RUNTIME_EXTERNAL_PACKAGES`, nextjs-anchored require-ability check, forwarder generation) + tests, `.size-limit.js`. - Dep added to runtime-injection consumers (node, nextjs, deno, aws/gcp-serverless, astro, tanstackstart-react); package registered in workspaces, `.craft.yml`, CODEOWNERS, aws e2e. Stacked on the detect/warn PR (#23675). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 2d039c7 commit 39428c8

42 files changed

Lines changed: 402 additions & 144 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.craft.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ targets:
1212
- name: npm
1313
id: '@sentry/server-utils'
1414
includeNames: /^sentry-server-utils-\d.*\.tgz$/
15+
# Depends on @sentry/server-utils (for the shared instrumentation config); publish after it.
16+
- name: npm
17+
id: '@sentry/server-runtime-injection'
18+
includeNames: /^sentry-server-runtime-injection-\d.*\.tgz$/
1519
## 1.3 Browser Utils package
1620
- name: npm
1721
id: '@sentry/browser-utils'

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
# Node/server runtimes and related packages
1111
# TEMP: whole JS SDK team reviews orchestrion work; revert to team-javascript-sdks-server after
1212
/packages/node/ @getsentry/team-javascript-sdks
13+
/packages/server-runtime-injection/ @getsentry/team-javascript-sdks
1314
/packages/server-utils/ @getsentry/team-javascript-sdks
1415
/packages/node-native/ @getsentry/team-javascript-sdks-server
1516
/packages/profiling-node/ @getsentry/team-javascript-sdks-server

.size-limit.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ module.exports = [
411411
},
412412
{
413413
name: '@sentry/node/import (ESM hook with diagnostics-channel injection)',
414-
path: ['packages/server-utils/build/esm/orchestrion/runtime/hook.js', 'packages/node/build/import-hook.mjs'],
414+
path: ['packages/server-runtime-injection/build/esm/hook.js', 'packages/node/build/import-hook.mjs'],
415415
ignore: [...builtinModules, ...nodePrefixedBuiltinModules],
416416
gzip: true,
417417
limit: '91 KB',

dev-packages/e2e-tests/test-applications/aws-serverless/src/stack.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,14 @@ export class LocalLambdaStack extends Stack {
5555
const packageLockPath = path.join(lambdaPath, 'package-lock.json');
5656
const nodeModulesPath = path.join(lambdaPath, 'node_modules');
5757

58-
// `dir` is the package directory under `packages/`; `name` is the published
59-
// npm name (most are `@sentry/<dir>`, but `server-utils` is `@sentry-internal`).
58+
// `dir` is the package directory under `packages/`; `name` is the published npm name.
6059
const packagesToLink: Array<{ dir: string; name: string }> = [
6160
{ dir: 'aws-serverless', name: '@sentry/aws-serverless' },
6261
{ dir: 'node', name: '@sentry/node' },
6362
{ dir: 'core', name: '@sentry/core' },
6463
{ dir: 'opentelemetry', name: '@sentry/opentelemetry' },
6564
{ dir: 'server-utils', name: '@sentry/server-utils' },
65+
{ dir: 'server-runtime-injection', name: '@sentry/server-runtime-injection' },
6666
{ dir: 'bundler-plugins', name: '@sentry/bundler-plugins' },
6767
];
6868
const dependencies: Record<string, string> = {};
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
import '@sentry/server-utils/orchestrion/import-hook';
1+
import '@sentry/server-runtime-injection/import-hook';

dev-packages/rollup-utils/npmHelpers.mjs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,9 @@ export function makeNPMConfigVariants(baseConfig, options = {}) {
192192
/**
193193
* Emits the `@sentry/<framework>/import` entry (`build/import-hook.mjs`) as part of the rollup build,
194194
* used as `node --import @sentry/<framework>/import app.js`. The generated hook imports
195-
* `@sentry/server-utils/orchestrion/import-hook`, which registers the orchestrion
196-
* diagnostics-channel injection, so the consuming package must declare `@sentry/server-utils` as a
197-
* dependency.
195+
* `@sentry/server-runtime-injection/import-hook`, which registers the orchestrion
196+
* diagnostics-channel injection, so the consuming package must declare
197+
* `@sentry/server-runtime-injection` as a dependency.
198198
*
199199
* @param {string} outputFolder Build output folder.
200200
*/
@@ -209,7 +209,7 @@ export function makeOrchestrionLoader(outputFolder) {
209209
);
210210
}
211211

212-
const requiredDep = '@sentry/server-utils';
212+
const requiredDep = '@sentry/server-runtime-injection';
213213
const foundRequiredDep =
214214
Object.keys(packageDotJSON.dependencies ?? {}).some(key => {
215215
return key === requiredDep;

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@
8888
"packages/replay-internal",
8989
"packages/replay-canvas",
9090
"packages/replay-worker",
91+
"packages/server-runtime-injection",
9192
"packages/server-utils",
9293
"packages/solid",
9394
"packages/solidstart",

packages/astro/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
"@sentry/core": "10.67.0",
5656
"@sentry/conventions": "^0.20.0",
5757
"@sentry/node": "10.67.0",
58+
"@sentry/server-runtime-injection": "10.67.0",
5859
"@sentry/server-utils": "10.67.0",
5960
"@sentry/bundler-plugins": "10.67.0"
6061
},

packages/aws-serverless/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
"@sentry/conventions": "^0.20.0",
6060
"@sentry/core": "10.67.0",
6161
"@sentry/node": "10.67.0",
62+
"@sentry/server-runtime-injection": "10.67.0",
6263
"@sentry/server-utils": "10.67.0",
6364
"@types/aws-lambda": "^8.10.161"
6465
},

packages/bun/src/plugin.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,11 @@ type UnknownPlugin = any;
3838
// module system.
3939
import codeTransformer from '@apm-js-collab/code-transformer-bundler-plugins/bun';
4040
import {
41-
INSTRUMENTED_MODULE_NAMES,
4241
moduleInjectedTransforms,
4342
ORCHESTRION_BUNDLER_MARKER_BANNER,
43+
} from '@sentry/server-utils/orchestrion/bundler-transforms';
44+
import {
45+
INSTRUMENTED_MODULE_NAMES,
4446
SENTRY_INSTRUMENTATIONS,
4547
withoutInstrumentedExternals,
4648
} from '@sentry/server-utils/orchestrion/config';

0 commit comments

Comments
 (0)