Helping with Fable 2 development
See original GitHub issueNot sure if the dev2.0
branch is already in a state where I can start calling for help, but I’ll do it anyway 😉 I’m listing below the main changes that are happening in that branch, how can you quickly test it out and which tasks are pending for the first alpha release. If you’re interested in helping with any of them, please comment below so I can give more details to work together 💪
Non-comprehensive list of main changes
- Fable AST now includes some of the most common constructs in F# (list, option…) so it’s easier to change their representation in JS if necessary. Also, the AST now keeps type information from the F# compiler.
- Records and unions won’t be compiled as JS classes but as plain objects and arrays respectively.
- All type methods are compiled now as JS module functions for better compatibility with tree shaking (hopefully it should also help JS engines optimize the code). The only exception is override methods (ToString, Equals), which are attached to the prototype. Also, nested module functions are compiled as functions of the file root module with mangled names.
- When casting an instance to an interface, it will be wrapped with an object containing the interface functions, this prevents name conflicts among interfaces (and it’s also necessary because methods are not attached to the prototype anymore).
- Some modules in fable-core (like List or Array) are now written in F#
- Optimizations applied to the Fable AST are now isolated passes happening in
FableTransforms
. This should make the code more maintainable than Fable 1, where optimizations are usually applied in multiple places (specially the uncurrying optimization, which hopefully will work much better in Fable 2). Some optimizations, however, still have to be done in the last Fable2Babel pass: tail-calls and decision trees (pattern matching).
Give it a quick try
- Clone the repository if you haven’t already
git checkout dev2.0
cd src/tools
bash quicktest.sh --build-core
This will compile and execute the QuickTest.fs
file in the same folder. Feel free to use it as a playground to test Fable 2 features (but please don’t include it in your PRs). The second time, if src/js/fable-core
files haven’t changed you can just run bash quicktest.sh
(if src/dotnet/Fable.Compiler
files haven’t changed you can also run bash quicktest.sh --no-build
but with 2.1.300-preview1 building a project with no changes should be quite fast anyways).
On Windows you should be able to run the script using Git bash.
Pending tasks
-
There is a number of
TODO!!!
comments spread through the code, I should probably handle those myself. -
As plugins won’t be included in the first alpha release, tests use now Expecto API, which is much easier to share with JS test runners. I’ve converted already some files (ArithmeticTests, ArrayTests, ListTests) but most of them are still waiting for some love. I was using Regex to change the signature of the methods to
testCase
but probably it’s a good idea to write a script for it. One of the main challenges is that, given tests are values in a list now, extra functions that appear in the middle of the file must be moved to the top, which may shadow other values in some cases. -
Set and Map modules in fable-core have to be ported to F#. I partially did it for Set (Map can also be taken from FunScript repo where I originally
stole ittook inspiration from). We need to be sure they are correctly compiled to JS, the public function names are exposed correctly, check if we need to port methods from the previous .ts files (saved insrc/tools/old
) and if the tests are working correctly. -
Because the AST has changed so much, most of the Replacements module needs to be rewritten. I already did around 1000 lines and there’s another thousand to go. This is a bit of a tedious task, but if someone is crazy enough to take on it, please let me know. Maybe the fastest way is to have a screen sharing session to show you what needs to be done and then split the remaining code so we can finish faster.
Things that won’t be included in the first alpha release: bigint, reflection, plugins.
I hope that’s enough info for now, thanks a lot for your help in advance!
Issue Analytics
- State:
- Created 6 years ago
- Reactions:7
- Comments:37 (32 by maintainers)
Just for info, if someone is porting the test files no need to port
SetTests.fs
andMapTests.fs
I will do it to test the module intergration.Also, if you use VSCode, you can use multiple selection to do all the work at once inside a file. Writing a scripting seems a bit over engeneering here 😃.
Thanks for your quick and detailed reply, I’ll try it tomorrow.
Great, I think I can spend two hours on weekdays and full day on weekends, mostly.