-
-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
helper-define-polyfill-provider: Cannot read properties of undefined (reading 'includes') #210
Comments
|
I also encountered a very similar error, and the error stack trace appears to originate from the same location. After downgrading @babel/helper-define-polyfill-provider to version 0.5.0 using yarn's resolutions, the error disappeared. When printing
|
I suspect the issue is because Why would a node that has already been removed still be traversed by traverse? |
I assume that the ancestor node is being removed while it's descendants are still being traversed. Would you be able to create a repo that shows the issue? You config + the file it's crashing on would be a good starting point, but you can probably reduce it. |
I have a workaround in #213, but it's be good to have a reproduction to figure out if the problem has other consequences. |
Sorry, missed this. in our case, the offending code is an ObjectMethod that gets replaced by a plugin with an ObjectProperty where the value is an object literal with a function as a value. I can check the removed flags today as well. |
I can test the fix in our codebase today as well |
I haven't found a minimal implementation to reproduce this issue yet, but I tested this solution by modifying files under node_modules in my project, and the issue disappeared. In my case, I have a plugin based on babel-plugin-macros, which utilizes the path.replaceWith / path.replaceWithMultiple API to remove certain layers of nodes in the JSX tree, replacing the current node with its children. Sometimes, it also creates a jsxFragment to wrap some of the children. This error is triggered in certain specific JSX structures, but not in all JSX structures. |
Workaround published in |
I'm having a bit of trouble narrowing down a useful reproduction, but I'm seeing this error with the following stack with @babel/helper-define-polyfill-provider@0.6.1 while I did not see the same issue with 0.5.0.
I suspect the issue was introduced in packages/babel-helper-define-polyfill-provider/src/visitors/usage.ts by #201.
The
path.listKey
in this case isarguments
, thepath.parentPath.node.type
is anObjectExpression
, thepath.node.type
is also anObjectExpression
. Happy to snag any other debugging info that'd be helpful, just a bit stuck on what exactly would help debug here.The text was updated successfully, but these errors were encountered: