From bea93f934b08638b883b2a361bff3c266b91fc39 Mon Sep 17 00:00:00 2001 From: Luca Forstner Date: Fri, 29 Nov 2024 12:07:41 +0000 Subject: [PATCH 1/4] nextjs --- packages/nextjs/src/config/types.ts | 2 +- packages/nextjs/src/config/webpack.ts | 24 ++++++++++++++++++++++-- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/packages/nextjs/src/config/types.ts b/packages/nextjs/src/config/types.ts index 75b1c29281fa..75ce7258fae5 100644 --- a/packages/nextjs/src/config/types.ts +++ b/packages/nextjs/src/config/types.ts @@ -470,7 +470,7 @@ export type IgnoreWarningsOption = ( // The two possible formats for providing custom webpack config in `next.config.js` export type WebpackConfigFunction = (config: WebpackConfigObject, options: BuildContext) => WebpackConfigObject; export type WebpackConfigObject = { - devtool?: string; + devtool?: string | boolean; plugins?: Array; entry: WebpackEntryProperty; output: { filename: string; path: string }; diff --git a/packages/nextjs/src/config/webpack.ts b/packages/nextjs/src/config/webpack.ts index 445ef32ab1e3..610cf96585c8 100644 --- a/packages/nextjs/src/config/webpack.ts +++ b/packages/nextjs/src/config/webpack.ts @@ -336,13 +336,33 @@ export function constructWebpackConfigFunction( if (sentryWebpackPlugin) { if (!userSentryOptions.sourcemaps?.disable) { + // TODO(v9): Remove this warning + if (newConfig.devtool === false) { + const runtimePrefix = !isServer ? 'Client' : runtime === 'edge' ? 'Edge' : 'Node.js'; + // eslint-disable-next-line no-console + console.warn( + `[@sentry/nextjs - ${runtimePrefix}] You disabled sourcemaps with the Webpack \`devtool\` option. Currently, the Sentry SDK will override this option to generate sourcemaps. In future versions, the Sentry SDK will not override the \`devtool\` option if you explicitly disable it. If you want to generate and upload sourcemaps please set the \`devtool\` option to true or undefined.`, + ); + } + + // TODO(v9): Remove this warning and print warning in case source map deletion is auto configured + if (!isServer && !userSentryOptions.sourcemaps?.deleteSourcemapsAfterUpload) { + // eslint-disable-next-line no-console + console.warn( + "[@sentry/nextjs] The Sentry SDK has enabled source map generation for your Next.js app. If you don't want to serve Source Maps to your users, either set the `deleteSourceMapsAfterUpload` option to true, or manually delete the source maps after the build. In future Sentry SDK versions `deleteSourceMapsAfterUpload` will default to `true`.", + ); + } + // `hidden-source-map` produces the same sourcemaps as `source-map`, but doesn't include the `sourceMappingURL` // comment at the bottom. For folks who aren't publicly hosting their sourcemaps, this is helpful because then // the browser won't look for them and throw errors into the console when it can't find them. Because this is a // front-end-only problem, and because `sentry-cli` handles sourcemaps more reliably with the comment than // without, the option to use `hidden-source-map` only applies to the client-side build. - newConfig.devtool = - isServer || userNextConfig.productionBrowserSourceMaps ? 'source-map' : 'hidden-source-map'; + if (isServer || userNextConfig.productionBrowserSourceMaps) { + newConfig.devtool = 'source-map'; + } else { + newConfig.devtool = 'hidden-source-map'; + } } newConfig.plugins = newConfig.plugins || []; From af672195d6b7ad2ac0a5634e47600a9d09f741ec Mon Sep 17 00:00:00 2001 From: Luca Forstner Date: Fri, 29 Nov 2024 12:29:27 +0000 Subject: [PATCH 2/4] This is chaos --- packages/astro/src/integration/index.ts | 9 +++++++++ packages/nextjs/src/config/webpack.ts | 2 +- packages/solidstart/src/vite/sourceMaps.ts | 3 +-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/packages/astro/src/integration/index.ts b/packages/astro/src/integration/index.ts index eb976e24213d..f038bfc67cb2 100644 --- a/packages/astro/src/integration/index.ts +++ b/packages/astro/src/integration/index.ts @@ -35,6 +35,15 @@ export const sentryAstro = (options: SentryOptions = {}): AstroIntegration => { // We don't need to check for AUTH_TOKEN here, because the plugin will pick it up from the env if (shouldUploadSourcemaps && command !== 'dev') { + // TODO(v9): Remove this warning + if (config.vite.build?.sourcemap === false) { + logger.warn( + "You disabled sourcemaps with the `vite.build.sourcemap` option. Currently, the Sentry SDK will override this option to generate sourcemaps. In future versions, the Sentry SDK will not override the `vite.build.sourcemap` option if you explicitly disable it. If you want to generate and upload sourcemaps please set the `vite.build.sourcemap` option to 'hidden' or undefined.", + ); + } + + // TODO: Add deleteSourcemapsAfterUpload option and warn if it isn't set. + updateConfig({ vite: { build: { diff --git a/packages/nextjs/src/config/webpack.ts b/packages/nextjs/src/config/webpack.ts index 610cf96585c8..20f1a00ce3c0 100644 --- a/packages/nextjs/src/config/webpack.ts +++ b/packages/nextjs/src/config/webpack.ts @@ -341,7 +341,7 @@ export function constructWebpackConfigFunction( const runtimePrefix = !isServer ? 'Client' : runtime === 'edge' ? 'Edge' : 'Node.js'; // eslint-disable-next-line no-console console.warn( - `[@sentry/nextjs - ${runtimePrefix}] You disabled sourcemaps with the Webpack \`devtool\` option. Currently, the Sentry SDK will override this option to generate sourcemaps. In future versions, the Sentry SDK will not override the \`devtool\` option if you explicitly disable it. If you want to generate and upload sourcemaps please set the \`devtool\` option to true or undefined.`, + `[@sentry/nextjs - ${runtimePrefix}] You disabled sourcemaps with the Webpack \`devtool\` option. Currently, the Sentry SDK will override this option to generate sourcemaps. In future versions, the Sentry SDK will not override the \`devtool\` option if you explicitly disable it. If you want to generate and upload sourcemaps please set the \`devtool\` option to 'hidden-source-map' or undefined.`, ); } diff --git a/packages/solidstart/src/vite/sourceMaps.ts b/packages/solidstart/src/vite/sourceMaps.ts index 548038515e79..cd7c76db6c6d 100644 --- a/packages/solidstart/src/vite/sourceMaps.ts +++ b/packages/solidstart/src/vite/sourceMaps.ts @@ -22,8 +22,7 @@ export function makeSourceMapsVitePlugin(options: SentrySolidStartPluginOptions) if (!sourceMapsUploadOptions?.filesToDeleteAfterUpload) { // eslint-disable-next-line no-console console.warn( - `[Sentry SolidStart PLugin] We recommend setting the \`sourceMapsUploadOptions.filesToDeleteAfterUpload\` option to clean up source maps after uploading. -[Sentry SolidStart Plugin] Otherwise, source maps might be deployed to production, depending on your configuration`, + '[Sentry SolidStart PLugin] We recommend setting the `sourceMapsUploadOptions.filesToDeleteAfterUpload` option to clean up source maps after uploading. Otherwise, source maps might be deployed to production, depending on your configuration. In future versions the SDK will default to deleting sourcemaps after uploading them.', ); } } From 9eb8d97d2ec67394bb341b01852fd2a29096e7c5 Mon Sep 17 00:00:00 2001 From: Luca Forstner Date: Fri, 29 Nov 2024 12:36:20 +0000 Subject: [PATCH 3/4] solidstart --- packages/solidstart/src/vite/sourceMaps.ts | 23 +++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/packages/solidstart/src/vite/sourceMaps.ts b/packages/solidstart/src/vite/sourceMaps.ts index cd7c76db6c6d..b6923b9d86b6 100644 --- a/packages/solidstart/src/vite/sourceMaps.ts +++ b/packages/solidstart/src/vite/sourceMaps.ts @@ -15,17 +15,22 @@ export function makeSourceMapsVitePlugin(options: SentrySolidStartPluginOptions) apply: 'build', enforce: 'post', config(config) { - const sourceMapsPreviouslyNotEnabled = !config.build?.sourcemap; - if (debug && sourceMapsPreviouslyNotEnabled) { + // TODO(v9): Remove this warning + if (config.build?.sourcemap === false) { // eslint-disable-next-line no-console - console.log('[Sentry SolidStart Plugin] Enabling source map generation'); - if (!sourceMapsUploadOptions?.filesToDeleteAfterUpload) { - // eslint-disable-next-line no-console - console.warn( - '[Sentry SolidStart PLugin] We recommend setting the `sourceMapsUploadOptions.filesToDeleteAfterUpload` option to clean up source maps after uploading. Otherwise, source maps might be deployed to production, depending on your configuration. In future versions the SDK will default to deleting sourcemaps after uploading them.', - ); - } + console.warn( + "[Sentry SolidStart PLugin] You disabled sourcemaps with the `build.sourcemap` option. Currently, the Sentry SDK will override this option to generate sourcemaps. In future versions, the Sentry SDK will not override the `build.sourcemap` option if you explicitly disable it. If you want to generate and upload sourcemaps please set the `build.sourcemap` option to 'hidden' or undefined.", + ); } + + // TODO(v9): Remove this warning and print warning in case source map deletion is auto configured + if (!sourceMapsUploadOptions?.filesToDeleteAfterUpload) { + // eslint-disable-next-line no-console + console.warn( + "[Sentry SolidStart PLugin] The Sentry SDK has enabled source map generation for your SolidStart app. If you don't want to serve Source Maps to your users, either configure the `filesToDeleteAfterUpload` option with a glob to remove source maps after uploading them, or manually delete the source maps after the build. In future Sentry SDK versions source maps will be deleted automatically after uploading them.", + ); + } + return { ...config, build: { From e5338ef46f35d56fe9441193ed5c2a95ff03b9fd Mon Sep 17 00:00:00 2001 From: Luca Forstner Date: Fri, 29 Nov 2024 17:07:57 +0000 Subject: [PATCH 4/4] beep boop --- packages/astro/src/integration/index.ts | 2 +- packages/solidstart/src/vite/sourceMaps.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/astro/src/integration/index.ts b/packages/astro/src/integration/index.ts index f038bfc67cb2..49e33ff0231d 100644 --- a/packages/astro/src/integration/index.ts +++ b/packages/astro/src/integration/index.ts @@ -36,7 +36,7 @@ export const sentryAstro = (options: SentryOptions = {}): AstroIntegration => { // We don't need to check for AUTH_TOKEN here, because the plugin will pick it up from the env if (shouldUploadSourcemaps && command !== 'dev') { // TODO(v9): Remove this warning - if (config.vite.build?.sourcemap === false) { + if (config?.vite?.build?.sourcemap === false) { logger.warn( "You disabled sourcemaps with the `vite.build.sourcemap` option. Currently, the Sentry SDK will override this option to generate sourcemaps. In future versions, the Sentry SDK will not override the `vite.build.sourcemap` option if you explicitly disable it. If you want to generate and upload sourcemaps please set the `vite.build.sourcemap` option to 'hidden' or undefined.", ); diff --git a/packages/solidstart/src/vite/sourceMaps.ts b/packages/solidstart/src/vite/sourceMaps.ts index b6923b9d86b6..0f8178356d88 100644 --- a/packages/solidstart/src/vite/sourceMaps.ts +++ b/packages/solidstart/src/vite/sourceMaps.ts @@ -19,7 +19,7 @@ export function makeSourceMapsVitePlugin(options: SentrySolidStartPluginOptions) if (config.build?.sourcemap === false) { // eslint-disable-next-line no-console console.warn( - "[Sentry SolidStart PLugin] You disabled sourcemaps with the `build.sourcemap` option. Currently, the Sentry SDK will override this option to generate sourcemaps. In future versions, the Sentry SDK will not override the `build.sourcemap` option if you explicitly disable it. If you want to generate and upload sourcemaps please set the `build.sourcemap` option to 'hidden' or undefined.", + "[Sentry SolidStart Plugin] You disabled sourcemaps with the `build.sourcemap` option. Currently, the Sentry SDK will override this option to generate sourcemaps. In future versions, the Sentry SDK will not override the `build.sourcemap` option if you explicitly disable it. If you want to generate and upload sourcemaps please set the `build.sourcemap` option to 'hidden' or undefined.", ); } @@ -27,7 +27,7 @@ export function makeSourceMapsVitePlugin(options: SentrySolidStartPluginOptions) if (!sourceMapsUploadOptions?.filesToDeleteAfterUpload) { // eslint-disable-next-line no-console console.warn( - "[Sentry SolidStart PLugin] The Sentry SDK has enabled source map generation for your SolidStart app. If you don't want to serve Source Maps to your users, either configure the `filesToDeleteAfterUpload` option with a glob to remove source maps after uploading them, or manually delete the source maps after the build. In future Sentry SDK versions source maps will be deleted automatically after uploading them.", + "[Sentry SolidStart Plugin] The Sentry SDK has enabled source map generation for your SolidStart app. If you don't want to serve Source Maps to your users, either configure the `filesToDeleteAfterUpload` option with a glob to remove source maps after uploading them, or manually delete the source maps after the build. In future Sentry SDK versions source maps will be deleted automatically after uploading them.", ); }