perf: Remove the use of NodePath#contexts - #18106
liuxingbaoyu wants to merge 1 commit into
Conversation
|
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/61850 |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ae02ce6797
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| path._traverseFlags = 0; | ||
|
|
||
| if (context && !path.context) { |
There was a problem hiding this comment.
Refresh cached paths for the active traversal
When a cached child NodePath already has any context, this guard skips updating its state/opts for the context passed by the current path.get(...) call. Cached paths survive across traversals, so a plugin that fetched a child in an earlier pass can later get the same child under different state/options (for example after a noScope pass) and observe stale path.state or have setScope run with stale opts, leaving scope unset in a scoped traversal. Please refresh the path for the supplied context even when it already has a context.
Useful? React with 👍 / 👎.
|
commit: |
|
Does this replace #12634? :) |
|
#12634 was originally intended to fix #12631. This PR and #12634 seem to be two different approaches and shouldn't work together. Technically, I don't think this PR completely avoids the context overriding issue. Unfortunately, the PR's baseline was also affected by the outdated baseline. |
Fixes #1, Fixes #2This is a breaking change.
I hope to postpone it until Babel 9.
Fortunately, none of our plugins were affected.
Only one test that supported
babel-plugin-jest-hoist's edge behavior was impacted.This resulted in an
overall transformationand traversing time reduction of ~20%.traverse with
noScope: true: 30%-40%