Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
"@sentry-internal/test-utils": "link:../../../test-utils",
"@types/react": "^19.2.0",
"@types/react-dom": "^19.2.0",
"@vitejs/plugin-react": "^4.5.0",
"@vitejs/plugin-react": "^6.1.2",
"typescript": "^5.9.0",
"vite": "7.3.2",
"vite-tsconfig-paths": "^5.1.4",
"vite": "8.3.4",
"vite-tsconfig-paths": "^6.1.1",
"wrangler": "^4.68.1"
},
"volta": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"test:build:tunnel-static": "pnpm install && E2E_TEST_TUNNEL_ROUTE_MODE=static E2E_TEST_DSN=http://public@localhost:3031/1337 pnpm build",
"test:build:tunnel-custom": "pnpm install && E2E_TEST_CUSTOM_TUNNEL_ROUTE=1 pnpm build",
"test:build:tunnel-object": "pnpm install && E2E_TEST_TUNNEL_ROUTE_MODE=object E2E_TEST_DSN=http://public@localhost:3031/1337 pnpm build",
"test:build-latest": "pnpm add @tanstack/react-start@latest @tanstack/react-router@latest && pnpm install && pnpm build",
"test:build-latest": "pnpm add @tanstack/react-start@latest @tanstack/react-router@latest nitro@latest vite@latest @vitejs/plugin-react-swc@latest vite-tsconfig-paths@latest && pnpm install && pnpm build",
"test:assert:proxy": "pnpm test && TEST_ENV=development pnpm playwright test db-drivers",
"test:assert": "pnpm test:assert:proxy",
"test:assert:tunnel-generated": "E2E_TEST_TUNNEL_ROUTE_MODE=dynamic E2E_TEST_DSN=http://public@localhost:3031/1337 pnpm test",
Expand Down
10 changes: 10 additions & 0 deletions packages/tanstackstart-react/src/vite/routePatterns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ export function makeRoutePatternPlugin(): Plugin {
name: 'sentry-tanstackstart-route-patterns',
enforce: 'post',

// The transform below must see the SDK's own `wrapFetchWithSentry` file. Vite externalizes dependencies in
// server builds, and Nitro 3 copies external dependencies into its output instead of bundling them.
configEnvironment(name, config, env) {
if (env.command === 'serve' || (config.consumer ?? (name === 'client' ? 'client' : 'server')) !== 'server') {
return null;
}

return { resolve: { noExternal: ['@sentry/tanstackstart-react'] } };
},

configResolved(config) {
resolvedRoot = config.root || process.cwd();
},
Expand Down
25 changes: 24 additions & 1 deletion packages/tanstackstart-react/test/vite/routePatterns.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,30 @@ import * as fs from 'node:fs';
import * as os from 'node:os';
import * as path from 'node:path';
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
import { extractRoutePatterns, findRouteTreeFile } from '../../src/vite/routePatterns';
import { extractRoutePatterns, findRouteTreeFile, makeRoutePatternPlugin } from '../../src/vite/routePatterns';

describe('makeRoutePatternPlugin', () => {
const configEnvironment = makeRoutePatternPlugin().configEnvironment as (
name: string,
config: { consumer?: 'client' | 'server' },
env: { command: 'build' | 'serve'; mode: string },
) => { resolve: { noExternal: string[] } } | null;

it('bundles the SDK into server environments of a build', () => {
const build = { command: 'build', mode: 'production' } as const;

expect(configEnvironment('ssr', {}, build)).toEqual({ resolve: { noExternal: ['@sentry/tanstackstart-react'] } });
expect(configEnvironment('nitro', { consumer: 'server' }, build)).toEqual({
resolve: { noExternal: ['@sentry/tanstackstart-react'] },
});
});

it('does not change client environments or the dev server', () => {
expect(configEnvironment('client', {}, { command: 'build', mode: 'production' })).toBeNull();
expect(configEnvironment('ssr', { consumer: 'client' }, { command: 'build', mode: 'production' })).toBeNull();
expect(configEnvironment('ssr', {}, { command: 'serve', mode: 'development' })).toBeNull();
});
});

describe('extractRoutePatterns', () => {
it('extracts full path patterns from single-line fullPaths union', () => {
Expand Down
Loading