Erik
10/20/2020, 2:20 PMHamza GATTAL
10/20/2020, 9:19 PMMarc Knaup
10/21/2020, 2:25 AMMarc Knaup
10/21/2020, 2:28 AMval styledComponent = styled(someFunctionalComponent) { css { … } }
. Took me a few hours to figure that one out 😮
fun <P> styled(component: FunctionalComponent<P>, handler: StyledElementBuilder<P>.(props: P) -> Unit): FunctionalComponent<P> where P : RProps, P : WithClassName {
val buildStyled = styled(component.unsafeCast<RClass<P>>())
val styledComponent = { props: P ->
buildElement {
buildStyled {
val dynamicAttrs = attrs.asDynamic()
val dynamicProps = props.asDynamic()
props.getOwnPropertyNames().forEach { propertyName ->
dynamicAttrs[propertyName] = dynamicProps[propertyName]
}
handler(props)
}
}
}
if (js("process.env.NODE_ENV !== 'production'") as Boolean) {
val displayName = component.asDynamic().displayName as String?
if (displayName != null)
styledComponent.asDynamic().displayName = "styled.$displayName"
}
return styledComponent
}
Marc Knaup
10/21/2020, 10:55 AMkotlin-react
and would love to hear what you think 🙂
https://github.com/JetBrains/kotlin-wrappers/issues/358Rasmus Plaubor
10/22/2020, 12:04 PMkartik1712
10/22/2020, 3:57 PM.js
files ? So that I can include those file from in html files like <script src="/static/kotlin.js"></script>
Hamza GATTAL
10/22/2020, 9:49 PMTristan Blakers
10/23/2020, 4:52 AMhikamaeng
10/23/2020, 8:41 AMJames Mulholland
10/23/2020, 10:16 AMkotlin
NPM package; updates were carried out by building and then copying the output of ./build/js/packages/ThisPackage/kotlin/ThisPackage.js
into our Next.js project).
However, now we have added a dependency on another internal Kotlin project, I can’t get anything build properly, even in a hacky way. ./build/distributions/ThisPackage.js
contains references to window
(despite the fact that I have used the node.js build option in build.gradle.kts
) and the output in ./build/js/package
does not correctly import our other package.
Does anyone know how I might do the following:
• Get a working amount of code exported using both of our packages (Essential)
• Build a single file to copy across (Highly desirable)
• Get a node_module on GitHub’s package registry (Nice to have)
I’ve tried using the new IR backend which looks like it will get us to where we want to go at some point in the future but, unfortunately, it seems to be either buggy or missing features for the time being.
I’ve got the current setup (with mobile config omitted).
plugins {
kotlin("multiplatform") version "1.4.0"
`maven-publish`
// ...mobile plugins
id("org.jlleitschuh.gradle.ktlint") version "9.3.0"
}
repositories {
mavenCentral()
maven {
url = uri("<https://maven.pkg.github.com/our/dependency>") // another internal kotlin project
credentials(PasswordCredentials::class)
}
}
kotlin {
js {
nodejs {
}
useCommonJs()
binaries.executable()
}
// ...mobile config
sourceSets {
val commonMain by getting {
dependencies {
implementation("com.our.dependency:kotlin:0.1") // another internal kotlin project
}
}
val commonTest by getting {
dependencies {
implementation(kotlin("test-common"))
implementation(kotlin("test-annotations-common"))
}
}
// ...mobile config
val jsMain by getting
val jsTest by getting {
dependencies {
implementation(kotlin("test-js"))
}
}
}
}
publishing {
repositories {
maven {
setUrl("<https://maven.pkg.github.com/our/this-repository>")
credentials {
username = System.getenv("GITHUB_USER")
password = System.getenv("GITHUB_TOKEN")
}
}
}
}
spierce7
10/24/2020, 8:39 PMthis in 'a'..'z' || this in 'A'..'Z' || this in '0'..'9'
in the JS compiler right?loke
10/25/2020, 4:54 AMTomasz Krakowiak
10/26/2020, 10:00 AM> Task :homepage:jsBrowserTest
SourceMap position not found for trace: Uncaught TypeError: Cannot read property 'default' of undefined
at <http://localhost:9876/absoluteD:/work/workspace/boardgames/build/js/packages/boardgames-homepage-test/adapter-browser.js?6a9c7a7ceb77d7649053551ffc77e4668b658019:230734:17>
TypeError: Cannot read property 'default' of undefined
at Object.<anonymous> (<http://localhost:9876/absoluteD:/work/workspace/boardgames/build/js/packages/boardgames-homepage-test/adapter-browser.js?6a9c7a7ceb77d7649053551ffc77e4668b658019:230734:17>)
at <http://localhost:9876/absoluteD:/work/workspace/boardgames/build/js/packages/boardgames-homepage-test/adapter-browser.js?6a9c7a7ceb77d7649053551ffc77e4668b658019:138144:37>
at Object.<anonymous> (<http://localhost:9876/absoluteD:/work/workspace/boardgames/build/js/packages/boardgames-homepage-test/adapter-browser.js?6a9c7a7ceb77d7649053551ffc77e4668b658019:138147:2>)
at Object../kotlin/boardgames-homepage-test.js (<http://localhost:9876/absoluteD:/work/workspace/boardgames/build/js/packages/boardgames-homepage-test/adapter-browser.js?6a9c7a7ceb77d7649053551ffc77e4668b658019:230761:30>)
at __webpack_require__ (<http://localhost:9876/absoluteD:/work/workspace/boardgames/build/js/packages/boardgames-homepage-test/adapter-browser.js?6a9c7a7ceb77d7649053551ffc77e4668b658019:20:30>)
at Object../adapter-browser.js (<http://localhost:9876/absoluteD:/work/workspace/boardgames/build/js/packages/boardgames-homepage-test/adapter-browser.js?6a9c7a7ceb77d7649053551ffc77e4668b658019:138128:18>)
at __webpack_require__ (<http://localhost:9876/absoluteD:/work/workspace/boardgames/build/js/packages/boardgames-homepage-test/adapter-browser.js?6a9c7a7ceb77d7649053551ffc77e4668b658019:20:30>)
at <http://localhost:9876/absoluteD:/work/workspace/boardgames/build/js/packages/boardgames-homepage-test/adapter-browser.js?6a9c7a7ceb77d7649053551ffc77e4668b658019:84:18>
at <http://localhost:9876/absoluteD:/work/workspace/boardgames/build/js/packages/boardgames-homepage-test/adapter-browser.js?6a9c7a7ceb77d7649053551ffc77e4668b658019:87:10>
SourceMap position not found for trace: Uncaught TypeError: Cannot read property 'default' of undefined
at <http://localhost:9876/absoluteD:/work/workspace/boardgames/build/js/packages/boardgames-homepage-test/adapter-browser.js?6a9c7a7ceb77d7649053551ffc77e4668b658019:230734:17>
TypeError: Cannot read property 'default' of undefined
at Object.<anonymous> (<http://localhost:9876/absoluteD:/work/workspace/boardgames/build/js/packages/boardgames-homepage-test/adapter-browser.js?6a9c7a7ceb77d7649053551ffc77e4668b658019:230734:17>)
at <http://localhost:9876/absoluteD:/work/workspace/boardgames/build/js/packages/boardgames-homepage-test/adapter-browser.js?6a9c7a7ceb77d7649053551ffc77e4668b658019:138144:37>
at Object.<anonymous> (<http://localhost:9876/absoluteD:/work/workspace/boardgames/build/js/packages/boardgames-homepage-test/adapter-browser.js?6a9c7a7ceb77d7649053551ffc77e4668b658019:138147:2>)
at Object../kotlin/boardgames-homepage-test.js (<http://localhost:9876/absoluteD:/work/workspace/boardgames/build/js/packages/boardgames-homepage-test/adapter-browser.js?6a9c7a7ceb77d7649053551ffc77e4668b658019:230761:30>)
at __webpack_require__ (<http://localhost:9876/absoluteD:/work/workspace/boardgames/build/js/packages/boardgames-homepage-test/adapter-browser.js?6a9c7a7ceb77d7649053551ffc77e4668b658019:20:30>)
at Object../adapter-browser.js (<http://localhost:9876/absoluteD:/work/workspace/boardgames/build/js/packages/boardgames-homepage-test/adapter-browser.js?6a9c7a7ceb77d7649053551ffc77e4668b658019:138128:18>)
at __webpack_require__ (<http://localhost:9876/absoluteD:/work/workspace/boardgames/build/js/packages/boardgames-homepage-test/adapter-browser.js?6a9c7a7ceb77d7649053551ffc77e4668b658019:20:30>)
at <http://localhost:9876/absoluteD:/work/workspace/boardgames/build/js/packages/boardgames-homepage-test/adapter-browser.js?6a9c7a7ceb77d7649053551ffc77e4668b658019:84:18>
at <http://localhost:9876/absoluteD:/work/workspace/boardgames/build/js/packages/boardgames-homepage-test/adapter-browser.js?6a9c7a7ceb77d7649053551ffc77e4668b658019:87:10>
Uncaught TypeError: Cannot read property 'default' of undefined
at d:/work/workspace/boardgames/build/js/packages/boardgames-homepage-test/kotlin/boardgames-homepage-test.js:92632:1 <- D:/work/workspace/boardgames/build/js/packages/boardgames-homepage-test/adapter-browser.js:230734:17
TypeError: Cannot read property 'default' of undefined
at Object.<anonymous> (d:/work/workspace/boardgames/build/js/packages/boardgames-homepage-test/kotlin/boardgames-homepage-test.js:92632:1 <- D:/work/workspace/boardgames/build/js/packages/boardgames-homepage-test/adapter-browser.js:230734:17)
at d:/work/workspace/boardgames/build/js/packages/boardgames-homepage-test/kotlin/boardgames-homepage-test.js:3:116 <- D:/work/workspace/boardgames/build/js/packages/boardgames-homepage-test/adapter-browser.js:138144:37
at Object.<anonymous> (d:/work/workspace/boardgames/build/js/packages/boardgames-homepage-test/kotlin/boardgames-homepage-test.js:21:2 <- D:/work/workspace/boardgames/build/js/packages/boardgames-homepage-test/adapter-browser.js:138147:2)
at Object../kotlin/boardgames-homepage-test.js (D:/work/workspace/boardgames/build/js/packages/boardgames-homepage-test/adapter-browser.js:230761:30)
at __webpack_require__ (d:/work/workspace/boardgames/build/js/packages/boardgames-homepage-test/webpack/bootstrap:19:1 <- D:/work/workspace/boardgames/build/js/packages/boardgames-homepage-test/adapter-browser.js:20:30)
at Object../adapter-browser.js (d:/work/workspace/boardgames/build/js/packages/boardgames-homepage-test/adapter-browser.js:2:18 <- D:/work/workspace/boardgames/build/js/packages/boardgames-homepage-test/adapter-browser.js:138128:18)
at __webpack_require__ (d:/work/workspace/boardgames/build/js/packages/boardgames-homepage-test/webpack/bootstrap:19:1 <- D:/work/workspace/boardgames/build/js/packages/boardgames-homepage-test/adapter-browser.js:20:30)
at d:/work/workspace/boardgames/build/js/packages/boardgames-homepage-test/webpack/bootstrap:83:1 <- D:/work/workspace/boardgames/build/js/packages/boardgames-homepage-test/adapter-browser.js:84:18
at D:/work/workspace/boardgames/build/js/packages/boardgames-homepage-test/adapter-browser.js:87:10
java.lang.IllegalStateException: command 'C:\Users\Niema\.gradle\nodejs\node-v12.16.1-win-x64\node.exe' exited with errors (exit code: 1)
Patrick Doering
10/26/2020, 1:55 PMthana
10/26/2020, 3:36 PMkeys()
method described here? https://discuss.kotlinlang.org/t/js-interop-for-in-and-for-of-loop-of-dynamic-objects/7507/4fkrauthan
10/27/2020, 3:14 AMjs("require('normalize.css/normalize.css')")
I can include a npm packaged stylesheet into my kotlinjs project. But what If I want below that import a custom stylesheet that is specific to this project? I've tried
js("require('./style.css')")
as style.css
is in the resources
folder but it complains that it can't find that fileNikky
10/27/2020, 12:35 PMcommonTest
and jsTest
.. sadly i need to run suspending functions and runBlocking is not in kotlinjs
and suspending test function are not allowed in kotlin-test
what can i do there ?Franco
10/28/2020, 1:16 AMtry {
val dateStr = date?.toIsoString(dateOnly = true)
...
} catch (e: Exception) {
logError("Failed to parse date", cause = e)
}
public fun Date.toIsoString(dateOnly: Boolean = false): String {
val timezoneOffset = getTimezoneOffset()
val dateStr = Date(getTime() - (timezoneOffset * 60_000)).toISOString()
return if (dateOnly) dateStr.split("T")[0] else dateStr
}
And this is the error I get:
Uncaught RangeError: Invalid time value
at Date.toISOString (<anonymous>)
Any idea if I'm doing something wrong or if this error just can't be catched for whatever reason?Tristan Blakers
10/28/2020, 6:22 AMexpect class Later<T>
JS:
actual typealias Later<T> = Promise<T>
JVM:
actual typealias Later<T> = Deferred<T>
But that doesn't seem to work because of the out variance on the Promise/Deferred, i.e. Promise<out T>. This feels like a common use-case, so wondering what the usual solution is? Would prefer not to wrap each method on each platform for maintenance reasons...Dieter Konrad
10/28/2020, 7:19 AMimplementation(npm("stylus", "0.54.8"))
but resources/stylus/main.styl
file is not processed with browserDevelopmentRun
or browserDevelopmentWebpack
just copied into build/distributions/stylus/main.styl
adding /webapack.config.d/stylus.config.js doesn’t help either.
https://webpack.js.org/loaders/stylus-loader/
https://kotlinlang.org/docs/reference/js-project-setup.html#configuring-webpack-bundling
Where is a proper documentation how to use webpack with KotlinJS?Harald Pehl
10/28/2020, 10:08 AMbuild.gradle.kts
file:
plugins {
kotlin("js") version "1.4.10"
id("org.jetbrains.dokka") version "1.4.10"
`maven-publish`
}
group = "dev.fritz2"
version = "0.8-SNAPSHOT"
repositories {
mavenLocal()
mavenCentral()
maven("<https://oss.jfrog.org/artifactory/jfrog-dependencies>")
maven("<https://oss.sonatype.org/content/repositories/snapshots/>")
jcenter()
}
dependencies {
implementation("dev.fritz2:core:0.8-SNAPSHOT")
}
kotlin {
explicitApi()
js {
browser {
testTask {
useKarma {
useChromeHeadless()
}
}
}
}
}
If I execute gradle publishToMavenLocal
nothing gets published to my local maven repo. I remember this worked sometime ago. Does anybody else facing the same issue?
The code / project is also available on GitHub: https://github.com/hpehl/fritz2-elementoJames Mulholland
10/28/2020, 5:38 PMAnthony Pages
10/29/2020, 11:11 AMkotlinx.serialization
) and the generate bundle, once imported, is over 280KB (I have used source-map-explorer
to analyze it). Am I missing something ? a configuration or something. I have read some stuff around DCE but it seems to be already active in my project.Marc Knaup
10/30/2020, 12:44 AMhallvard
10/30/2020, 8:07 AMbuild/
folder has .js files all over the place. Can anyone point me to a readable table that specifies which files are where after a build? There seems to be "raw" js files and DCE'ed js files, of course, but alas, several of them and in different sub folders. Some may be only drafts while others (hopefully only one of each) are the final compiled .js files ...Daan
10/31/2020, 9:07 AMnapperley
11/02/2020, 12:28 AMNorbi
11/02/2020, 5:08 PMhallvard
11/02/2020, 8:15 PMbrowserDevelopmentWebpack
and browserProductionWebpack
gradle tasks: https://kotlinlang.org/docs/reference/js-project-setup.html, but I can't customize them. Can anyone tell me how to add a simple doFirst
or doLast
in there? The only thing I get from Gradle, is «Unresolved reference: browserDevelopmentWebpack» ...hallvard
11/02/2020, 8:15 PMbrowserDevelopmentWebpack
and browserProductionWebpack
gradle tasks: https://kotlinlang.org/docs/reference/js-project-setup.html, but I can't customize them. Can anyone tell me how to add a simple doFirst
or doLast
in there? The only thing I get from Gradle, is «Unresolved reference: browserDevelopmentWebpack» ...altavir
11/02/2020, 8:27 PMVampire
11/02/2020, 10:41 PMtasks.matching { it.name == 'browserDevelopmentWebpack' }.configure { ... }
or so.hallvard
11/03/2020, 7:13 AMaltavir
11/03/2020, 7:14 AMhallvard
11/03/2020, 7:19 AM