-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable support for Kotlin/JS IR backend and introduce js_export
parameter
#147
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR @itegulov!
It looks like the build is failing in CI with a StackOverflowError
from the Kotlin compiler. Unfortunately we've run into this many times with the new IR backend used by Kotlin/Native (and now available on JS and JVM too). It seems that the new IR backend is still buggy and certain Kotlin constructs in pbandk's source code will cause it to either use an inordinate amount of memory during compilation, or will cause it to get into an infinite loop. Both of which manifest as out-of-memory or stack overflow errors. You could try tweaking the jvmargs in gradle.properties
to increase the memory available and see if that helps. If you can't replicate this when building on your own machine, try limiting the amount of memory available to the process to under 7GB. That's how much memory the CI job runs with.
I also see a bunch of warnings in the build log about non-exported types. Is this anything we need to worry about? E.g.:
w: /home/runner/work/pbandk/pbandk/runtime/src/commonMain/kotlin/pbandk/ExtendableMessage.kt: (10, 38): Exported declaration uses non-exportable parameter type: FieldDescriptor<M, T>
protoc-gen-kotlin/lib/src/commonMain/kotlin/pbandk/gen/CodeGenerator.kt
Outdated
Show resolved
Hide resolved
5216755
to
1dfb590
Compare
@garyp Thanks for the review.
Unfortunately, this is one of the short-comings of the |
1dfb590
to
bcdf95b
Compare
Module 'fs' is not available for browser environments which is a fatal error with IR compiler backend. Since we are using conformance tests specifically with NodeJS there is no reason to cross-build it for browsers anyway.
bcdf95b
to
ccb67e4
Compare
@garyp the PR is ready from my perspective, could you take another look please? |
A couple other things:
./gradlew :runtime:generateWellKnownTypes \
:runtime:generateTestTypes \
:protoc-gen-kotlin:protoc-gen-kotlin-lib:generateProto \
:conformance:conformance-lib:generateProto
For the first error: I'm not sure if there's a way to tell Kotlin not to export a particular declaration when using For the second error: It's these two declarations that are conflicting with each other: val pbandk.conformance.pb.TestAllTypesProto2.extensionInt32: Int?
get() = getExtension(pbandk.conformance.pb.extensionInt32)
val extensionInt32 = pbandk.FieldDescriptor(
...
) They're both defining a getter on a field named |
Renamed pbandk.Name to pbandk.JsName, annotated it with @PublicForGeneratedCode and improved browser-js example gralde configuration
@garyp Unfortauntely, there does not seem to be a way to exclude declarations form a file-wide
Actually, there is no need to give one of them a different name since the first one is an extension property that cannot be exported anyway. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks again for the improvement!
Fixes #136
I have tested
js_export
on my company's projects and it works pretty well. Obviously the resulting.d.ts
declaration has some "red" parts as@JsExport
does not support Kotlin collections, but overall it is still usable.Let me know what you think and thanks for this amazing library!