Skip to content

feat(rsc): custom scope analyzer to replace periscopic#1157

Open
james-elicx wants to merge 5 commits intovitejs:mainfrom
james-elicx:james/replace-periscopic
Open

feat(rsc): custom scope analyzer to replace periscopic#1157
james-elicx wants to merge 5 commits intovitejs:mainfrom
james-elicx:james/replace-periscopic

Conversation

@james-elicx
Copy link

@james-elicx james-elicx commented Mar 22, 2026

Description

This PR implements our own scope analyzer to replace periscopic.

Pulled in the test cases from both #1151 and #1155, and generated several more, to ensure that it works for several different edge cases.

The new analyzer gives the following benefits:

  • detects shadowed variables and avoids binding them.
  • binds member expressions instead of variables where possible, and de-dupes in the case where both parents and children are used.
  • detects self-referenced functions.
  • detects and binds default values in function params.
  • support for hoisting var to the function body.
  • skips re-exports from polluting scope.

I used AI to help with ensuring we were getting the right the behaviour and logic we wanted, but a large chunk of the implementation was written by myself, and the bits that weren't were refactored.

Busy Sunday!

Close #1151
Close #1155

@hi-ogawa hi-ogawa self-assigned this Mar 23, 2026
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.

2 participants