Open remram44 opened 5 years ago
The JavaScript lexer in Babel is far from perfect, unfortunately... If you feel like trying to hack at the lexer to fix this, by all means please do!
It might be a good idea for a future version to use e.g. https://github.com/Kronuz/esprima-python when it's available (i.e. an optional dependency) for more robust parsing.
Thanks, I might take a look. I am low on time unfortunately right now.
For reference, lexer is jslexer.py
Seems that />
gets recognized as a JSX tag.
I don't see how to fix this. The tokenizer can't possibly tell if />
is the start of a regexp or the end of a JSX tag, they are the same tokens. The Javascript grammar is too ambiguous for this to be decided at the tokenizer level.
A parser would be able to tell if it's currently in a JSX tag or not and resolve the ambiguity, but there is no such parsing being done in Babel. Simply keeping track of JSX open/close tokens wouldn't be enough because regexps can appear inside JSX tags (<hr class={ /\w+/.exec(var)[0] }/>
).
I think I'll have to leave that alone, sorry!
After a regular expression like
/>/
, Babel ignores all messages until the next one.Mapping:
Source file:
Result POT: