Robert Jaros
03/23/2020, 1:58 PMturansky
03/23/2020, 2:07 PMaraqnid
03/23/2020, 8:57 PMJared Woolston
03/23/2020, 9:24 PMnvk.kt
which contains:
@file:JsModule("nvk")
@file:JsNonModule
package nvk
external class VulkanWindow
And in the JS source set, I am trying to define an actual
for an expected
as seen here:
actual class VkWindow {
val window: VulkanWindow
actual constructor(width: Int, height: Int, title: String) {
window = VulkanWindow::class.js.createInstance()
window.asDynamic()["width"] = width
window.asDynamic()["height"] = height
window.asDynamic()["title"] = title
}
}
Where createInstance()
is defined following the discussion at https://discuss.kotlinlang.org/t/is-there-a-way-to-use-the-new-operator-with-arguments-on-a-dynamic-variable-in-kotlin-javascript/6126/4 as:
fun <T : Any> JsClass<T>.createInstance(vararg args: dynamic): T {
@Suppress("UNUSED_VARIABLE")
val ctor = this
@Suppress("UNUSED_VARIABLE")
val argsArray = (listOf(null) + args).toTypedArray()
//language=JavaScript 1.6
return js("new (Function.prototype.bind.apply(ctor, argsArray))").unsafeCast<T>()
}
This all compiles fine but when I try and run it via jsNodeRun
I get the following error:
return js("new (Function.prototype.bind.apply(ctor, argsArray))").unsafeCast<T>()
^
Error: Argument 1 must be of type 'Object'To be honest, I don't have a particular preference on how I instantiate objects from this module, though I would like to be able to eventually do it with arguments. Any guidance would be greatly appreciated.
Ian Stewart
03/24/2020, 7:25 PMdazza5000
03/24/2020, 9:53 PMJurriaan Mous
03/25/2020, 5:02 PMCrypto.randomBytes(16)
and Buffer.from("AQ", "base64")
in actual implementations of multiplatform code I intended to replace with browser compatible code. Somehow if I run my tests in the browser, the node functions all work and tests succeed in all browsers. (Firefox/Safari/Chrome) How can this be explained? Can I expect these functions to run in a proper application? Or am I overlooking something?Marian Schubert
03/25/2020, 5:13 PM1.4-M1
but ./gradlew run
no longer exists. What should I use instead?Rob Murdock
03/25/2020, 5:21 PMExit code: 127
Command: node scripts/build-browser-scripts
Arguments:
Directory: /home/circleci/project/build/js/node_modules/wd
Output:
/bin/sh: 1: node: not found
...
* What went wrong:
Execution failed for task ':kotlinNpmInstall'.
> Process 'Resolving NPM dependencies using yarn' returns 127
Fun right? It doesn’t always happen on the same postinstall script. I’m pretty sure node is installed on the docker image (though it shouldn’t be using that version - it should use the version the kotlin plugin downloads). It doesn’t seem to be affected by running kotlinNodeJsSetup in a previous gradle run.
Any clues would be useful… this is blocking me from fully utilizing the power of the plugin. 😰Stefan Beyer
03/26/2020, 10:34 AMbodies.knb
) preventing any subsequent builds from touching the files. When I search for the process that has the file handles and kill it manually, I can build the project one more time. But after that, there is a new process that locks the files again.
I made a minimal example project to demonstrate this: https://github.com/LostMekka/kotlin-js-1.4-M1-error-demonstration.
Is anyone else having this issue?Sebastian Aigner
03/27/2020, 2:09 PMktor-client-core
and ktor-client-js
, version 1.3.2-1.4-M1-2
adds IR support.
For kotlin-react
and kotlin-react-dom
, version 16.13.0-pre.93-kotlin-1.4-M1
adds IR support.
Please note that especially the react wrappers heavily relied on specific characteristics of the default backend, which might make your current code incompatible with the new IR backend. The issues we’ve already identified are:
- Interfaces implementing RProps
or RState
should be marked as external interface
. Otherwise, you will get a Uncaught ClassCastException
.
If you’re implementing these interfaces via a class
, you can mark it as @JsExport
– however, we suggest evaluating if you could use an external interface
instead.
- To make your components work in production
mode, please mark your RComponent
implementations with @JSExport
. Otherwise, you might run into issues such as TypeError: l.render is not a function (react-dom.production.min.js:182)
If you’d like to see how we migrated the kotlin-full-stack-application-demo to IR, check the diff of our 1.4
branch: https://github.com/Kotlin/kotlin-full-stack-application-demo/compare/1.4
Of course, we know that this is far from ideal. The team is having a close look at these cases, and any other issues you might report, and will try their best to improve and polish the developer experience over time. Solutions currently being evaluated include compiler checks, IDE inspections, DCE adjustments, and more.
We kindly ask for your support to help us spot any more issues with the IR compiler backend – so go and try it out 👌Milan Hruban
03/28/2020, 9:34 AMspierce7
03/28/2020, 7:50 PMuli
03/28/2020, 9:10 PM<https://www.npmjs.com/package/@abandonware/noble>
with dukat:
implementation(npm("@abandonware/noble", "1.9.2-7"))
The problem is, that dukat only generates top level functions which can not be resolved at runtime:
@file:Suppress("INTERFACE_WITH_SUPERCLASS", "OVERRIDING_FINAL_MEMBER", "RETURN_TYPE_MISMATCH_ON_OVERRIDE", "CONFLICTING_OVERLOADS", "EXTERNAL_DELEGATION")
import ...
external fun startScanning(callback: (error: Error) -> Unit = definedExternally)
If a add my own type definitions like that things work:
@file:Suppress("INTERFACE_WITH_SUPERCLASS", "OVERRIDING_FINAL_MEMBER", "RETURN_TYPE_MISMATCH_ON_OVERRIDE", "CONFLICTING_OVERLOADS", "EXTERNAL_DELEGATION")
val noble: Noble = js("require('@abandonware/noble')")
external class Noble : events.EventEmitter {
fun startScanning(callback: (error: Error) -> Unit = definedExternally)
Am I donig something wrong? Are the type script definitons of the package broken? Or is it just dukat?
Btw. the project is compiled with
kotlin {
target {
useCommonJs()
nodejs()
Robert Jaros
03/30/2020, 11:35 AMC:\data\master\experimenting-with-kotlin-js>gradlew.bat run -t
> Task :kotlinNpmInstall FAILED
error Couldn't find package "is-sorted@*" required by "experimenting-with-kotlin-js@1.0.0-SNAPSHOT" on the "npm" registry.
Error: Couldn't find package "webpack@4.41.2" required by "experimenting-with-kotlin-js@1.0.0-SNAPSHOT" on the "npm" registry.
at MessageError.ExtendableBuiltin (C:\Users\joerg.rade\.gradle\yarn\yarn-v1.21.1\lib\cli.js:721:66)
at new MessageError (C:\Users\joerg.rade\.gradle\yarn\yarn-v1.21.1\lib\cli.js:750:123)
at PackageRequest.<anonymous> (C:\Users\joerg.rade\.gradle\yarn\yarn-v1.21.1\lib\cli.js:36539:17)
at Generator.throw (<anonymous>)
at step (C:\Users\joerg.rade\.gradle\yarn\yarn-v1.21.1\lib\cli.js:310:30)
at C:\Users\joerg.rade\.gradle\yarn\yarn-v1.21.1\lib\cli.js:323:13
at processTicksAndRejections (internal/process/task_queues.js:93:5)
Error: Couldn't find package "webpack-dev-server@3.9.0" required by "experimenting-with-kotlin-js@1.0.0-SNAPSHOT" on the "npm" registry.
at MessageError.ExtendableBuiltin (C:\Users\joerg.rade\.gradle\yarn\yarn-v1.21.1\lib\cli.js:721:66)
at new MessageError (C:\Users\joerg.rade\.gradle\yarn\yarn-v1.21.1\lib\cli.js:750:123)
at PackageRequest.<anonymous> (C:\Users\joerg.rade\.gradle\yarn\yarn-v1.21.1\lib\cli.js:36539:17)
at Generator.throw (<anonymous>)
at step (C:\Users\joerg.rade\.gradle\yarn\yarn-v1.21.1\lib\cli.js:310:30)
at C:\Users\joerg.rade\.gradle\yarn\yarn-v1.21.1\lib\cli.js:323:13
at processTicksAndRejections (internal/process/task_queues.js:93:5)
Error: Couldn't find package "webpack-cli@3.3.10" required by "experimenting-with-kotlin-js@1.0.0-SNAPSHOT" on the "npm" registry.
at MessageError.ExtendableBuiltin (C:\Users\joerg.rade\.gradle\yarn\yarn-v1.21.1\lib\cli.js:721:66)
at new MessageError (C:\Users\joerg.rade\.gradle\yarn\yarn-v1.21.1\lib\cli.js:750:123)
at PackageRequest.<anonymous> (C:\Users\joerg.rade\.gradle\yarn\yarn-v1.21.1\lib\cli.js:36539:17)
at Generator.throw (<anonymous>)
at step (C:\Users\joerg.rade\.gradle\yarn\yarn-v1.21.1\lib\cli.js:310:30)
at C:\Users\joerg.rade\.gradle\yarn\yarn-v1.21.1\lib\cli.js:323:13
at processTicksAndRejections (internal/process/task_queues.js:93:5)
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':kotlinNpmInstall'.
> Process 'Resolving NPM dependencies using yarn' returns 1
yarn install v1.21.1
info No lockfile found.
[1/4] Resolving packages...
info Visit <https://yarnpkg.com/en/docs/cli/install> for documentation about this command.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at <https://help.gradle.org>
BUILD FAILED in 11s
2 actionable tasks: 2 executed
Ian Stewart
03/30/2020, 3:07 PMkartoffelsup
03/30/2020, 7:58 PMNicholas Bilyk
03/30/2020, 8:30 PMVersion: webpack 4.41.2
Time: 9419ms
Built at: 03/30/2020 3:24:01 PM
2 assets
Entrypoint main = app-production.js app-production.js.map
[0] ./kotlin-dce/kotlin.js 424 KiB {0} [built]
[1] ./kotlin-dce/acornui-acornui-utils.js 695 KiB {0} [built]
[2] ./kotlin-dce/acornui-acornui-core.js 2.35 MiB {0} [built]
[3] ./kotlin-dce/kotlinx-coroutines-core.js 297 KiB {0} [built]
[4] ./kotlin-dce/asdf-app-common.js 352 KiB {0} [built]
[5] ./kotlin-dce/kotlinx-serialization-kotlinx-serialization-runtime.js 342 KiB {0} [built]
[7] (webpack)/buildin/global.js 472 bytes {0} [built]
[9] multi ./kotlin-dce/asdf-app.js 28 bytes {0} [built]
[10] ./kotlin-dce/asdf-app.js 136 KiB {0} [built]
[18] ./kotlin-dce/asdf-ddc.js 115 KiB {0} [built]
[19] ./kotlin-dce/asdf-demo-module.js 75.9 KiB {0} [built]
[20] ./kotlin-dce/asdf-theme-builder.js 131 KiB {0} [built]
[21] ./kotlin-dce/asdf-rich-text-editor.js 6.4 KiB {0} [built]
[22] ./kotlin-dce/asdf-timesheet.js 118 KiB {0} [built]
[23] ./kotlin-dce/acornui-acornui-webgl-backend.js 174 KiB {0} [built]
+ 9 hidden modules
ERROR in app-production.js from Terser
undefined
Any idea how I can troubleshoot this? It was working in the 1.3.70 EAPRob Murdock
03/30/2020, 8:31 PMnwillc
03/31/2020, 2:39 AMgradle run
works as expected. Is there a way to run it with npm from the command line?Robert Jaros
03/31/2020, 8:43 AMkotlin-frontend-plugin
)?pabl0rg
03/31/2020, 3:29 PMaerb
03/31/2020, 5:56 PMfkrauthan
04/01/2020, 12:39 AMkotlin2js
plugin I was able to set the output Javascript filename with the following snippet in my build.gradle.kts
: setProperty("archivesBaseName", "main")
but in the new js plugin this just renames the single file in distributions
but not the output in the DCE output directory. There the main source code file is still called ${rootProject.name}-${project.name}.js
is there any way to have the file that is placed in the DCE output folder to be called main.js
instead?diesieben07
04/01/2020, 8:53 AM.d.ts
generation, ran into issues / unsupported things very fast (can't even export enums 😕). Off to youtrack I go...spand
04/01/2020, 1:10 PMkotlin2js
in gradle. I tried setting kotlin.daemon.jvm.options=-Xmx8g
in gradle.properties but even then I still get it (its a bit non deterministic). Am I setting the option correctly ?Gunslingor
04/01/2020, 5:55 PMgalex
04/03/2020, 8:56 AM@JsExport
has an issue with a data class that is @Serializable
:
@CommonJsExport
@Serializable
data class EventDetails(var answer_id: Int? = null)
At compilation, I get the following error:
e: java.lang.AssertionError: Properties without fields are not supported my.package.EventDetails.Companion_instance
So the generated serializer()
of kotlinx-serialization
blocks @JsExport
galex
04/03/2020, 9:00 AMd.ts
file is that it contains definitions for classes only annotated with @JsExport
and not all the classes that are referenced inside that class.Andrew
04/03/2020, 8:16 PMAndrew
04/03/2020, 8:16 PMpatrickdelconte
04/03/2020, 8:20 PMgalex
04/04/2020, 9:34 AMAndrew
04/04/2020, 11:31 PM