PHondogo
05/12/2020, 8:24 AMCaused by: java.lang.AssertionError: Built-in class kotlin.Any is not found
My configuration:
in gradle.properties:
kotlin.js.compiler=ir
In gradle.build
kotlin {
target {
useCommonJs()
produceExecutable()
browser {}
}
}
Chilli
05/12/2020, 9:31 AMPHondogo
05/12/2020, 7:32 PMobject Test {
init { // want to execute it on js start without calling Test from main method
window.alert("test")
}
}
yogi
05/13/2020, 9:47 AMsourceSet
.
I have configured a custom sourceSet
as below
js {
browser {}
nodejs {
useCommonJs()
}
val fooMain by compilations.creating {
nodejs {
useCommonJs()
}
defaultSourceSet {
dependencies {
api(kotlin("stdlib-js"))
implementation(npm("<some-dependency>","some-version"))
}
}
}
val fooTest by compilations.creating {
defaultSourceSet {
dependsOn(fooMain.defaultSourceSet)
dependencies {
implementation(kotlin("test-js"))
}
}
}
}
// Some other config
sourceSets {
val jsMain by getting {
dependsOn(getByName("fooMain"))
// some more config
}
}
Now, the question is - How do I write a task that 'compiles and runs' the tests written in fooTest
. The [documentation](https://kotlinlang.org/docs/reference/building-mpp-with-gradle.html#running-tests) mentions that
For Kotlin/JS targets, add kotlin-test-js as a test dependency. At this point, test tasks for Kotlin/JS are created but do not run tests by default; they should be manually configured to run the tests with a JavaScript test framework.
Now, I believe that means configuring a KotlinJsTest
task that has useMocha()
configured.
However, I am unable to wire up such a task.
Can someone please help me out?
Also, apologies if this is present somewhere in the documentation - if it is, please direct me to it.
If it isn't , please direct me how I can add it once I have the answer 🙂Robert Jaros
05/13/2020, 12:21 PMOmar Mainegra
05/13/2020, 3:09 PMtimeout
parameter only works in node, not in browserMarian Schubert
05/13/2020, 3:36 PMRobert Jaros
05/13/2020, 4:15 PMproduceExecutable()
and produceKotlinLibrary()
in Kotlin 1.4-M1 Gradle DSL?PHondogo
05/13/2020, 9:07 PMFranco
05/14/2020, 1:05 AMJsObject
class is no longer available in the latest versions of the kotlinext
in kotlin-wrappers
, was it renamed or replaced by other class or just removed?
@turansky I know you've made a lot of changes to that repo so you might knowankushg
05/15/2020, 2:16 AMe: java.lang.ClassCastException: org.jetbrains.kotlin.ir.expressions.impl.IrGetObjectValueImpl cannot be cast to org.jetbrains.kotlin.ir.expressions.IrExpressionWithCopy
?Knut
05/16/2020, 10:37 AMdpux
05/17/2020, 8:04 PMRachid
05/17/2020, 8:46 PMproject ':domain' is not configured for JS usage
Any idea what is wrong? For the JVM subproject I already got it workingPHondogo
05/18/2020, 1:09 PMUgi
05/18/2020, 5:44 PMjs("...")
code block. In pre 1.4 I had this code to determine if I'm running on node or in browser (it's inside an actual implementation of expected method in multi platform project)
val runningOnNode = js(
"if (typeof window === 'undefined') {\n" +
" true;\n" +
" } else {\n" +
" false;\n" +
" }"
)
Since switching to 1.4 and enabling IR, that block started returning undefined
where it was previously a boolean true or false. I worked around this with this:
val runningOnNode = js(
"var isNode = false;\n" +
"if (typeof window === 'undefined') {\n" +
" isNode = true;\n" +
" } else {\n" +
" isNode = false;\n" +
" }\n" +
"return isNode;"
)
So I have two questions, and please consider that my JS knowledge is very limited:
1. Is this expected change that came with 1.4 or is it a bug?
2. Am I using js(...)
code block in a way that it was not meant to be used, and causing the issue myself?Nicholas Bilyk
05/18/2020, 7:27 PM> Task :compileKotlinJs FAILED
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See <https://docs.gradle.org/6.1/userguide/command_line_interface.html#sec:command_line_warnings>
5 actionable tasks: 1 executed, 4 up-to-date
e: java.nio.file.FileSystemException: ...\build\classes\kotlin\main\default\ir\bodies.knb: The process cannot access the file because it is being used by another process.
at java.base/sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:92)
at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:103)
at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:108)
at java.base/sun.nio.fs.WindowsFileSystemProvider.implDelete(WindowsFileSystemProvider.java:274)
at java.base/sun.nio.fs.AbstractFileSystemProvider.delete(AbstractFileSystemProvider.java:105)
If I force stop the openjdk platform binary process, it works again.mkosm
05/19/2020, 8:20 AMCould not resolve org.jetbrains:kotlin-react:16.13.0-pre.95-kotlin-1.4-M1
for all of my libs, even though I have included the required maven repositories. The lib exists on the maven server: https://kotlin.bintray.com/kotlin-js-wrappers/org/jetbrains/kotlin-react/16.13.0-pre.95-kotlin-1.4-M1/
I'm including my full build.gradle.kts
file. What am I doing wrong?Mranders
05/19/2020, 2:46 PMInformationK kotlinc-js 1.4-M1 (JRE 1.8.0_232-b09)
Information:19/05/2020 16.15 - Build completed with 1 error and 28 warnings in 10 s 86 ms
ErrorK [Internal Error] java.io.IOException: Failed to open zip file: C:\Work\hltv\build\js\node_modules\jquery\dist\jquery.js
at org.jetbrains.kotlin.utils.JsLibraryUtils.traverseArchive(JsLibraryUtils.kt:118)
at org.jetbrains.kotlin.utils.JsLibraryUtils.copyJsFilesFromZip(JsLibraryUtils.kt:102)
at org.jetbrains.kotlin.utils.JsLibraryUtils.copyJsFilesFromLibraries(JsLibraryUtils.kt:43)
at org.jetbrains.kotlin.jps.targets.KotlinJsModuleBuildTarget.copyJsLibraryFilesIfNeeded(KotlinJsModuleBuildTarget.kt:127)
at org.jetbrains.kotlin.jps.targets.KotlinJsModuleBuildTarget.doAfterBuild(KotlinJsModuleBuildTarget.kt:121)
at org.jetbrains.kotlin.jps.build.KotlinBuilder.doBuild(KotlinBuilder.kt:457)
at org.jetbrains.kotlin.jps.build.KotlinBuilder.build(KotlinBuilder.kt:309)
at org.jetbrains.jps.incremental.IncProjectBuilder.runModuleLevelBuilders(IncProjectBuilder.java:1414)
at org.jetbrains.jps.incremental.IncProjectBuilder.runBuildersForChunk(IncProjectBuilder.java:1092)
at org.jetbrains.jps.incremental.IncProjectBuilder.buildTargetsChunk(IncProjectBuilder.java:1159)
at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunkIfAffected(IncProjectBuilder.java:1053)
at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunks(IncProjectBuilder.java:882)
at org.jetbrains.jps.incremental.IncProjectBuilder.runBuild(IncProjectBuilder.java:449)
at org.jetbrains.jps.incremental.IncProjectBuilder.build(IncProjectBuilder.java:190)
at org.jetbrains.jps.cmdline.BuildRunner.runBuild(BuildRunner.java:138)
at org.jetbrains.jps.cmdline.BuildSession.runBuild(BuildSession.java:297)
at org.jetbrains.jps.cmdline.BuildSession.run(BuildSession.java:130)
at org.jetbrains.jps.cmdline.BuildMain$MyMessageHandler.lambda$channelRead0$0(BuildMain.java:218)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.util.zip.ZipException: error in opening zip file
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(ZipFile.java:225)
at java.util.zip.ZipFile.<init>(ZipFile.java:155)
at java.util.zip.ZipFile.<init>(ZipFile.java:126)
at org.jetbrains.kotlin.utils.JsLibraryUtils.traverseArchive(JsLibraryUtils.kt:116)
... 20 more
WarningK 'C:/Work/hltv/build/js/node_modules/jquery/dist/jquery.js' is not a valid Kotlin Javascript library
WarningK 'C:/Work/hltv/build/js/node_modules/moment-timezone/index.js' is not a valid Kotlin Javascript library
WarningK 'C:/Work/hltv/build/js/node_modules/moment/moment.js' is not a valid Kotlin Javascript library
WarningK 'C:/Work/hltv/build/js/node_modules/react-sortable-hoc/dist/react-sortable-hoc.js' is not a valid Kotlin Javascript library
WarningK 'C:/Work/hltv/build/js/node_modules/regenerator-runtime/runtime.js' is not a valid Kotlin Javascript library
Martin Gagnon
05/20/2020, 2:10 PM@JsExport
data class A(val b: String) {
companion object
}
e: java.lang.AssertionError: Properties without fields are not supported A.Companion_instance
Also, when using the @JsExport
annotation on an object
, example:
@JsExport
object A {
var b: String = ""
}
The following TypeScript definition is generated:
/* ErrorDeclaration: Class A with kind: OBJECT */
Is there any workaround for this? Is there any plan to support those types?Andrey Logoshko
05/20/2020, 7:03 PMGrantas33
05/20/2020, 8:27 PMFranco
05/20/2020, 9:25 PMJoffrey
05/21/2020, 9:47 AMTristan
05/22/2020, 12:36 AMuseContext
but I am facing this error
When accessing module declarations from UMD, they must be marked by both @JsModule and @JsNonModule
Have you already encountered this issue?Nicholas Bilyk
05/22/2020, 3:21 AMReferenceError: HTMLLegendElement is not defined
at D:\Projects\acornui2\build\js\packages_imported\kotlinx-html-js\0.7.1\kotlinx-html-js.js:66:29
Also, is there a version that uses es5?frank
05/23/2020, 1:27 AMplugins {
id("org.jetbrains.kotlin.js") version "1.4-M1"
}
repositories {
maven("<https://dl.bintray.com/kotlin/kotlin-eap>")
jcenter()
mavenCentral()
}
dependencies {
implementation(kotlin("stdlib-js"))
}
kotlin.target {
useCommonJs()
nodejs()
}
tasks.compileKotlinJs {
kotlinOptions.outputFile = "routes/node/index2.js"
kotlinOptions.metaInfo = false
}
My Enviroment:
- Gradle: 6.4.1 (compatible with JDK 14)
- IDEA last eap. (With previus versions the same)
- Kotlin 1.4-M1(I tried with old versions)Ananiya
05/24/2020, 12:59 PMAn exception occurred applying plugin request [id: 'java']
> Failed to apply plugin [id 'org.gradle.java']
> Cannot add task 'processResources' as a task with that name already exists.
while i am creating new kotlin/js project . I am using intellij idea ultimate 2020.1 with jdk 8 and here is my gradle fileGrantas33
05/24/2020, 7:29 PMjs {
useCommonJs()
produceExecutable()
browser {}
}
Is there a way to compile typescript declarations in commonJs format in kotlin multiplatform 1.4-M1?Andrew
05/24/2020, 8:28 PM