Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sourcemap URL mapping comment should be at the bottom #1505

Closed
Jesse-Box opened this issue Mar 8, 2023 · 5 comments · Fixed by #1511
Closed

Sourcemap URL mapping comment should be at the bottom #1505

Jesse-Box opened this issue Mar 8, 2023 · 5 comments · Fixed by #1511
Assignees

Comments

@Jesse-Box
Copy link

Problem

Historically, browsers always look at the bottom of the minified code for the comment.

Acceptance Criteria

Put it at the bottom ;)

@kamilogorek
Copy link
Contributor

It is already the case for DebugID and sourceMappingUrlis generated by 3rd party tools (compilers, transpilers), so we don't control that:

ref:

/// Appends the following text to a file:
/// ```
///
/// <CODE_SNIPPET>[<debug_id>]
/// //# sentryDebugId=<debug_id>
///```
/// where `<CODE_SNIPPET>[<debug_id>]`
/// is `CODE_SNIPPET_TEMPLATE` with `debug_id` substituted for the `__SENTRY_DEBUG_ID__`
/// placeholder.
fn fixup_js_file(js_path: &Path, debug_id: Uuid) -> Result<()> {
let mut js_file = File::options().append(true).open(js_path)?;
let to_inject =
CODE_SNIPPET_TEMPLATE.replace(DEBUGID_PLACEHOLDER, &debug_id.hyphenated().to_string());
writeln!(js_file)?;
writeln!(js_file, "{to_inject}")?;
write!(js_file, "{DEBUGID_COMMENT_PREFIX}={debug_id}")?;
Ok(())
}

@Jesse-Box
Copy link
Author

We found in our testing that wasn't the case

cc: @mitsuhiko

@kamilogorek
Copy link
Contributor

image

@loewenheim
Copy link
Contributor

The problem is that the comment may be at the bottom when we look at the file, but then we append something else. We should inject our stuff immediately before the comment.

@loewenheim loewenheim linked a pull request Mar 8, 2023 that will close this issue
@kamilogorek
Copy link
Contributor

Ohhhhhh, now I get it! #1511

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants