Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix(minifier): drop bound console methods - #26568

Open
akashchamp wants to merge 2 commits into
oxc-project:mainfrom
akashchamp:fix/drop-console-bound-method
Open

fix(minifier): drop bound console methods#26568
akashchamp wants to merge 2 commits into
oxc-project:mainfrom
akashchamp:fix/drop-console-bound-method

Conversation

@akashchamp

@akashchamp akashchamp commented Sep 11, 2026

Copy link
Copy Markdown

Summary

  • Replace the console.<method> receiver with a scoped empty arrow when a bound console method is retained under compress.dropConsole.
  • Mark that replacement arrow as having no side effects, preserving the generated purity annotation for later optimization passes.
  • Cover dot-property and bracket-property bound methods so the bind call and its arguments continue to be evaluated without emitting a console call.

Closes #26373

Testing

  • cargo fmt --check
  • cargo test -p oxc_minifier --test mod drop_console — 2 passed.
  • cargo test -p oxc_minifier --test mod — 703 passed, 0 failed, 33 ignored.
  • cargo clippy -p oxc_minifier --all-targets --all-features -- -D warnings
  • cargo lintgen
  • Manually built the N-API minifier and ran the issue reproducer. The output retained (() => {}).bind(console), emitted no console.log call, and invoked the replacement-bound function.
  • just ready could not start because just and its remaining JavaScript tool prerequisites are unavailable on the remote host.

AI disclosure

AI assistance was used for PR development.

@akashchamp
akashchamp requested a review from Dunqing as a code owner September 11, 2026 20:54
let scope_id = ctx.create_child_scope_of_current(ScopeFlags::Arrow | ScopeFlags::Function);
let empty_function =
Expression::new_arrow_function_expression_with_scope_id_and_pure_and_pife(
span, false, None, params, None, body, scope_id, false, false, ctx,

@armano2 armano2 Sep 11, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this should be marked as pure true, false, ctx

Preserve no-side-effects metadata when replacing a bound console method.

Signed-off-by: Akash Kumar <[email protected]>
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 this pull request may close these issues.

minifier: handle console.*.bind(console) for compress.dropConsole: true

2 participants