Skip to content

Commit c7b5f46

Browse files
committed
refactor: isolate webpack options in their own namespace and mark toplevel ones for deprecation
1 parent 2f8a039 commit c7b5f46

File tree

1 file changed

+120
-0
lines changed

1 file changed

+120
-0
lines changed

packages/nextjs/src/config/types.ts

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,106 @@ export type NextConfigObject = {
5757
};
5858
};
5959

60+
export type SentryBuildWebpackOptions = {
61+
/**
62+
* Include Next.js-internal code and code from dependencies when uploading source maps.
63+
*
64+
* Note: Enabling this option can lead to longer build times.
65+
* Disabling this option will leave you without readable stacktraces for dependencies and Next.js-internal code.
66+
*
67+
* Defaults to `false`.
68+
*/
69+
// Enabling this option may upload a lot of source maps and since the sourcemap upload endpoint in Sentry is super
70+
// slow we don't enable it by default so that we don't opaquely increase build times for users.
71+
// TODO: Add an alias to this function called "uploadSourceMapsForDependencies"
72+
widenClientFileUpload?: boolean;
73+
74+
/**
75+
* Automatically instrument Next.js data fetching methods and Next.js API routes with error and performance monitoring.
76+
* Defaults to `true`.
77+
*/
78+
autoInstrumentServerFunctions?: boolean;
79+
80+
/**
81+
* Automatically instrument Next.js middleware with error and performance monitoring. Defaults to `true`.
82+
*/
83+
autoInstrumentMiddleware?: boolean;
84+
85+
/**
86+
* Automatically instrument components in the `app` directory with error monitoring. Defaults to `true`.
87+
*/
88+
autoInstrumentAppDirectory?: boolean;
89+
90+
/**
91+
* Automatically create cron monitors in Sentry for your Vercel Cron Jobs if configured via `vercel.json`.
92+
*
93+
* Defaults to `false`.
94+
*/
95+
automaticVercelMonitors?: boolean;
96+
97+
/**
98+
* Exclude certain serverside API routes or pages from being instrumented with Sentry during build-time. This option
99+
* takes an array of strings or regular expressions. This options also affects pages in the `app` directory.
100+
*
101+
* NOTE: Pages should be specified as routes (`/animals` or `/api/animals/[animalType]/habitat`), not filepaths
102+
* (`pages/animals/index.js` or `.\src\pages\api\animals\[animalType]\habitat.tsx`), and strings must be be a full,
103+
* exact match.
104+
*
105+
* Notice: If you build Next.js with turbopack, the Sentry SDK will no longer apply build-time instrumentation and
106+
* purely rely on Next.js telemetry features, meaning that this option will effectively no-op.
107+
*/
108+
excludeServerRoutes?: Array<RegExp | string>;
109+
110+
/**
111+
* Disables automatic injection of Sentry's Webpack configuration.
112+
*
113+
* By default, the Sentry Next.js SDK injects its own Webpack configuration to enable features such as
114+
* source map upload and automatic instrumentation. Set this option to `true` if you want to prevent
115+
* the SDK from modifying your Webpack config (for example, if you want to handle Sentry integration manually
116+
* or if you are on an older version of Next.js while using Turbopack).
117+
*/
118+
disableSentryConfig?: boolean;
119+
120+
/**
121+
* Tree shakes Sentry SDK logger statements from the bundle.
122+
*/
123+
treeshake?: {
124+
/**
125+
* Tree shakes Sentry SDK logger statements from the bundle. Note that this doesn't affect Sentry Logs.
126+
*/
127+
debugLogs?: boolean;
128+
};
129+
130+
/**
131+
* Options to be passed directly to the Sentry Webpack Plugin (`@sentry/webpack-plugin`) that ships with the Sentry SDK.
132+
* You can use this option to override any options the SDK passes to the Webpack plugin.
133+
*
134+
* Please note that this option is unstable and may change in a breaking way in any release.
135+
*/
136+
unstable_sentryWebpackPluginOptions?: SentryWebpackPluginOptions;
137+
138+
/**
139+
* Options related to react component name annotations.
140+
* Disabled by default, unless a value is set for this option.
141+
* When enabled, your app's DOM will automatically be annotated during build-time with their respective component names.
142+
* This will unlock the capability to search for Replays in Sentry by component name, as well as see component names in breadcrumbs and performance monitoring.
143+
* Please note that this feature is not currently supported by the esbuild bundler plugins, and will only annotate React components
144+
*
145+
* @deprecated Use `webpack.reactComponentAnnotation` instead.
146+
*/
147+
reactComponentAnnotation?: {
148+
/**
149+
* Whether the component name annotate plugin should be enabled or not.
150+
*/
151+
enabled?: boolean;
152+
153+
/**
154+
* A list of strings representing the names of components to ignore. The plugin will not apply `data-sentry` annotations on the DOM element for these components.
155+
*/
156+
ignoredComponents?: string[];
157+
};
158+
};
159+
60160
export type SentryBuildOptions = {
61161
/**
62162
* The slug of the Sentry organization associated with the app.
@@ -363,6 +463,8 @@ export type SentryBuildOptions = {
363463
* When enabled, your app's DOM will automatically be annotated during build-time with their respective component names.
364464
* This will unlock the capability to search for Replays in Sentry by component name, as well as see component names in breadcrumbs and performance monitoring.
365465
* Please note that this feature is not currently supported by the esbuild bundler plugins, and will only annotate React components
466+
*
467+
* @deprecated Use `webpack.reactComponentAnnotation` instead.
366468
*/
367469
reactComponentAnnotation?: {
368470
/**
@@ -381,6 +483,7 @@ export type SentryBuildOptions = {
381483
* You can use this option to override any options the SDK passes to the webpack plugin.
382484
*
383485
* Please note that this option is unstable and may change in a breaking way in any release.
486+
* @deprecated Use `webpack.unstable_sentryWebpackPluginOptions` instead.
384487
*/
385488
unstable_sentryWebpackPluginOptions?: SentryWebpackPluginOptions;
386489

@@ -391,6 +494,7 @@ export type SentryBuildOptions = {
391494
* Disabling this option will leave you without readable stacktraces for dependencies and Next.js-internal code.
392495
*
393496
* Defaults to `false`.
497+
* @deprecated Use `webpack.widenClientFileUpload` instead.
394498
*/
395499
// Enabling this option may upload a lot of source maps and since the sourcemap upload endpoint in Sentry is super
396500
// slow we don't enable it by default so that we don't opaquely increase build times for users.
@@ -400,16 +504,19 @@ export type SentryBuildOptions = {
400504
/**
401505
* Automatically instrument Next.js data fetching methods and Next.js API routes with error and performance monitoring.
402506
* Defaults to `true`.
507+
* @deprecated Use `webpack.autoInstrumentServerFunctions` instead.
403508
*/
404509
autoInstrumentServerFunctions?: boolean;
405510

406511
/**
407512
* Automatically instrument Next.js middleware with error and performance monitoring. Defaults to `true`.
513+
* @deprecated Use `webpack.autoInstrumentMiddleware` instead.
408514
*/
409515
autoInstrumentMiddleware?: boolean;
410516

411517
/**
412518
* Automatically instrument components in the `app` directory with error monitoring. Defaults to `true`.
519+
* @deprecated Use `webpack.autoInstrumentAppDirectory` instead.
413520
*/
414521
autoInstrumentAppDirectory?: boolean;
415522

@@ -423,6 +530,8 @@ export type SentryBuildOptions = {
423530
*
424531
* Notice: If you build Next.js with turbopack, the Sentry SDK will no longer apply build-time instrumentation and
425532
* purely rely on Next.js telemetry features, meaning that this option will effectively no-op.
533+
*
534+
* @deprecated Use `webpack.excludeServerRoutes` instead.
426535
*/
427536
excludeServerRoutes?: Array<RegExp | string>;
428537

@@ -439,13 +548,17 @@ export type SentryBuildOptions = {
439548

440549
/**
441550
* Tree shakes Sentry SDK logger statements from the bundle.
551+
*
552+
* @deprecated Use `webpack.treeshake.debugLogs` instead.
442553
*/
443554
disableLogger?: boolean;
444555

445556
/**
446557
* Automatically create cron monitors in Sentry for your Vercel Cron Jobs if configured via `vercel.json`.
447558
*
448559
* Defaults to `false`.
560+
*
561+
* @deprecated Use `webpack.automaticVercelMonitors` instead.
449562
*/
450563
automaticVercelMonitors?: boolean;
451564

@@ -497,6 +610,8 @@ export type SentryBuildOptions = {
497610
* the SDK from modifying your Webpack config (for example, if you want to handle Sentry integration manually
498611
* or if you are on an older version of Next.js while using Turbopack).
499612
*
613+
* @deprecated Use `webpack.disableSentryConfig` instead.
614+
*
500615
* @default false
501616
*/
502617
disableSentryWebpackConfig?: boolean;
@@ -519,6 +634,11 @@ export type SentryBuildOptions = {
519634
_experimental?: Partial<{
520635
thirdPartyOriginStackFrames?: boolean;
521636
}>;
637+
638+
/**
639+
* Options related to webpack builds, has no effect if you are using Turbopack.
640+
*/
641+
webpack?: SentryBuildWebpackOptions;
522642
};
523643

524644
export type NextConfigFunction = (

0 commit comments

Comments
 (0)