Skip to content

Implement Oxc.scope to rename top-level bindings - #1

Closed
marcoroth wants to merge 1 commit into
mainfrom
scope
Closed

Implement Oxc.scope to rename top-level bindings#1
marcoroth wants to merge 1 commit into
mainfrom
scope

Conversation

@marcoroth

@marcoroth marcoroth commented Aug 25, 2026

Copy link
Copy Markdown
Owner

Oxc.scope renames everything a file declared at the top level, so two copies of the same script on one page never collide. Every reference to a renamed name follows it, and a name the file did not declare is left alone.

result = Oxc.scope(source, scope: "1a2b3c4d")

result.code
#=> "let count_1a2b3c4d = 0;\nfunction bump_1a2b3c4d() { count_1a2b3c4d += 1; render(label) }\n"

result.renamed
#=> {"bump" => "bump_1a2b3c4d", "count" => "count_1a2b3c4d"}

@marcoroth

marcoroth commented Aug 26, 2026

Copy link
Copy Markdown
Owner Author

Superseded by the visitor and mutation visitor in #3 and #4. Scoping is now expressible as a Ruby codemod over MutationVisitor plus symbols, which preserves formatting and comments and needs neither rename_symbol nor Codegen::with_scoping.

@marcoroth marcoroth closed this Aug 26, 2026
@marcoroth
marcoroth deleted the scope branch August 26, 2026 05:03
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.

1 participant