Skip to content

Commit 11e5412

Browse files
authored
feat(tanstackstart-react)!: Export Vite plugin from @sentry/tanstackstart-react/vite subpath (#19182)
Closes #19180 Closes #19181 Context #19142 As discussed we change the `sentryTanstackStart()` vite plugin to now be a subpath export from `@sentry/tanstackstart-react`. This should resolve the issue of the plugin being pulled into user builds. As far as I could see this now seems to work for the latest nitro alpha. With the latest nitro nightly we still see a `rollup` issue that is a bit annoying. However, it does work with the latest vite 8 beta, which uses `rolldown`.
1 parent c2c2d43 commit 11e5412

File tree

9 files changed

+47
-12
lines changed

9 files changed

+47
-12
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,15 @@ Work in this release was contributed by @LudvigHz and @jadengis. Thank you for y
4747

4848
### Important Changes
4949

50+
- **feat(tanstackstart-react)!: Export Vite plugin from `@sentry/tanstackstart-react/vite` subpath ([#19182](https://github.com/getsentry/sentry-javascript/pull/19182))**
51+
52+
The `sentryTanstackStart` Vite plugin is now exported from a dedicated subpath. Update your import:
53+
54+
```diff
55+
- import { sentryTanstackStart } from '@sentry/tanstackstart-react';
56+
+ import { sentryTanstackStart } from '@sentry/tanstackstart-react/vite';
57+
```
58+
5059
- **feat(tanstackstart-react): Auto-instrument server function middleware ([#19001](https://github.com/getsentry/sentry-javascript/pull/19001))**
5160

5261
The `sentryTanstackStart` Vite plugin now automatically instruments middleware in `createServerFn().middleware([...])` calls. This captures performance data without requiring manual wrapping with `wrapMiddlewaresWithSentry()`.

dev-packages/e2e-tests/test-applications/tanstackstart-react/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
"@tanstack/react-start": "^1.136.0",
1818
"@tanstack/react-router": "^1.136.0",
1919
"react": "^19.2.0",
20-
"react-dom": "^19.2.0"
20+
"react-dom": "^19.2.0",
21+
"nitro": "latest || *"
2122
},
2223
"devDependencies": {
2324
"@types/react": "^19.2.0",
@@ -29,7 +30,6 @@
2930
"typescript": "^5.9.0",
3031
"vite": "7.2.0",
3132
"vite-tsconfig-paths": "^5.1.4",
32-
"nitro": "^3.0.0",
3333
"@playwright/test": "~1.56.0",
3434
"@sentry-internal/test-utils": "link:../../../test-utils"
3535
},

dev-packages/e2e-tests/test-applications/tanstackstart-react/vite.config.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,23 @@ import tsConfigPaths from 'vite-tsconfig-paths';
33
import { tanstackStart } from '@tanstack/react-start/plugin/vite';
44
import viteReact from '@vitejs/plugin-react-swc';
55
import { nitro } from 'nitro/vite';
6-
import { sentryTanstackStart } from '@sentry/tanstackstart-react';
6+
import { sentryTanstackStart } from '@sentry/tanstackstart-react/vite';
77

88
export default defineConfig({
99
server: {
1010
port: 3000,
1111
},
1212
plugins: [
13+
tsConfigPaths(),
14+
tanstackStart(),
15+
nitro(),
16+
// react's vite plugin must come after start's vite plugin
17+
viteReact(),
1318
sentryTanstackStart({
1419
org: process.env.E2E_TEST_SENTRY_ORG_SLUG,
1520
project: process.env.E2E_TEST_SENTRY_PROJECT,
1621
authToken: process.env.E2E_TEST_AUTH_TOKEN,
1722
debug: true,
1823
}),
19-
tsConfigPaths(),
20-
tanstackStart(),
21-
nitro(),
22-
// react's vite plugin must come after start's vite plugin
23-
viteReact(),
2424
],
2525
});

packages/tanstackstart-react/package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@
3737
"import": {
3838
"default": "./build/loader-hook.mjs"
3939
}
40+
},
41+
"./vite": {
42+
"types": "./build/types/vite/index.d.ts",
43+
"import": "./build/esm/vite/index.js",
44+
"require": "./build/cjs/vite/index.js"
4045
}
4146
},
4247
"typesVersions": {

packages/tanstackstart-react/rollup.npm.config.mjs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@ import { makeBaseNPMConfig, makeNPMConfigVariants, makeOtelLoaders } from '@sent
33
export default [
44
...makeNPMConfigVariants(
55
makeBaseNPMConfig({
6-
entrypoints: ['src/index.server.ts', 'src/index.client.ts', 'src/client/index.ts', 'src/server/index.ts'],
6+
entrypoints: [
7+
'src/index.server.ts',
8+
'src/index.client.ts',
9+
'src/client/index.ts',
10+
'src/server/index.ts',
11+
'src/vite/index.ts',
12+
],
713
}),
814
),
915
...makeOtelLoaders('./build', 'sentry-node'),

packages/tanstackstart-react/src/index.server.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@
33
export * from './config';
44
export * from './server';
55
export * from './common';
6-
export * from './vite';

packages/tanstackstart-react/src/index.types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ export * from './config';
1212
export * from './client';
1313
export * from './server';
1414
export * from './common';
15-
export * from './vite';
1615

1716
/** Initializes Sentry TanStack Start SDK */
1817
export declare function init(options: Options | clientSdk.BrowserOptions | serverSdk.NodeOptions): Client | undefined;
@@ -38,5 +37,6 @@ export declare const unleashIntegration: typeof clientSdk.unleashIntegration;
3837

3938
export declare const wrapMiddlewaresWithSentry: typeof serverSdk.wrapMiddlewaresWithSentry;
4039

40+
export declare const tanstackRouterBrowserTracingIntegration: typeof clientSdk.tanstackRouterBrowserTracingIntegration;
4141
export declare const sentryGlobalRequestMiddleware: typeof serverSdk.sentryGlobalRequestMiddleware;
4242
export declare const sentryGlobalFunctionMiddleware: typeof serverSdk.sentryGlobalFunctionMiddleware;

packages/tanstackstart-react/src/server/index.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,29 @@
11
// import/export got a false positive, and affects most of our index barrel files
22
// can be removed once following issue is fixed: https://github.com/import-js/eslint-plugin-import/issues/703
33
/* eslint-disable import/export */
4+
import type { Integration } from '@sentry/core';
5+
46
export * from '@sentry/node';
57

68
export { init } from './sdk';
79
export { wrapFetchWithSentry } from './wrapFetchWithSentry';
810
export { wrapMiddlewaresWithSentry } from './middleware';
911
export { sentryGlobalRequestMiddleware, sentryGlobalFunctionMiddleware } from './globalMiddleware';
1012

13+
/**
14+
* A no-op stub of the browser tracing integration for the server. Router setup code is shared between client and server,
15+
* so this stub is needed to prevent build errors during SSR bundling.
16+
*/
17+
export function tanstackRouterBrowserTracingIntegration(
18+
_router: unknown,
19+
_options?: Record<string, unknown>,
20+
): Integration {
21+
return {
22+
name: 'BrowserTracing',
23+
setup() {},
24+
};
25+
}
26+
1127
/**
1228
* A passthrough error boundary for the server that doesn't depend on any react. Error boundaries don't catch SSR errors
1329
* so they should simply be a passthrough.

packages/tanstackstart-react/src/vite/sentryTanstackStart.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export interface SentryTanstackStartOptions extends BuildTimeOptionsBase {
2828
* ```typescript
2929
* // vite.config.ts
3030
* import { defineConfig } from 'vite';
31-
* import { sentryTanstackStart } from '@sentry/tanstackstart-react';
31+
* import { sentryTanstackStart } from '@sentry/tanstackstart-react/vite';
3232
* import { tanstackStart } from '@tanstack/react-start/plugin/vite';
3333
*
3434
* export default defineConfig({

0 commit comments

Comments
 (0)