Module extraction is the way it is done today.
1) Well-known top-level function invoked by the server but tree-shaken by the bundler for the client.
2) Some form of manual type safety.
(no special code transformation needed)
Function Extraction requires code transformation, which can extract inlined functions into top-level exports (module extraction)
- A lot more natural DX
- Automatic type safety
- Any number of functions (not just well-known exports)
Closure Extraction (similar to function extraction, but) can also capture closure variables.
- Even better DX, as closures are the bread-and-butter of modern frameworks.
- Can pass JSON data, Date, Promise, cyclic graphs, closures