From f95bbf6d53ee38555bfe886988181c5129fd3c56 Mon Sep 17 00:00:00 2001 From: Luca Forstner Date: Wed, 17 May 2023 12:55:01 +0200 Subject: [PATCH] ref(core): Use debug ID as filename for upload --- .../src/plugins/debug-id-upload.ts | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/packages/bundler-plugin-core/src/plugins/debug-id-upload.ts b/packages/bundler-plugin-core/src/plugins/debug-id-upload.ts index e60b59b4..319ffc78 100644 --- a/packages/bundler-plugin-core/src/plugins/debug-id-upload.ts +++ b/packages/bundler-plugin-core/src/plugins/debug-id-upload.ts @@ -71,12 +71,7 @@ export function debugIdUploadPlugin({ await Promise.all( debugIdChunkFilePaths.map(async (chunkFilePath, chunkIndex): Promise => { - await prepareBundleForDebugIdUpload( - chunkFilePath, - tmpUploadFolder, - String(chunkIndex), - logger - ); + await prepareBundleForDebugIdUpload(chunkFilePath, tmpUploadFolder, chunkIndex, logger); }) ); @@ -123,7 +118,7 @@ export function debugIdUploadPlugin({ export async function prepareBundleForDebugIdUpload( bundleFilePath: string, uploadFolder: string, - uniqueUploadName: string, + chunkIndex: number, logger: Logger ) { let bundleContent; @@ -139,12 +134,14 @@ export async function prepareBundleForDebugIdUpload( const debugId = determineDebugIdFromBundleSource(bundleContent); if (debugId === undefined) { - logger.warn( + logger.debug( `Could not determine debug ID from bundle. This can happen if you did not clean your output folder before installing the Sentry plugin. File will not be source mapped: ${bundleFilePath}` ); return; } + const uniqueUploadName = `${debugId}-${chunkIndex}`; + bundleContent += `\n//# debugId=${debugId}`; const writeSourceFilePromise = fs.promises.writeFile( path.join(uploadFolder, `${uniqueUploadName}.js`), @@ -218,7 +215,8 @@ async function determineSourceMapPathFromBundle( // noop } - logger.warn(`Could not determine source map path for bundle: ${bundlePath}`); + // This is just a debug message because it can be quite spammy for some frameworks + logger.debug(`Could not determine source map path for bundle: ${bundlePath}`); return undefined; }