Skip to content

🐛 fix(js): keep stores to top-level bindings - #2525

Merged
gaborbernat merged 1 commit into
tox-dev:mainfrom
gaborbernat:fix/js-global-stores
Nov 20, 2026
Merged

gaborbernat merged 1 commit into
tox-dev:mainfrom
gaborbernat:fix/js-global-stores

Conversation

@gaborbernat

Copy link
Copy Markdown
Member

minify_js() dropped assignments to top-level bindings that the script never read again:

var x=1;x=2        // was: var x=1
var x;x=g()        // was: var x;g()
var x=1;function f(){x=2}f()   // was: ...function f(){}f()

A top-level var, let or function is a global that another script on the page can read, so its stores are observable. dead_store_value now refuses a target declared in the global scope. Stores to function-local bindings are still dropped as before.

The minify-js benchmark sizes don't change: the libraries keep their code inside a function wrapper.

@gaborbernat gaborbernat added the bug Something isn't working label Nov 20, 2026
@codspeed

codspeed Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Merging this PR will regress 1 benchmark

2 warnings

⚠️ 9 benchmarks with a significant change ran on different hardware

Their base and head results were measured on machines with a different CPU, core count or memory, so the changes might not come from the code. Run base and head on the same runner type.

Learn more about Macro Runners

See affected benchmarks

⚠️ 9 benchmarks with a significant change ran in a different software environment

Their base and head results were measured with a different OS or toolchain, such as compiler, runtime or library versions, so the changes might come from this difference rather than from the code. Open an affected benchmark to see what changed.

See affected benchmarks

⚡ 8 improved benchmarks
❌ 1 regressed benchmark
✅ 571 untouched benchmarks
⏩ 91 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
❌ test_feature[serialize-named-small] 815.7 µs 861.3 µs -5.3%
⚡ test_feature[build-e] 2 ms 1 ms +99%
⚡ test_mutating_feature[linkify-node-wide-links] 13.5 ms 7.3 ms +83.95%
⚡ test_feature[linkify-traversal-callbacks] 8.1 ms 4.8 ms +68.05%
⚡ test_feature[construct] 709.2 µs 535.4 µs +32.46%
⚡ test_feature[build] 1,049.3 µs 876.2 µs +19.75%
⚡ test_feature[shadow] 1,085 µs 912.4 µs +18.91%
⚡ test_mutating_feature[observe-registrations] 1.2 ms 1.2 ms +5.19%
⚡ test_feature[canonicalize-deep-xlink] 331.9 µs 315.8 µs +5.11%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing gaborbernat:fix/js-global-stores (77b832a) with main (fb99191)2

Open in CodSpeed

Footnotes

  1. 91 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

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

dead_store_value dropped an assignment to any binding the script never read
again, top-level ones included. A top-level var, let or function is a global
another script can read, so its stores are observable and now stay.
@gaborbernat
gaborbernat merged commit 2e65d17 into tox-dev:main Nov 20, 2026
45 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant