Marc Knaup
11/24/2020, 6:20 PM@kotlin.internal.InlineOnly
do in Kotlin/JS? Will it prevent JS code from being generated?jw
11/24/2020, 9:51 PMkotlin.targets.all { target ->
target.compilations.all { compilation ->
compilation.compileKotlinTask.dependsOn(generate.get())
}
}
to add a dependency on a source-generating task. My project is configured with both legacy and IR for JS, but when I print out the targets that this applies to the IR ones are missing:
compilation 'main' (target jsLegacy (js))
compilation 'test' (target jsLegacy (js))
compilation 'main' (target jvm (jvm))
compilation 'test' (target jvm (jvm))
compilation 'main' (target metadata (common))
IR compilation seems to be occurring first, which results in an empty artifact that eventually fails downstream.
Is it expected that the IR compilation tasks would not show up here?Marc Knaup
11/24/2020, 11:30 PMx.toString()
. Use "$x"
. The former cannot be optimized by Terser.
• Avoid Number
. Cannot be optimized by Terser.
• Avoid String.isEmpty()
and String.isNotEmpty()
. Unnecessarily imports CharSequence
code. Use == ""
and != ""
.
• Avoid StringBuilder
. Imports heaps of code. I’ve made a cheap alternative: https://gist.github.com/fluidsonic/473758c30dd084042905e77c5ebd0374
• Avoid Long
if possible. Uses a custom JS class fo Kotlin and cannot be optimized by Terser.
• Avoid `print`/`println`. Imports heaps of code. Use console.log
. But even the latter isn’t efficiently implemented.
• Prefer unsafeCast<Foo>()
over as Foo
when you’re certain of the type. The latter adds overhead and imports more code from stdlib.
• Use external
when possible to reduce amount of classes & interfaces.jw
11/24/2020, 11:33 PMandylamax
11/25/2020, 2:30 AMhungnk212
11/25/2020, 7:27 AMandylamax
11/25/2020, 8:28 AMbrowserDevelopmentRun
successfully runs while browserProductionRun
fails. Is this a bug?Robert Jaros
11/25/2020, 1:28 PMkotlin.reflect.KSuspendFunction2
type with IR backend, I've got a compiler error:
> Task :compileDevelopmentExecutableKotlinFrontend FAILED
e: java.lang.IllegalStateException: Can't find name for declaration CLASS FUNCTION_INTERFACE_CLASS INTERFACE name:KSuspendFunction2 modality:ABSTRACT visibility:public superTypes:[kotlin.reflect.KFunction<R of kotlin.reflect.KSuspendFunction2>]
at org.jetbrains.kotlin.ir.backend.js.utils.NameTables.getNameForStaticDeclaration(NameTables.kt:315)
at org.jetbrains.kotlin.ir.backend.js.utils.IrNamerImpl.getNameForStaticDeclaration(IrNamerImpl.kt:20)
at org.jetbrains.kotlin.ir.backend.js.transformers.irToJs.EmptyCrossModuleReferenceInfo$withReferenceTracking$1.getNameForStaticDeclaration(MultiModuleSupport.kt)
But what's interesting not when I compile the library with such code, but when I compile an app which uses it.Robert Jaros
11/25/2020, 2:31 PM@JsExport
data class Test(val content: String)
val json = "{\"content\":\"data\"}"
val test = kotlin.js.JSON.parse<Test>(json)
println(test.content)
Property is undefined
, no matter if I use @JsExport
or not. It works fine with legacy and the only workaround for IR seems to be parse<dynamic>()
. Is this a known issue? Can't find anything on YT.Emmanuel Oga
11/26/2020, 1:32 AMTomasz Krakowiak
11/26/2020, 3:16 PMenum DOMParserSupportedType {
"text/html",
"text/xml",
"application/xml",
"application/xhtml+xml",
"image/svg+xml"
};
😅Andrew
11/26/2020, 7:43 PMmmaillot
11/27/2020, 9:49 AMmmaillot
11/27/2020, 2:45 PMaltavir
11/27/2020, 5:41 PMMarc Knaup
11/28/2020, 12:45 AMexternal interface Foo
external interface Scope {
@Suppress("INLINE_EXTERNAL_DECLARATION", "NON_ABSTRACT_MEMBER_OF_EXTERNAL_INTERFACE", "WRONG_MODIFIER_CONTAINING_DECLARATION", "WRONG_EXTERNAL_DECLARATION", "WRONG_BODY_OF_EXTERNAL_DECLARATION")
final inline fun Foo.print() {
console.log("${this@Scope}.$this")
}
}
fun main() {
val scope = "scope".unsafeCast<Scope>()
val foo = "foo".unsafeCast<Foo>()
with(scope) { foo.print() }
}
Vampire
11/28/2020, 4:02 AMkotlinx-nodejs
0.0.6 by 0.0.7 I suddenly get
Unresolved reference. None of the following candidates is applicable because of receiver type mismatch:
public inline operator fun RegExpMatch.get(index: Int): String? defined in kotlin.js
where the code is
val wslShellWrapperDirectory = path.join(process.env["RUNNER_TEMP"]!!, "wsl-shell-wrapper")
Anyone an idea what is broken and how to work-around it?dazza5000
11/28/2020, 3:49 PMMarc Knaup
11/29/2020, 6:22 PMkotlin-react
and kotlinx-html
, so I’ve started my own React wrapper.
• Similar to kotlin-react.
• Nicer and consistent API. Easier to use.
• Not multiplatform. Optimized for Kotlin/JS instead.
• No dependencies beside React [Router].
• Lower size and performance overhead.
• More type safety, esp. around hooks.
• Props allow class
instead of just external interface
.
• Highly experimental. IR compiler only. Relies on unofficial compiler behavior.
Anyone wants to join the project? 😄
https://github.com/fluidsonic/fluid-reactRobert Jaros
11/29/2020, 6:27 PMMranders
11/30/2020, 7:13 PMimplementation "org.jetbrains:kotlin-react-dom:16.13.1-pre.112-kotlin-1.4.0"
Looking in the build folder, my yarn.lock
contains:
react-dom@^16.13.1:
version "16.14.0"
Looking into the node-modules, the version in <Project>\build\js\node_modules\react-dom\package.json
is 16.14.0
- so everything is working just as expected.
Then I add an npm dependency to a plain Javascript module, where the package.json
contains a dependency on `"react-dom": "^15.3.2"`:
implementation npm("js-module", "1.0.0")
Now my yarn.lock
contains both of these:
react-dom@^15.3.2:
version "15.7.0"
react-dom@^16.13.1:
version "16.14.0"
Looking into the node modules, the version in <Project>\build\js\node_modules\react-dom\package.json
is 15.7.0
. This causes problems because we use React 16 features, which are missing in 15.
Is this the expected behaviour? Are there any ways to control such dependency resolutions?andylamax
12/01/2020, 9:50 AMprivate class Counter(props: Counter.Props) : RComponent<Counter.Props,Counter.State>(props) {
class Props(val initialValue: Int):RProps
class State(val value: Int) : RState
// . . .
}
fun RBuilder.Counter(initialValue: Int = 0) = child(Counter::class.js,Counter.Props(initialValue)){}
This made only RBuiler.Counter()
available to consumers. However, with IR backend we need to mark our components with @JsExport
. Sadly, IR backend won't export a private class/function it results in error upon minification similar to when you don't mark the component with @JsExport
Currently, I have resorted to leaving them public. This works but again it exposes code that wasn't meant to be public. Also pollutes the namespace as every tiny component is available on the entire project. Which is really huge.
Is there a workaround I can use, so that I may use the IR
backend, export my components but still make them private/internal
?Big Chungus
12/01/2020, 9:52 AMYan Pujante
12/01/2020, 2:04 PMSam Hamburger
12/01/2020, 3:23 PMandylamax
12/02/2020, 6:49 AMGrantas33
12/02/2020, 10:18 PMcopy
function requires to set all fields, so it is no better than just creating a new object. I'm looking for something like obj.copy(a = "foo")
in Kotlin or obj = {...obj, a: "foo"}
in JS, but for the auto-generated data classesankushg
12/03/2020, 12:08 AMLEGACY
, I was able to:
• create an umbrella module with dependencies on other modules, kotlin stdlib, and even serialization (these other modules also have their own interdependencies)
• configure browser.dceTask.dceOptions.outputDirectory
to point to a specific folder
• run processDceKotlinJs
• check that specified directory for a separate, DCEd JS file for every dependency of the umbrella module (including a DCEd version of kotlin stdlib and serialization!)
What I've done so far in `IR`:
• added binaries.executable()
to my umbrella module's JS config (and tried adding it to every dependency module)
• tagged whatever was previously relying on dceOptions.keep
with @JsExport
• tried updating browser.distribution.directory
to match dceOptions.outputDirectory
• ran browserDistribution
(since processDceKotlinJs
is missing)
I do get a single file for my umbrella repo that seems to include all of annotated contents of its dependencies
I still can't seem to get separate, DCEd JS file per module/dependency though.
Anyone else run into this or have any tips?andylamax
12/03/2020, 9:06 AMExecution failed for task ':todo-core:jsPackageJson'.
> Failed to create MD5 hash for file '/home/runner/work/builders/builders/applikation-runtime/build/js/packages/applikation-runtime-test/package.json' as it does not exist.
dazza5000
12/03/2020, 3:40 PM@JsExport
the data
class instead of the interface
?dazza5000
12/03/2020, 3:40 PM@JsExport
the data
class instead of the interface
?Svyatoslav Kuzmich [JB]
12/03/2020, 3:46 PMexternal
modifier to JsExport interface will probably workaround the issue.data
class.dazza5000
12/03/2020, 3:47 PMbbil
12/03/2020, 5:17 PMexternal interface
in the commonMain
of a MPP.
So, I can't share the interface definition... and I can't do:
@JsExport external interface A : AFromCommon
Because I get a compile error about an external interface can't extend a non-external oneSvyatoslav Kuzmich [JB]
12/03/2020, 5:25 PMexpect interface
with actual external interface
in JSbbil
12/03/2020, 5:25 PM