Skip to content
Draft
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
@@ -1,11 +1,11 @@
import { cloudflare } from '@cloudflare/vite-plugin';
import { sentryCloudflareVitePlugin } from '@sentry/cloudflare/vite';
import sentry from '@sentry/cloudflare/vite';
import agents from 'agents/vite';
import { defineConfig } from 'vite';

// `agents()` supplies the TC39 decorator transform that `@callable()` needs.
// Auto-instrumentation is the plugin behavior under test: it rewrites
// `src/index.ts` at build time so the entry itself contains no Sentry calls.
export default defineConfig({
plugins: [agents(), cloudflare(), sentryCloudflareVitePlugin()],
plugins: [agents(), cloudflare(), sentry()],
});
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { vitePlugin as remix } from '@remix-run/dev';
import { sentryRemixVitePlugin } from '@sentry/remix/vite';
import sentry from '@sentry/remix/vite';
import { defineConfig } from 'vite';
import tsconfigPaths from 'vite-tsconfig-paths';

Expand All @@ -8,7 +8,7 @@ export default defineConfig({
remix({
ignoredRouteFiles: ['**/.*'],
}),
sentryRemixVitePlugin(),
sentry(),
tsconfigPaths(),
],
});
4 changes: 2 additions & 2 deletions dev-packages/e2e-tests/test-applications/node-vite/build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { builtinModules } from 'node:module';
import { dirname, join } from 'node:path';
import { fileURLToPath } from 'node:url';
import { build } from 'vite';
import { sentryVitePlugin } from '@sentry/node/vite';
import sentry from '@sentry/node/vite';

const __dirname = dirname(fileURLToPath(import.meta.url));
const nodeExternals = [...builtinModules, ...builtinModules.map(m => `node:${m}`)];
Expand All @@ -21,7 +21,7 @@ rmSync(join(__dirname, 'dist'), { recursive: true, force: true });

// No auth/release/telemetry — we only care about the build-time transforms and defines.
const makeSentryPlugin = () =>
sentryVitePlugin({
sentry({
telemetry: false,
sourcemaps: { disable: true },
release: { create: false, finalize: false, inject: false },
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { reactRouter } from '@react-router/dev/vite';
import { sentryReactRouter } from '@sentry/react-router/vite';
import sentry from '@sentry/react-router/vite';
import { defineConfig } from 'vite';

export default defineConfig(config => {
return {
plugins: [reactRouter(), sentryReactRouter({ sourcemaps: { disable: true } }, config)],
plugins: [reactRouter(), sentry({ sourcemaps: { disable: true } }, config)],
};
});
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { sentrySolidStart } from '@sentry/solidstart/vite';
import sentry from '@sentry/solidstart/vite';
import { solidStart } from '@solidjs/start/config';
import { nitro } from 'nitro/vite';
import { defineConfig } from 'vite';
Expand All @@ -9,7 +9,7 @@ export default defineConfig({
appRoot: './src',
middleware: './src/middleware.ts',
}),
sentrySolidStart({
sentry({
org: process.env.E2E_TEST_SENTRY_ORG_SLUG,
project: process.env.E2E_TEST_SENTRY_PROJECT,
authToken: process.env.E2E_TEST_AUTH_TOKEN,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { sentrySvelteKit } from '@sentry/sveltekit/vite';
import sentry from '@sentry/sveltekit/vite';
import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig } from 'vite';

export default defineConfig({
plugins: [
sentrySvelteKit({
sentry({
autoUploadSourceMaps: false,
}),
sveltekit(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import tsConfigPaths from 'vite-tsconfig-paths';
import { tanstackStart } from '@tanstack/react-start/plugin/vite';
import viteReact from '@vitejs/plugin-react-swc';
import { nitro } from 'nitro/vite';
import { sentryTanstackStart } from '@sentry/tanstackstart-react/vite';
import sentry from '@sentry/tanstackstart-react/vite';

const tunnelRouteMode = process.env.E2E_TEST_TUNNEL_ROUTE_MODE ?? 'off';
const useManagedTunnelRoute = tunnelRouteMode !== 'off';
Expand Down Expand Up @@ -49,7 +49,7 @@ export default defineConfig({
nitro(),
// react's vite plugin must come after start's vite plugin
viteReact(),
sentryTanstackStart({
sentry({
org: process.env.E2E_TEST_SENTRY_ORG_SLUG,
project: process.env.E2E_TEST_SENTRY_PROJECT,
authToken: process.env.E2E_TEST_AUTH_TOKEN,
Expand Down
5 changes: 5 additions & 0 deletions packages/bundler-plugins/src/vite/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,8 @@ export const sentryVitePlugin = (options?: SentryRollupPluginOptions): SentryVit
};

export type { Options as SentryVitePluginOptions } from '../core';

/**
* Default export of `@sentry/bundler-plugins/vite`. It is the same function as {@link sentryVitePlugin}.
*/
export default sentryVitePlugin;
6 changes: 5 additions & 1 deletion packages/bundler-plugins/test/vite/public-api.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { sentryVitePlugin } from '../../src/vite';
import sentryVitePluginDefault, { sentryVitePlugin } from '../../src/vite';
import { describe, it, expect, test, beforeEach, vi } from 'vitest';

test('Vite plugin should exist', () => {
Expand All @@ -11,6 +11,10 @@ describe('sentryVitePlugin', () => {
vi.clearAllMocks();
});

it('is the default export of the vite entry point', () => {
expect(sentryVitePluginDefault).toBe(sentryVitePlugin);
});

it('returns an array of Vite plugins', () => {
const plugins = sentryVitePlugin({
authToken: 'test-token',
Expand Down
6 changes: 6 additions & 0 deletions packages/cloudflare/rollup.npm.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ import { makeBaseNPMConfig, makeNPMConfigVariants } from '@sentry-internal/rollu
export default makeNPMConfigVariants(
makeBaseNPMConfig({
entrypoints: ['src/index.ts', 'src/request.ts', 'src/vite/index.ts', 'src/orchestrion-diagnostics-channel.ts'],
packageSpecificConfig: {
output: {
// make it so Rollup calms down about the fact that we're combining default and named exports
exports: 'named',
},
},
}),
{ splitDevProd: true },
);
5 changes: 5 additions & 0 deletions packages/cloudflare/src/vite/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,8 @@ export function sentryCloudflareVitePlugin(options: SentryCloudflareVitePluginOp
: []),
];
}

/**
* Default export of `@sentry/cloudflare/vite`. It is the same function as {@link sentryCloudflareVitePlugin}.
*/
export default sentryCloudflareVitePlugin;
6 changes: 5 additions & 1 deletion packages/cloudflare/test/vite/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, expect, it } from 'vitest';
import { sentryCloudflareVitePlugin } from '../../src/vite/index';
import sentryCloudflareVitePluginDefault, { sentryCloudflareVitePlugin } from '../../src/vite/index';

const AUTO_INSTRUMENT_PLUGIN = 'sentry-cloudflare-auto-instrument';

Expand All @@ -8,6 +8,10 @@ function pluginNames(options?: Parameters<typeof sentryCloudflareVitePlugin>[0])
}

describe('sentryCloudflareVitePlugin', () => {
it('is the default export of the vite entry point', () => {
expect(sentryCloudflareVitePluginDefault).toBe(sentryCloudflareVitePlugin);
});

it('enables auto-instrumentation by default', () => {
expect(pluginNames()).toContain(AUTO_INSTRUMENT_PLUGIN);
});
Expand Down
5 changes: 5 additions & 0 deletions packages/node/src/bundler-plugin/vite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,8 @@ export function sentryVitePlugin(options?: SentryVitePluginOptions): VitePlugin[
const bundlerPlugins = sentryViteBundlerPlugin(options);
return [...bundlerPlugins, sentryOrchestrionPlugin(options)];
}

/**
* Default export of `@sentry/node/vite`. It is the same function as {@link sentryVitePlugin}.
*/
export default sentryVitePlugin;
6 changes: 5 additions & 1 deletion packages/node/test/bundler-plugin/bundler-plugin.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { beforeEach, describe, expect, it, vi } from 'vitest';
import { sentryEsbuildPlugin } from '../../src/bundler-plugin/esbuild';
import { sentryRollupPlugin } from '../../src/bundler-plugin/rollup';
import { sentryVitePlugin } from '../../src/bundler-plugin/vite';
import sentryVitePluginDefault, { sentryVitePlugin } from '../../src/bundler-plugin/vite';
import { sentryWebpackPlugin } from '../../src/bundler-plugin/webpack';

const orchestrionVite = vi.fn(() => ({ name: 'sentry-orchestrion-vite' }));
Expand Down Expand Up @@ -30,6 +30,10 @@ describe('@sentry/node bundler plugins', () => {
vi.clearAllMocks();
});

it('is the default export of the vite entry point', () => {
expect(sentryVitePluginDefault).toBe(sentryVitePlugin);
});

// The wrappers always wire in the orchestrion plugin. Opting out via
// `buildTimeInstrumentation: false` is handled inside the orchestrion plugin
// itself (covered in @sentry/server-utils), which returns an inert plugin.
Expand Down
7 changes: 7 additions & 0 deletions packages/react-router/src/vite/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import { sentryReactRouter } from './plugin';

export { sentryReactRouter } from './plugin';
export { sentryOnBuildEnd } from './buildEnd/handleOnBuildEnd';
export type { SentryReactRouterBuildOptions } from './types';
export { makeConfigInjectorPlugin } from './makeConfigInjectorPlugin';

/**
* Default export of `@sentry/react-router/vite`. It is the same function as {@link sentryReactRouter}.
*/
export default sentryReactRouter;
5 changes: 5 additions & 0 deletions packages/react-router/test/vite/plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { makeConfigInjectorPlugin } from '../../src/vite/makeConfigInjectorPlugi
import { makeCustomSentryVitePlugins } from '../../src/vite/makeCustomSentryVitePlugins';
import { makeEnableSourceMapsPlugin } from '../../src/vite/makeEnableSourceMapsPlugin';
import { makeServerBuildCapturePlugin } from '../../src/vite/makeServerBuildCapturePlugin';
import sentryReactRouterDefault from '../../src/vite';
import { sentryReactRouter } from '../../src/vite/plugin';

vi.spyOn(console, 'log').mockImplementation(() => {
Expand Down Expand Up @@ -45,6 +46,10 @@ describe('sentryReactRouter', () => {
vi.resetModules();
});

it('is the default export of the vite entry point', () => {
expect(sentryReactRouterDefault).toBe(sentryReactRouter);
});

it('should return sentry config injector plugin in development mode', async () => {
const originalNodeEnv = process.env.NODE_ENV;
process.env.NODE_ENV = 'development';
Expand Down
5 changes: 5 additions & 0 deletions packages/remix/src/vite/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,8 @@ export function sentryRemixVitePlugin(options: SentryRemixVitePluginOptions = {}

return plugins;
}

/**
* Default export of `@sentry/remix/vite`. It is the same function as {@link sentryRemixVitePlugin}.
*/
export default sentryRemixVitePlugin;
6 changes: 5 additions & 1 deletion packages/remix/test/vite/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { ConfigEnv, UserConfig } from 'vite';
import { beforeEach, describe, expect, it, vi } from 'vitest';
import { sentryRemixVitePlugin } from '../../src/vite';
import sentryRemixVitePluginDefault, { sentryRemixVitePlugin } from '../../src/vite';

// Stub the orchestrion plugin so these stay pure wiring tests (no apm code transformer pulled in),
// mirroring the real plugin's two shapes.
Expand Down Expand Up @@ -67,6 +67,10 @@ function callHook(hook: unknown, ...args: unknown[]): unknown {
}

describe('sentryRemixVitePlugin', () => {
it('is the default export of the vite entry point', () => {
expect(sentryRemixVitePluginDefault).toBe(sentryRemixVitePlugin);
});

beforeEach(() => {
vi.clearAllMocks();
vi.unstubAllEnvs();
Expand Down
2 changes: 2 additions & 0 deletions packages/solidstart/rollup.npm.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ export default makeNPMConfigVariants(
external: ['solid-js/web', 'solid-js', '@sentry/solid', '@sentry/solid/solidrouter'],
output: {
dynamicImportInCjs: true,
// make it so Rollup calms down about the fact that we're combining default and named exports
exports: 'named',
},
},
}),
Expand Down
7 changes: 7 additions & 0 deletions packages/solidstart/src/vite/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
import { sentrySolidStart } from './sentrySolidStart';

export { sentrySolidStart } from './sentrySolidStart';
export type { SentrySolidStartOptions } from './sentrySolidStart';

/**
* Default export of `@sentry/solidstart/vite`. It is the same function as {@link sentrySolidStart}.
*/
export default sentrySolidStart;
5 changes: 5 additions & 0 deletions packages/solidstart/test/vite/sentrySolidStart.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import type { Plugin, UserConfig } from 'vite';
import { mergeConfig } from 'vite';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import sentrySolidStartDefault from '../../src/vite';
import { sentrySolidStart } from '../../src/vite/sentrySolidStart';

vi.spyOn(console, 'log').mockImplementation(() => {
Expand Down Expand Up @@ -45,6 +46,10 @@ afterEach(() => {
});

describe('sentrySolidStart()', () => {
it('is the default export of the vite entry point', () => {
expect(sentrySolidStartDefault).toBe(sentrySolidStart);
});

it('returns the nitro, orchestrion and source maps plugins', () => {
const names = sentrySolidStart({ org: 'org', project: 'project', authToken: 'token' }).map(plugin => plugin.name);

Expand Down
2 changes: 2 additions & 0 deletions packages/sveltekit/rollup.npm.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ export default makeNPMConfigVariants(
external: ['$app/state', '$app/stores', '@sentry/sveltekit/browser-tracing-variant', 'cloudflare:workers'],
output: {
dynamicImportInCjs: true,
// make it so Rollup calms down about the fact that we're combining default and named exports
exports: 'named',
},
},
}),
Expand Down
7 changes: 7 additions & 0 deletions packages/sveltekit/src/vite/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
import { sentrySvelteKit } from './sentryVitePlugins';

export { sentrySvelteKit } from './sentryVitePlugins';

/**
* Default export of `@sentry/sveltekit/vite`. It is the same function as {@link sentrySvelteKit}.
*/
export default sentrySvelteKit;
5 changes: 5 additions & 0 deletions packages/sveltekit/test/vite/sentrySvelteKitPlugins.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { Plugin } from 'vite';
import { describe, expect, it, vi } from 'vitest';
import sentrySvelteKitDefault from '../../src/vite';
import * as autoInstrument from '../../src/vite/autoInstrument';
import { generateVitePluginOptions, sentrySvelteKit } from '../../src/vite/sentryVitePlugins';
import * as sourceMaps from '../../src/vite/sourceMaps';
Expand Down Expand Up @@ -40,6 +41,10 @@ function getSentrySvelteKitPlugins(options?: Parameters<typeof sentrySvelteKit>[
}

describe('sentrySvelteKit()', () => {
it('is the default export of the vite entry point', () => {
expect(sentrySvelteKitDefault).toBe(sentrySvelteKit);
});

it('warns when the removed `unstable_sentryVitePluginOptions` is still set', async () => {
consoleWarnSpy.mockClear();

Expand Down
6 changes: 6 additions & 0 deletions packages/tanstackstart-react/rollup.npm.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ export default [
'src/server/index.ts',
'src/vite/index.ts',
],
packageSpecificConfig: {
output: {
// make it so Rollup calms down about the fact that we're combining default and named exports
exports: 'named',
},
},
}),
),
...makeOrchestrionLoader('./build'),
Expand Down
7 changes: 7 additions & 0 deletions packages/tanstackstart-react/src/vite/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
import { sentryTanstackStart } from './sentryTanstackStart';

export { sentryTanstackStart } from './sentryTanstackStart';
export type { SentryTanstackStartOptions } from './sentryTanstackStart';
export type { TunnelRouteOptions } from './tunnelRoute';

/**
* Default export of `@sentry/tanstackstart-react/vite`. It is the same function as {@link sentryTanstackStart}.
*/
export default sentryTanstackStart;
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { Plugin } from 'vite';
import sentryTanstackStartDefault from '../../src/vite';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import { makeAutoInstrumentMiddlewarePlugin } from '../../src/vite/autoInstrumentMiddleware';
import { sentryTanstackStart, type SentryTanstackStartOptions } from '../../src/vite/sentryTanstackStart';
Expand Down Expand Up @@ -79,6 +80,10 @@ describe('sentryTanstackStart()', () => {
process.env.NODE_ENV = 'production';
});

it('is the default export of the vite entry point', () => {
expect(sentryTanstackStartDefault).toBe(sentryTanstackStart);
});

describe('source maps', () => {
it('returns source maps plugins in production mode', () => {
const plugins = sentryTanstackStart({ autoInstrumentMiddleware: false });
Expand Down
Loading