Kotlin / dukat

Converter of <any kind of declarations> to Kotlin external declarations
553 stars 42 forks source link

Support for UMD #106

Open SebastianAigner opened 5 years ago

SebastianAigner commented 5 years ago

If I uncomment the useCommonJs directive from my build.gradle.kts file like so:

    target {
        browser()
        //useCommonJs()
    }

The project is no longer able to compile:

Main.kt: (2, 13): When accessing module declarations from UMD, they must be marked by both @JsModule and @JsNonModule
felipehjcosta commented 4 years ago

Any news about this issue?

iHad169 commented 4 years ago

if my build.gradle.kts is below. how to do it?

plugins {
    id("org.jetbrains.kotlin.js") version "1.4.10"
}

group = "org.exmaple"
version = "1.0"

repositories {
    maven("https://kotlin.bintray.com/kotlin-js-wrappers/")
    mavenCentral()
    jcenter()
}

dependencies {
    implementation(kotlin("stdlib-js"))

    //React, React DOM + Wrappers (chapter 3)
    implementation("org.jetbrains:kotlin-react:16.13.1-pre.110-kotlin-1.4.0")
    implementation("org.jetbrains:kotlin-react-dom:16.13.1-pre.110-kotlin-1.4.0")
    implementation(npm("react", "16.13.1"))
    implementation(npm("react-dom", "16.13.1"))
    //Kotlin Styled (chapter 3)
    implementation("org.jetbrains:kotlin-styled:1.0.0-pre.110-kotlin-1.4.0")
    implementation(npm("styled-components", "~5.1.1"))
    implementation(npm("inline-style-prefixer", "~6.0.0"))
    //Video Player (chapter 7)
    implementation(npm("react-player", "~2.6.0"))
    //Share Buttons (chapter 7)
    implementation(npm("react-share", "~4.2.1"))
    //Coroutines (chapter 8)
    implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.9")
}

kotlin {
    js {
        browser {
            webpackTask {
                cssSupport.enabled = true
            }

            runTask {
                cssSupport.enabled = true
            }

            testTask {
                useKarma {
                    useChromeHeadless()
                    webpackConfig.cssSupport.enabled = true
                }
            }
        }
        binaries.executable()
    }
}
francos commented 4 years ago

@iHad169 you need to add useCommonJs() inside js { }, like this:

kotlin {
    js {
        browser {
            webpackTask {
                cssSupport.enabled = true
            }

            runTask {
                cssSupport.enabled = true
            }

            testTask {
                useKarma {
                    useChromeHeadless()
                    webpackConfig.cssSupport.enabled = true
                }
            }
        }
        binaries.executable()

        useCommonJs()
    }
}