-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Improve import and export parsing with babel #399
Conversation
This pull request is automatically deployed with Now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dope! Looking forward to seeing this out
In order to maintain positional metadata for AST nodes that are parsed, we need to ensure that each import/export is eaten in order as a correct subvalue. Since the remark eat function requires the string to be consumed in order, with no missing characters, the babel plugin now returns the start value which is used to sort the nodes and partition the input string. They're then combined again and returned as nodes that can be eaten in order by the tokenizer. This also comes with the benefit of no longer changing the input code which occurs with the prior babel generator.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome!! ✨ Few questions/nits
Good calls @wooorm. Addressed in latest commits. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect! 🌈
* Improve import and export parsing with babel This introduces babel for better handling import and export parsing. Anything that is an import/export block will be parsed by babel and split up ensuring that edge cases will no longer occur based on how the JS is grouped. It also makes parsing the export default nodes more robust. - #345 - #340 * Add multiline fixtures * Preserve positional information for AST nodes In order to maintain positional metadata for AST nodes that are parsed, we need to ensure that each import/export is eaten in order as a correct subvalue. Since the remark eat function requires the string to be consumed in order, with no missing characters, the babel plugin now returns the start value which is used to sort the nodes and partition the input string. They're then combined again and returned as nodes that can be eaten in order by the tokenizer. This also comes with the benefit of no longer changing the input code which occurs with the prior babel generator. * Remove unneeded babel generator dep * Simplify partition function * Make naming consistent * Add snapshot test to verify positional info
This introduces babel for better handling import and
export parsing. Anything that is an import/export block
will be parsed by babel and split up ensuring that
edge cases will no longer occur based on how the
JS is grouped. It also makes parsing the export default
nodes more robust.