fix: Regression of new traverse with transform-modules-amd#17001
fix: Regression of new traverse with transform-modules-amd#17001liuxingbaoyu wants to merge 6 commits into
traverse with transform-modules-amd#17001Conversation
|
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/58416 |
Yes, we should, because it seems that the act of arbitrarily moving nodes to children will cause this problem. |
|
How would you feel about reverting #16923, and re-landing it (together with this PR) for babel 8? |
| Identifier(path) { | ||
| if (!bool) { | ||
| bool = true; | ||
| path.parentPath.parentPath.pushContainer("body", t.functionDeclaration(t.identifier("fn"), [t.identifier("x")], t.blockStatement([]))); |
There was a problem hiding this comment.
Can you add some assertions to this test so that it will fail without the changes in the amd transform? Currently this test is already passing given only the babel-traverse changes.
de713e7 to
d7685a5
Compare
I'm slightly inclined to try this before reverting, because I want to accumulate significant performance changes before v7.27.0. :) |
|
Or we revert it and only count the performance changes for Babel 8, since #16965 seems a bit riskier than this.🤦♂️ |
|
The reason I prefer reverting is that it's very common for people to be on an older version of some package, and in this case the fix in As an alternative, I would prefer a fix that only involves |
Yes, I submitted the fix for only But now there are two issues that I need to test whether they have been fixed by the two PRs. So revert may also be a good choice. |
|
I investigated the bug with babel-minify in istio/istio.io#16053 and luckily it was fixed by this patch as well. |
#16923 caused the regression, but the source of the problem was not there.
The source of the problem was that
transform-modules-amdcorrupted thecontainerof the paths in the traversal queue.babel/packages/babel-plugin-transform-modules-amd/src/index.ts
Lines 32 to 45 in 844901e
Program.body.babel/packages/babel-traverse/src/context.ts
Line 128 in 844901e
Program.bodyviapushContainerto have wrongcontainerandkeyin subsequent traversals.Then the crash happens when we use the wrong
container.Maybe we also add a temporary fix to
@babel/traversein Babel 7? I'm not sure how many people will accidentally use the newtraversewith the oldtransform-modules-amd.