Announcing <https://github.com/deezer/KustomExport...
# javascript
g
Announcing KustomExport: an experimental KSP project to provide better Typescript APIs! Some features
@JsExport
doesn't provide but
@KustomExport
does: • support exporting
enum
,
interface
,
sealed class
• ability to remove the namespace • support exporting
List
(mapped into
Array
) • remove useless methods from
data class
• support
suspend
methods (with cooperative cancellation via AbortController) Do you need something else? Please open an issue to help this project! Have a nice day Kotlin developers! K
K 14
🔥 4
👍 11
👍🏽 1
❤️ 7
😮 2
a
This is amazing work right here. However @JsExport as received some love since kotlin 1.6.20-RC, supporting enum and sealed classes. I love that KustomExport goes an extra mile to removing unwanted methods, namespaces e.t.c
🙏 1
also the List to Array was very much needed. Next should be Map to Record
2
g
Thanks! I've started with 1.5.30 and I'm glad to soon remove the support for enum or sealed class. That said Kotlin enums could have a method returning a List for example, so Kotlin Js will still not export it as I want. I've opened an issue yesterday to support mixing JS Export with KustomExport so that we can still address those edge cases while using optimized Kotlin Js enum export for simple enums.
j
Next, replace suspending functions with functions that return promises so that one doesn't have to include the whole coroutines library inside the JS bundle
g
Suspending functions are already exported to Promises 🎉. That said it's still using coroutines library to make it work in the KMP part, so not sure we can save on the bundle size with only facades. (KSP adds Kotlin code, it doesn't change the way JS/TS is actually exported by KotlinJs compiler)
a
Kotlin enums could have a method returning a List for example, so Kotlin Js will still not export it as I want
Thats a quick catch. Can you link the issue to support both
@KustomExport
and
@JsExport
so that I can upvote it like there is no tomorrow?
g
j
I feel like these things should be in KotlinJS by default. Currently I'm forced to use Arrays in data models instead of Lists to get Arrays in generated TypeScript Seems like all the quality of life things that are missing from KotlinJS are all in this library 🔥
❤️ 4