Skip to content

Conversation

cernymatej
Copy link
Contributor

@cernymatej cernymatej commented Feb 27, 2025

This PR brings the implementation of the ScopeTracker from Nuxt into the oxc-walker.
I have refactored it and cleaned it up slightly.

The ScopeTracker class enables convenient tracking of declared identifiers and accessing their relevant nodes' start / end positions to make code transformations easier. For example, it stores a declaration of a variable, and then allows easy access to a custom ScopeTrackerVariable node, which provides access to the string positions of the whole VariableDeclaration, based on the identifier name.

@cernymatej cernymatej marked this pull request as ready for review May 28, 2025 01:05
@danielroe
Copy link
Collaborator

Initially we had a MagicString object because this was something oxc-parser was considering doing, for performance reasons (the sourcemap could be created in Rust). But now this is dropped, and I think it best to keep the walker minimal.

Copy link
Member

@Boshen Boshen left a comment

Choose a reason for hiding this comment

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

@danielroe merge?

@danielroe danielroe merged commit ce5dd98 into oxc-project:main Jun 1, 2025
2 checks passed
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.

3 participants