estraverse icon indicating copy to clipboard operation
estraverse copied to clipboard

traverse crashes on ES dynamic import

Open dgoldstein0 opened this issue 7 years ago • 4 comments

the es8 (7? 9? not sure exactly which number it is, but it's stage 4 now I believe) style import("foo") crashes estraverse. In particular:

  • use a parser that produces an estree spec AST and understands this syntax. I discovered this with cherow, but I suspect acorn will also work
  • estraverse.traverse(ast, {enter: function(){}, leave: function(){}}); should probably then be enough to repro if there's a dynamic import in the tree

I expect estraverse to be able to handle the type: "Import" nodes, and it instead throws. This seems to happen when it tries to visit the children of these nodes, as a this.skip() in the enter function when an import node is encountered does the trick. That said, skipping it's children shouldn't be necessary.

dgoldstein0 avatar Oct 24 '18 06:10 dgoldstein0

Try using fallback=iteration

seasonli avatar Nov 14 '18 06:11 seasonli

what is that? I don't see iteration documented at all

dgoldstein0 avatar Nov 14 '18 07:11 dgoldstein0

image

seasonli avatar Nov 14 '18 11:11 seasonli

Got it, I was not familiar with that. Seems like a simpler workaround, though still a workaround.

On Wed, Nov 14, 2018, 3:33 AM Jijun Li [email protected] wrote:

[image: image] https://user-images.githubusercontent.com/5109541/48480062-27537080-e844-11e8-8932-ef6895545ba5.png

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/estools/estraverse/issues/97#issuecomment-438632003, or mute the thread https://github.com/notifications/unsubscribe-auth/ABBndyHoxl1bmIZXtmRH71OlfHSJXHYGks5uu_-OgaJpZM4X3L8d .

dgoldstein0 avatar Nov 14 '18 20:11 dgoldstein0