How This Example Works
Production minifiers rename identifiers (customer → c), fold module constants directly into arithmetic (TAX_RATE = 0.085 disappears), eliminate unused variables (rawAuditToken), and inline single-use variables like fullName, isVip, lineTotal, and taxAmount.
With the Scopes proposal, each GeneratedRange provides a values array mapping every variable in its OriginalScope to an arbitrary JavaScript binding expression (or null when optimized out). Chrome DevTools uses this information to reconstruct the Scope sidebar, render inline variable hints, populate autocomplete suggestions with original variable names, and evaluate Conditional Breakpoints and Console expressions via debug evaluate.
What to Try & Verify in DevTools
Try:Click "Run & Pause in Debugger" with DevTools open (Sources panel) to pause at debugger; in order-pricing.ts.
- Local Scope (
calculateInvoice):fullName("Ada Lovelace"),isVip(true),subtotal(250),discountRate(0.15),discountedSubtotal(212.5), andtaxAmount(18.0625) are all reconstructed from binding expressions. - Module Scope: Folded constants
TAX_RATE(0.085),CURRENCY("USD"), andFREE_SHIPPING_MIN(100) appear in theModulesection. - Eliminated Variable:
rawAuditToken(bound tonull) displays cleanly as<unavailable>.
Try:While paused in order-pricing.ts, inspect the editor lines 19–34 and hover over variables in the source code.
- Inline Value Hints: Authored variables (
subtotal,discountedSubtotal,grandTotal) show live inline values at the end of their lines. - Hover Popovers: Hovering over
customer,taxAmount, orTAX_RATEopens an interactive preview evaluated from the source map binding.
Try:Open the Console drawer (Esc) while paused and type prefixes like disc, tax, FREE_, or fullN.
- Original Identifiers Suggested: Autocomplete offers
discountRate,discountedSubtotal,taxAmount,FREE_SHIPPING_MIN, andfullNamedirectly from the activeOriginalScopechain.
Try:Right-click line 26 (subtotal += lineTotal;), add a conditional breakpoint item.quantity > 1 && lineTotal < 100, resume (F8), and click "Run & Pause in Debugger" again.
- Autocomplete in Condition Input: Typing
itemandlineTotalin the breakpoint dialog offers scope-aware suggestions. - Targeted Pause on Item #2: V8 skips item 1 (
MECH-KB,qty: 1, lineTotal: 140), pauses inside theBlockscope only on item 2 (USB-C-CABLE,qty: 2, lineTotal: 45), and skips item 3.
Try:Copy and run the test expressions below in the DevTools Console while paused.
- Transparent AST Rewriting: Expressions mixing
fullName,taxAmount,shippingFee, andTAX_RATEare automatically rewritten to their underlyingbundle.jsbindings (c,d * 0.085, etc.) before evaluation.
Other things to try
- Add a logpoint in the
forloop that printsitem.skuandlineTotal. - Add Watch expressions with folded constants (
TAX_RATE,CURRENCY) and step through the loop. - Hover variables that were optimized away and check what the popover shows.
- Toggle the source map scopes experiment and compare the Scope view.
Not sure if it's a DevTools bug? Tab 4. Decoded Scopes shows what the source map actually encodes.
Try in the Console While Paused
While paused, select a frame and evaluate these in the Console (Esc opens the drawer) using the authored names:
`${fullName} (${CURRENCY}): $${grandTotal.toFixed(2)}`
discountedSubtotal + taxAmount + shippingFee
isVip && discountRate === 0.15 && TAX_RATE === 0.085