After I got my `EPIPE` problem from above solved, ...
# javascript
v
After I got my
EPIPE
problem from above solved, I'm a step further, but highly confused. Maybe someone can shed some light here. • If I only have
implementation(npm("@actions/core", "1.2.4"))
as npm dependency, automatic Dukat runs fine now, producing a
core.module_@actions_core.kt
file with the external definitions, but all exported methods are in the default package, not in an npm-package specific package, is that expected or can this be changed? I imagine this could easily cause conflicts if you add more dependencies. • Also, with only
@actions/core
as dependency, it then compiled fine, but doing
./gradlew run
complains with
ReferenceError: setFailed is not defined
• Now it gets even uglier, I added the other dependencies I have (or at least had in the TS variant, some are probably superfluous now):
Copy code
implementation(npm("@actions/cache", "1.0.1"))
implementation(npm("@actions/core", "1.2.4"))
implementation(npm("@actions/exec", "1.0.4"))
implementation(npm("@actions/http-client", "1.0.8"))
implementation(npm("@actions/io", "1.0.2"))
implementation(npm("@actions/tool-cache", "1.6.0"))
implementation(npm("semver", "7.3.2"))
implementation(npm("null-writable", "1.0.5"))
implementation(npm("node-filter-async", "2.0.0"))
and now while Dukat still duly does its work (and produces 316! Kotlin files o_O), the compiler is super unhappy, throwing 802 errors at me.
f
Hi Björn, you're working on a GitHub Action that makes use of Kotlin? I've had a twitter converstation with @Sebastian Aigner on that subject as I was a bit disappointed by the state of kotlin/js. Is your code public?
v
It will be, yes. But currently it is completely in TypeScript. I now wanted to rewrite in Kotlin/JS but struggle with what I wrote here. Any ideas? 🙂
f
I have the same struggles, but probably way less expirience with this thing.
My code is here, but it is super crappy https://github.com/SAP/project-piper-action/tree/kotlin-poc
I'm trying to convert a quite simple JS action to Kotlin
More a POC then any "real" programming, I want to find out how well it works, so far I'm disappointed.
Are you aware of https://github.com/burrunan/gradle-cache-action? That seems to be a good starting point.
v
Less experience than me with Kotlin/JS is hardly possible. 😄
How should a Gradle Cache Action help? o_O
Oh, or is this made with Kotlin/JS?
f
Ok xD I've not written Kotlin code in years, and I have a jvm background and am really not wenn versed in js
yes, it is implemented in Kotlin
might serve as a template in some cases?
v
Ah, then I'll have a look there, thx
👍 1
🧌 1
But I still wonder that a simple
gradlew run
does not work as expected
Besides the compilation problems which are probably more Dukat not working well
f
Yes, so it seems like you need to hand-write some of these definitions, which is not what I expected
v
That is what Dukat should be for and which also is integrated into the Kotlin/JS Gradle plugin
For
@actions/core
it works fine it seems, for some others not so fine
f
Agreed, that's about the same point where I am.
t
Oh, or is this made with Kotlin/JS?
Yes, and it was in first comment, which was reported as “spam” by @Vampire
v
I'm sorry @turansky, but you just posted a seemingly unrelated link to both of my questions without any further comment and didn't answer when I asked how theses relate to my question, what should I have assumed? Besides that, this protect might show how to implement an action with Kotlin, it might still not answer my actual question though, which is far away from an action, but just a simple npm dependency usage in a one-liner Kotlin project that doesn't work as expected.
t
Common problem - no
@JsModule
annotation if package name is started from
@
(dukat bug - issue exists)
For example here required annotation
@JsModule("@actions/core")
Fast decision: 1. Generate declarations using
dukat
2. Add
@JsModule
annotation manually to
@actions
declarations
v
Ah, great, thanks, will try that later.
Hm, that gradle-cache-action actually confuses me a bit instead of clarifying things. It uses target "browser", while it obviously targets "nodejs" this somehow feels wrong. But I guess this is done to be able to package all code and dependencies in one file? I think I remember having read that you cannot package into one file with "nodejs" target, but only with "browser" target. Or do I remember wrong and there is a way?
At least with the
@file:JsModule("@actions/core")
injected the simple example works now from
gradlew run
, the packaging would have been the next issue Besides that adding the other dependencies will probably still break compilation.
t
nodejs
=
browser
- bundler :( If you need single js file in dist you need: 1. Use
browser
target and configure 2. Configure right
this
v
Really? I thought I've read differently. Anyway, I solved it now already with keeping
nodejs
target by having a subproject that calls
@zeit/ncc
from the node.js code and thus does the packaging, like it does in the TypeScript template by GitHub. I think this might be the cleaner solution. 🙂
(yes, I know that
@zeit/ncc
uses webpack internally too)
The most important that helped me was the hint about the missing
@JsModule
, so thanks again @turansky. My simple
import setFailed; fun main() = setFailed("boo hoo")
action is now working as intended, including
ncc
packaging. 🙂 I just fear that when I add more of the libraries I needed before, I will hit the compile errors again. 😞
t
Welcome on board! Most errors from
legacy
are known and registered. Workarounds are known too. This chat can help in most cases :)
v
Well, as said in the original message of this thread, I had 802 errors, hopefully I'm not going to need 802 work-arounds. 😄
t
Less :)
104 Views