Closed mafintosh closed 2 years ago
Thanks @mafintosh yes nested dynamic imports are not supported! We only analyze based on cur_dynamic_import
in https://github.com/guybedford/es-module-lexer/blob/main/src/lexer.c#L107, when this should really be a stack to support arbitrary nesting.
Did you have real code that this was affecting?
Only for a test case that our transforms work for any js code, but I was able to work around it by only knowing the where the import statement was, which does work atm, so not a big issue.
Only using the import start index massively simplified my transforms so it was a good challenge 😄
Okay, I'm going to leave this open to track a real-world need for it since it's a bit of work for an edge case, but let me know if it is affecting you in any material way too!
For sure, as long as the start index is correct, I'd much prefer MOAR PERF vs fixing this.
Btw the big negative number for the end index is actually uninitialized memory... the great thing about Wasm is not having to worry about this stuff :P
This feature is now supported as of https://github.com/guybedford/es-module-lexer/pull/102 using a dynamic import stack for tracking.
Wow, amazing, thanks!
Found this edge case:
Basically if you parse that, all the start offsets are correct but the end ones for the first import is a big negative number.