New to kotlin js here. Trying to get a usable set ...
# javascript
a
New to kotlin js here. Trying to get a usable set of externals for a node library web-request. What strategies are people using for creating externals? Using
generateExternals = true
from gradle doesn't give any opportunity to tweak the generated files, yet they all seem to need tweaking?
The specific problem I have with this lib is that Url and Stream from nodejs are not available (Unresolve reference in compileKotlinJs).
I could hand-craft these, or pull them in from kotlinx-nodejs, but not sure how to tell dukat where to find these?
b
run
./gradlew jsGenerateExternals
(without that flag). This will generate externals for you on root. After that review/modify them and add to your sources
a
Thanks for your response. 🙂 So you're basically advocating that I don't use the built in
generateExternals
option in the gradle dependency declaration and instead I just use dukat manually to get a head start on building the declarations myself?
b
@adk yes exactly he means that. Dukat is not yet 100% ready to do everything right. Many changes “still” must be done by the devs
👆 1
a
Ok, thanks. I was hoping there might be a way to just tell it how to find the nodejs classes/modules that it is missing, but I'm happy to bow to the wisdom of those who have been before me. 🙂
v
I actually use the generated files with some tweaks, you can have a look at https://github.com/Vampire/setup-wsl
a
Wow - nice gradle foo! Thanks for the pointer 🙂
The actual problem I was facing was that dukat appears not to support typescript import syntax like
import { Url } from url
. The fix to the generated source was straightforward. It is good to have confirmation that I wasn't missing some magic "make it all work perfectly" feature! 🙂
v
Nah, Dukat still has many quirks, but provides a nice base.