-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Flow support #79
Comments
I'm not currently considering Flow support. I've never used Flow myself and I had the (perhaps incorrect) impression that the web development community was gradually moving away from Flow to TypeScript. My goal for esbuild is to build a bundler that solves for a sweet spot of common use cases, not to build a bundler that works for any codebase. That said, I could consider it. To get an idea of the scope of work that this would require (since I'm completely unfamiliar with Flow):
|
|
As @rtsao says, Flow does not add any new language constructs. All Flow syntax can simply be stripped to get working JS code. The Flow project contains multiple packages, one of which is the Please look at this material to see if it can help. The package itself (published on NPM as |
Thanks for the pointers! That's very helpful. I'm currently focused on building some other features first (code splitting and tree shaking) but I would like to do this at some point. |
I'd like to see this as well. The flow syntax is extremely similar to TypeScript, really just a handful of differences. So hopefully this wouldn't be very hard to add. |
I've scraped relevant test cases from from https://github.com/facebook/flow/tree/master/src/parser/test/flow/types and https://github.com/babel/babel/tree/main/packages/babel-parser/test/fixtures/flow and generated esbuild unit test cases. In doing this, I learned that Flow actually supports enum syntax, which isn't really documented anywhere. Support for parsing Flow enums was also added to Babel, but interestingly it appears Babel does not transform them to anything when using Unfortunately, no special file extension is used for Flow syntax, so there's no way to know if a esbuild/internal/bundler/bundler.go Lines 607 to 608 in 5f6aac0
I can think of two ways of handling this:
I think Flow pragma comments aren't strictly required, but I imagine the first option could introduce some overhead. I need to clean up the test cases a bit more, but at some point I'd be interested in working on Flow support. My initial thought would be something like this:
|
Some quick thoughts:
|
Makes sense, thanks for the heads up. Right now, I'm mainly tinkering around to better understand the differences between TS and Flow syntax and see how difficult it would be to add Flow support. At the very least, I'm merely hoping to produce a suite of test cases that will prove useful no matter what kind of refactoring happens. Regarding enums, they have to be explicitly enabled by adding |
The refactoring I have in mind is mainly renaming files and packages, so it should be straightforward to carry any modifications to the JavaScript parser forward. It’ll just potentially be a lot of conflicts. |
I'm currently trying to use esbuild for "react-native-web", but many of the libraries I use have flow in the code. So, just adding the use-case of react-native libraries to this thread. No to rush in any way. Thanks. |
You can try esbuild-plugin-flow. |
The Flow team just announced that they are going to diverge from the JavaScript language and no longer be just JavaScript with types: https://medium.com/flow-type/clarity-on-flows-direction-and-open-source-engagement-e721a4eb4d8b. Given that, I don’t think it makes sense to include this in esbuild itself. You can of course still do this with a plugin. |
Hello, are you also considering Flow support or will this only support TypeScript?
The text was updated successfully, but these errors were encountered: