I'm trying the new 1.3.70-eap for `JSExport` with ...
# javascript
s
I'm trying the new 1.3.70-eap for
JSExport
with the compiler opts. I'm getting out a
.js
and
.d.ts
file. But when trying to import into a
ts
project I'm getting
output.d.ts is not a module
The top level looks like
Copy code
declare namespace output {
    type Nullable<T> = T | null | undefined
    namespace my.test.project
        .....
    }
}
Is there an example of how to properly structure / bundle the output into a npm package?
s
I was looking for this also. Check out the thread. https://kotlinlang.slack.com/archives/C0B8L3U69/p1582038458410800
Might not be what you where looking for, but we did successfully manage to build an NPM package with all dependacies.
s
It's looking closer thanks. I'll dive into that repo. Right now I'm doing
Copy code
tasks {
...
    val compileKotlinJs by getting(org.jetbrains.kotlin.gradle.tasks.Kotlin2JsCompile::class) {
        kotlinOptions {
            outputFile = "$projectDir/jsOut/output.js"
            sourceMap = true
            freeCompilerArgs = listOf("-Xir-produce-js", "-Xgenerate-dts")
        }
    }
}
Which gives the
js
and
ts.d
files . i have that going into a folder with a
package.json
which then publishes to an npm artifact server. I'm just trying to figure out the import for an actual ts project. It seems like the
d.ts
isn't in the expted format? Lot to read through there though.
e
I wasn't aware of that compiler option, and I haven't looked much into generating typescript definitions yet. I agree, the generated
d.ts
doesn't look very useful at all, and it would probably be difficult to get to work with our current workarounds of shuffling files around in the
buildDir
. I'm hopeful that this use-case will work more or less out of the box in
1.4
.
s
The js works fine as long as you're not using ts. I'm wondering if there is a bug / issue tracking this right now. I can even finagle the
ts.d
to work. But it's manual intervention.