Skip to content

Commit 48fa3e3

Browse files
committed
fix(orchestrion): remove unused submodule paths, fix sourcemaps
1 parent 78a950c commit 48fa3e3

8 files changed

Lines changed: 23 additions & 46 deletions

File tree

packages/node/package.json

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,6 @@
5858
"default": "./build/orchestrion/import-hook.mjs"
5959
}
6060
},
61-
"./orchestrion/config": {
62-
"import": {
63-
"types": "./build/types/orchestrion/config.d.ts",
64-
"default": "./build/esm/orchestrion/config.js"
65-
},
66-
"require": {
67-
"types": "./build/types/orchestrion/config.d.ts",
68-
"default": "./build/cjs/orchestrion/config.js"
69-
}
70-
},
7161
"./orchestrion/vite": {
7262
"import": {
7363
"types": "./build/types/orchestrion/bundler/vite.d.ts",

packages/node/rollup.npm.config.mjs

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import { makeBaseNPMConfig, makeNPMConfigVariants, makeOtelLoaders } from '@sent
77
// also covers CJS-internal `require()` calls — no separate `--require` hook is
88
// needed. We pass it through rollup only to copy it into `build/` at the path
99
// the package.json `exports` map expects; `external: /.*/` keeps every import
10-
// (e.g. `@sentry/node/orchestrion/config`) as a runtime resolution against the
11-
// installed package.
10+
// (e.g. `@sentry-internal/server-utils/orchestrion/import-hook`) as a runtime
11+
// resolution against the installed package.
1212
const orchestrionRuntimeHooks = [
1313
defineConfig({
1414
input: 'src/orchestrion/runtime/import-hook.mjs',
@@ -22,18 +22,11 @@ export default [
2222
...orchestrionRuntimeHooks,
2323
...makeNPMConfigVariants(
2424
makeBaseNPMConfig({
25-
// `src/orchestrion/config.ts` and `src/orchestrion/bundler/vite.ts` are
26-
// loaded via dedicated subpath exports (`@sentry/node/orchestrion/config`,
27-
// `@sentry/node/orchestrion/vite`) — neither is reachable from `src/index.ts`,
28-
// so we list them as separate entrypoints to guarantee they end up in
29-
// build/esm and build/cjs.
30-
entrypoints: [
31-
'src/index.ts',
32-
'src/init.ts',
33-
'src/preload.ts',
34-
'src/orchestrion/config.ts',
35-
'src/orchestrion/bundler/vite.ts',
36-
],
25+
// `src/orchestrion/bundler/vite.ts` is loaded via the dedicated
26+
// `@sentry/node/orchestrion/vite` subpath export and is not reachable from
27+
// `src/index.ts`, so we list it as a separate entrypoint to guarantee it
28+
// ends up in build/esm and build/cjs.
29+
entrypoints: ['src/index.ts', 'src/init.ts', 'src/preload.ts', 'src/orchestrion/bundler/vite.ts'],
3730
packageSpecificConfig: {
3831
external: [/^@sentry\/opentelemetry/],
3932
output: {

packages/node/src/orchestrion/config.ts

Lines changed: 0 additions & 4 deletions
This file was deleted.

packages/node/tsconfig.json

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,9 @@
44
"include": ["src/**/*"],
55

66
// The orchestrion runtime hooks are hand-written `.mjs` / `.cjs` files that
7-
// self-reference `@sentry/node/orchestrion/config`. If tsc picks them up, it
8-
// follows that subpath export back to `build/types/orchestrion/config.d.ts`,
9-
// treats the .d.ts as an input, and then collides with the .d.ts it wants to
10-
// emit from `src/orchestrion/config.ts`. Excluding them keeps tsc focused on
11-
// the .ts sources — rollup copies these files through to `build/orchestrion/`
12-
// unchanged.
7+
// rollup copies through to `build/orchestrion/` unchanged. We exclude them so
8+
// tsc doesn't try to type-check or emit declarations for them and stays
9+
// focused on the `.ts` sources.
1310
"exclude": ["src/orchestrion/runtime/**/*.mjs", "src/orchestrion/runtime/**/*.cjs"],
1411

1512
"compilerOptions": {

packages/node/tsconfig.types.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@
55
"declaration": true,
66
"declarationMap": true,
77
"emitDeclarationOnly": true,
8-
"outDir": "build/types",
9-
// Required so Node16 module resolution can disambiguate package self-references
10-
// (`@sentry/node/orchestrion/config` from inside this package) against the
11-
// package's `.` export. Without this tsc reports TS2209.
12-
"rootDir": "src"
8+
"outDir": "build/types"
139
}
1410
}

packages/server-utils/orchestrion.mjs

Lines changed: 0 additions & 1 deletion
This file was deleted.

packages/server-utils/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010
"node": ">=18"
1111
},
1212
"files": [
13-
"/build",
14-
"/orchestrion.mjs"
13+
"/build"
1514
],
1615
"main": "build/cjs/index.js",
1716
"module": "build/esm/index.js",
@@ -94,7 +93,8 @@
9493
"@apm-js-collab/code-transformer": "^0.13.0",
9594
"@apm-js-collab/code-transformer-bundler-plugins": "^0.3.0",
9695
"@apm-js-collab/tracing-hooks": "^0.8.0",
97-
"@sentry/core": "10.56.0"
96+
"@sentry/core": "10.56.0",
97+
"magic-string": "~0.30.0"
9898
},
9999
"devDependencies": {
100100
"@types/node": "^18.19.1",

packages/server-utils/src/orchestrion/bundler/vite.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@
1313
// eslint-disable-next-line @typescript-eslint/no-explicit-any
1414
type UnknownPlugin = any;
1515

16-
import { SENTRY_INSTRUMENTATIONS } from '../config';
1716
import codeTransformer from '@apm-js-collab/code-transformer-bundler-plugins/vite';
17+
import MagicString from 'magic-string';
18+
import { SENTRY_INSTRUMENTATIONS } from '../config';
1819

1920
// `vite` types live in the package's ESM-only subpath; under Node16 module
2021
// resolution with TS treating @sentry/node as CJS, importing them produces a
@@ -78,9 +79,14 @@ function bundlerMarkerPlugin(): UnknownPlugin {
7879
// their additions.
7980
return { ssr: { noExternal: instrumentedModules } };
8081
},
81-
renderChunk(code: string, chunk: { isEntry: boolean }): { code: string; map: null } | null {
82+
renderChunk(code: string, chunk: { isEntry: boolean }): { code: string; map: unknown } | null {
8283
if (!chunk.isEntry) return null;
83-
return { code: banner + code, map: null };
84+
// Prepend via magic-string so the entry chunk's sourcemap stays aligned —
85+
// returning `map: null` here would shift every mapping by the banner's
86+
// line count and misattribute server stack traces.
87+
const ms = new MagicString(code);
88+
ms.prepend(banner);
89+
return { code: ms.toString(), map: ms.generateMap({ hires: true }) };
8490
},
8591
};
8692
}

0 commit comments

Comments
 (0)