Skip to content

Conversation

@Boshen
Copy link
Member

@Boshen Boshen commented Aug 18, 2025

closes #13174

This should reduce sourcemap memory usage by a huge amount.

These tokens were added in esbuild for code coverage: evanw/esbuild@c4d45e6

But esbuild has an optimization to not generate these tokens when } is not on the same line

if class.CloseBraceLoc.Start > class.BodyLoc.Start {
    p.addSourceMapping(class.CloseBraceLoc)
}

We should revisit these tokens later in the future.

Copilot AI review requested due to automatic review settings August 18, 2025 11:08
@graphite-app
Copy link
Contributor

graphite-app bot commented Aug 18, 2025

How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

@github-actions github-actions bot added A-minifier Area - Minifier A-codegen Area - Code Generation C-bug Category - Bug labels Aug 18, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR removes end sourcemap generation for closing brackets (}, ], )), which should significantly reduce sourcemap memory usage. This follows an optimization pattern used by esbuild that only generates sourcemaps for closing brackets under specific conditions.

  • Removes add_source_mapping_end function and its calls throughout the codebase
  • Updates development dependencies to support sourcemap visualization examples
  • Adds new transformer plugin example demonstrating define replacement functionality

Reviewed Changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
crates/oxc_codegen/src/lib.rs Removes add_source_mapping_end function and its usage in block printing methods
crates/oxc_codegen/src/gen.rs Removes calls to add_source_mapping_end for various AST node types (arrays, objects, patterns)
crates/oxc_minifier/examples/minifier.rs Updates sourcemap visualization to use new SourcemapVisualizer utility
crates/oxc_minifier/Cargo.toml Replaces base64 dependency with oxc_sourcemap for visualization
crates/oxc_transformer_plugins/examples/define.rs Adds new example demonstrating define replacement with sourcemap support
crates/oxc_transformer_plugins/Cargo.toml Adds dependencies for the new example (pico-args, oxc_semantic)

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@codspeed-hq
Copy link

codspeed-hq bot commented Aug 18, 2025

CodSpeed Instrumentation Performance Report

Merging #13180 will improve performances by 3.35%

Comparing improve-sourcemap (f10ac33) with main (deddc8c)1

Summary

⚡ 2 improvements
✅ 32 untouched benchmarks

Benchmarks breakdown

Benchmark BASE HEAD Change
codegen[RadixUIAdoptionSection.jsx] 123.6 µs 119.6 µs +3.35%
minifier[cal.com.tsx] 31.1 ms 30.1 ms +3.31%

Footnotes

  1. No successful run was found on main (f10ac33) during the generation of this report, so deddc8c was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@Boshen Boshen force-pushed the improve-sourcemap branch 2 times, most recently from f7c694d to 0b946af Compare August 18, 2025 11:38
@Boshen Boshen added the 0-merge Merge with Graphite Merge Queue label Aug 18, 2025
Copy link
Member Author

Boshen commented Aug 18, 2025

Merge activity

closes #13174

This should reduce sourcemap memory usage by a huge amount.

These tokens were added in esbuild for code coverage: evanw/esbuild@c4d45e6

But esbuild has an optimization to not generate these tokens when `}` is not on the same line

```
if class.CloseBraceLoc.Start > class.BodyLoc.Start {
    p.addSourceMapping(class.CloseBraceLoc)
}
```

We should revisit these tokens later in the future.
@graphite-app graphite-app bot force-pushed the improve-sourcemap branch from 0b946af to f10ac33 Compare August 18, 2025 11:45
@graphite-app graphite-app bot merged commit f10ac33 into main Aug 18, 2025
25 checks passed
@graphite-app graphite-app bot deleted the improve-sourcemap branch August 18, 2025 11:50
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Aug 18, 2025
graphite-app bot pushed a commit that referenced this pull request Aug 29, 2025
…ls (#13354)

added end mappings for array literals and object literals to fix stack trace.

refs #13180
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-codegen Area - Code Generation A-minifier Area - Minifier C-bug Category - Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

source mapping for closing brace is off by one

2 participants