Closed privatenumber closed 10 months ago
Hey @privatenumber, yes this is by design - we don't parse arbitrary expressions, so from the perspective of the lexer, ('string')
is an expression, while 'string'
is a direct static string.
In the dynamic expression cases, you always do just need to apply a custom parser, but at least there is an expression range you can apply it to.
The problem is that the expression range is incorrect, which results in invalid JS.
e.g. a parser cannot correctly parse import(("asdf")
because it's missing the closing parenthesis )
.
Okay, right, if it’s the wrong offset for a slice function then that’s a buf we should fix.
On Sat, Sep 9, 2023 at 19:04 Hiroki Osame @.***> wrote:
The problem is that the expression range is incorrect, which results in invalid JS.
e.g. a parser cannot correctly parse import(("asdf") because it's missing the closing parenthesis ).
— Reply to this email directly, view it on GitHub https://github.com/guybedford/es-module-lexer/issues/156#issuecomment-1712685926, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAESFSQRNMFG6OW7RIO4FBDXZUN3LANCNFSM6AAAAAA4A2CIP4 . You are receiving this because you commented.Message ID: @.***>
Released in 1.3.1.
Thank you @guybedford !
When the dynamic import argument is wrapped in a parenthesis, the statement range is not correctly captured:
Reproduction: https://stackblitz.com/edit/stackblitz-starters-zzxwkp?file=index.mjs