-
-
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
Strip flow types #256
Comments
Closing as flow decided to focus on internal usages. |
That doesn't mean external projects can't use it. There are a lot of projects that still use Flow. |
@FezVrasta If you send a PR, I'll happily accept it and maintain it. |
@FezVrasta Maybe it's unrelated question, can you show me some projects using flow? |
I maintain Popper, which is used by approximately a couple million websites around the world, and it's entirely wrote with Flow. |
The best way to implement it would be to use This is an example of how to use it programmatically with JavaScript: https://github.com/leebyron/rollup-plugin-flow/blob/master/index.js I'd be happy to send a PR, I just need to understand if integrating flow-remove-types would be an acceptable approach, and some guidance on where to start. |
Hmm... I don't think using js module is acceptable. |
Thanks that'd be awesome! The whole Flow community will be grateful for this 🤗 |
I found that I have a task with higher priority, so I'm postponing this. |
I looked at the source code of |
Yes it depends on the JS-compiled OCaml compiler. Considering how fast the OCaml compiler it is I wonder if swc could directly interface with it? TBH a simple plugin-like approach where each file is feeded through the Flow parser would be all it's needed to address this. |
Is there a way to see the size of the compiled flow stripper? |
It's between 30-40 MB depending by the target platform: From my understanding, the Babel plugin to strip Flow types doesn't depend on the Flow compiler though, so maybe you could use their source code as reference for a Rust implementation? |
Yes. But it means lots of work. It's really enormous amount of work. |
What about the approach I described above?
|
I'm fine with it. |
Ok that sounds great, this way the Flow support will be implementable at plugin level and the core is not tied to it. Is there anything else I can do to help to move this effort forward? Do you have an RFC or other kind of documentation where the API is being designed? |
Can you join discord server at https://discord.gg/GnHbXTdZz6 ? I'm not sure about the RFC, but I think people in discord server may provide some ideas about the api. |
For anyone interested, I started a conversation here https://discord.com/channels/889779439272075314/889780921002246154/894551464410763314 |
Facebook's Hermes project also has parsers for both TypeScript and Flow, written in C++, if that's any help. |
That's great! It also seems to expose a Rust API? |
react-native also uses flow which need to be stripped away in production builds |
Shooting from the hip: there's only a few differences between the TS and Flow type syntaxes, so perhaps it's possible to reuse a goodly portion of the TS transformer and take it from there? |
I'm going to suggest to close this. /cc @kdy1 before actually closing it. Given the scope of the SWC's feature and codebase, I don't think we have enough bandwidth to support this continuously. Probably the best way forward is someone making a userland parser based on the existing implementation of SWC. |
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Babel has this module:
@babel/plugin-transform-flow-strip-types
, which simply ignores flow types. There are quite a few modules out there that use babel to compile, yet have flow typing.Please add support for stripping types, no need for full Flow support (issue #174), just ignore/strip them.
The text was updated successfully, but these errors were encountered: