Skip to content
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

@babel/core parseFile #11104

Open
Gallevy opened this issue Feb 6, 2020 · 5 comments
Open

@babel/core parseFile #11104

Gallevy opened this issue Feb 6, 2020 · 5 comments

Comments

@Gallevy
Copy link

@Gallevy Gallevy commented Feb 6, 2020

Feature Request

  • I would like to work on this feature!

Is your feature request related to a problem? Please describe.
ParseFile method to parse code from a file into AST

Describe the solution you'd like
a parseFile method, similar to transformFile but just to parse into AST

Describe alternatives you've considered
using @babel/core transformFile and using the result AST

Teachability, Documentation, Adoption, Migration Strategy
Same as parse but to parse a whole file

@babel-bot

This comment has been minimized.

Copy link
Collaborator

@babel-bot babel-bot commented Feb 6, 2020

Hey @Gallevy! We really appreciate you taking the time to report an issue. The collaborators on this project attempt to help as many people as possible, but we're a limited number of volunteers, so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack community that typically always has someone willing to help. You can sign-up here for an invite."

@kaicataldo

This comment has been minimized.

Copy link
Member

@kaicataldo kaicataldo commented Feb 6, 2020

Mind adding some more information about why the existing parseSync and parseAsync methods don't cover your use case?

@kaicataldo kaicataldo added pkg: core and removed i: needs triage labels Feb 6, 2020
@Gallevy

This comment has been minimized.

Copy link
Author

@Gallevy Gallevy commented Feb 6, 2020

I want to read an entire directory. Methods like transformFile do help you read entire files. But with parse you don't have parseFile which leaves me with two options. Either read the file myself and use the parse method with the read file or use transformFile and only care about the AST.

Again, this is not a major issue but does offer easier and more diverse api

@kaicataldo

This comment has been minimized.

Copy link
Member

@kaicataldo kaicataldo commented Feb 6, 2020

I want to read an entire directory.

Just to be clear, are you expecting the parseFile method to do this? That seems out of scope to me.

I'd like to hear from other team members, but I personally don't think this proposal meets the bar for inclusion in core, since you would need to be running this programmatically anyway and iterating through a directory of files, reading their contents, and calling the parse method on these contents isn't a whole lot of overhead, while maintaining yet another public API is.

@Gallevy

This comment has been minimized.

Copy link
Author

@Gallevy Gallevy commented Feb 6, 2020

I want to read an entire directory.

Just to be clear, are you expecting the parseFile method to do this? That seems out of scope to me.

No, just read a single file, similar to how transformFile works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.