Skip to content

Commit 9c0def8

Browse files
author
Luca Forstner
authored
ref(core): Use debug ID as filename for upload (#247)
1 parent f4446a5 commit 9c0def8

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

packages/bundler-plugin-core/src/plugins/debug-id-upload.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export function debugIdUploadPlugin({
8080
await prepareBundleForDebugIdUpload(
8181
chunkFilePath,
8282
tmpUploadFolder,
83-
String(chunkIndex),
83+
chunkIndex,
8484
logger,
8585
rewriteSourcesHook ?? defaultRewriteSourcesHook
8686
);
@@ -130,7 +130,7 @@ export function debugIdUploadPlugin({
130130
export async function prepareBundleForDebugIdUpload(
131131
bundleFilePath: string,
132132
uploadFolder: string,
133-
uniqueUploadName: string,
133+
chunkIndex: number,
134134
logger: Logger,
135135
rewriteSourcesHook: RewriteSourcesHook
136136
) {
@@ -147,12 +147,14 @@ export async function prepareBundleForDebugIdUpload(
147147

148148
const debugId = determineDebugIdFromBundleSource(bundleContent);
149149
if (debugId === undefined) {
150-
logger.warn(
150+
logger.debug(
151151
`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}`
152152
);
153153
return;
154154
}
155155

156+
const uniqueUploadName = `${debugId}-${chunkIndex}`;
157+
156158
bundleContent += `\n//# debugId=${debugId}`;
157159
const writeSourceFilePromise = fs.promises.writeFile(
158160
path.join(uploadFolder, `${uniqueUploadName}.js`),
@@ -227,7 +229,8 @@ async function determineSourceMapPathFromBundle(
227229
// noop
228230
}
229231

230-
logger.warn(`Could not determine source map path for bundle: ${bundlePath}`);
232+
// This is just a debug message because it can be quite spammy for some frameworks
233+
logger.debug(`Could not determine source map path for bundle: ${bundlePath}`);
231234
return undefined;
232235
}
233236

0 commit comments

Comments
 (0)