* add tests on regression 12386
* fix: update cache on _replaceWith
* fix: pathCache in replaceWithMultiple could be nullish
* Update packages/babel-traverse/src/path/replacement.js
Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
* test: add replaceWith test to traverse
Co-authored-by: Brian Ng <bng412@gmail.com>
Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
* Path#ensureBlock keeps path context
This ensures that if you're inside an ArrowFunction with an expression body (say, you're on the BooleanLiteral in `() => true`), you don't suddenly lose your path context after inserting a variable.
This is because of 82d8aded8e (diff-9e0668ad44535be897b934e7077ecea5R14). Basically, an innocent `Scope#push` caused my visitor to suddenly stop working. Now, we mutate the Path so it's still in the tree.
* Tests