Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/utils/sourcemaps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -934,7 +934,7 @@ impl SourceMapProcessor {
// If we don't have a sourcemap, it's not safe to inject the code snippet at the beginning,
// because that would throw off all the mappings. Instead, inject the snippet at the very end.
// This isn't ideal, but it's the best we can do in this case.
inject::fixup_js_file_end(Arc::make_mut(&mut source_file.contents), debug_id)
inject::inject_at_end(Arc::make_mut(&mut source_file.contents), debug_id)
.context(format!("Failed to process {}", source_file.path.display()))?;
debug_id
}
Expand Down Expand Up @@ -984,7 +984,7 @@ impl SourceMapProcessor {
source_file_contents.extend(injected.as_bytes());
} else {
// We can't adjust the section offset rows, so we have to inject at the end
inject::fixup_js_file_end(source_file_contents, debug_id)
inject::inject_at_end(source_file_contents, debug_id)
.with_context(|| {
format!(
"Failed to inject debug id into {}",
Expand Down Expand Up @@ -1082,13 +1082,13 @@ impl SourceMapProcessor {
source_file_contents.extend(injected.as_bytes());
} else {
// We can't adjust the section offset rows, so we have to inject at the end
inject::fixup_js_file_end(source_file_contents, debug_id)
inject::inject_at_end(source_file_contents, debug_id)
.with_context(|| {
format!(
"Failed to inject debug id into {}",
source_file.path.display()
)
})?;
format!(
"Failed to inject debug id into {}",
source_file.path.display()
)
})?;
}
}
}
Expand Down Expand Up @@ -1134,7 +1134,7 @@ impl SourceMapProcessor {
// If we don't have a sourcemap, it's not safe to inject the code snippet at the beginning,
// because that would throw off all the mappings. Instead, inject the snippet at the very end.
// This isn't ideal, but it's the best we can do in this case.
inject::fixup_js_file_end(
inject::inject_at_end(
Arc::make_mut(&mut source_file.contents),
debug_id,
)
Expand Down
4 changes: 2 additions & 2 deletions src/utils/sourcemaps/inject.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ pub fn fixup_js_file(js_contents: &mut Vec<u8>, debug_id: DebugId) -> Result<Sou
Ok(SourceMap::from_slice(map.as_bytes()).unwrap())
}

/// Fixes up a minified JS source file with a debug id without messing with mappings.
/// Inject a minified JS source file with a debug id without changing mappings.
///
/// This changes the source file in several ways:
/// 1. The source code snippet `<CODE_SNIPPET>[<debug_id>]` is appended to the file.
Expand All @@ -221,7 +221,7 @@ pub fn fixup_js_file(js_contents: &mut Vec<u8>, debug_id: DebugId) -> Result<Sou
/// might mess up the mappings by inserting a line, with no opportunity to adjust the
/// sourcemap accordingly. However, in general it is desirable to insert the code snippet
/// as early as possible to make sure it runs even when an error is raised in the file.
pub fn fixup_js_file_end(js_contents: &mut Vec<u8>, debug_id: DebugId) -> Result<()> {
pub fn inject_at_end(js_contents: &mut Vec<u8>, debug_id: DebugId) -> Result<()> {
let mut js_lines = js_contents.lines().collect::<Result<Vec<_>, _>>()?;

js_contents.clear();
Expand Down