269 questions
3
votes
1
answer
254
views
Uncaught ReferenceError: firebase is not defined in Kotlin/JS project with Dukat generated declarations
In a basic kotlin js project, I imported the firebase dependency. I used Dukat to get access to the type references and got them to compile. My kotlin compiles like a charm, however it seems to me ...
3
votes
1
answer
370
views
Deploying KotlinJs React web app to Heroku, error extracting tar content of undefined failed
I have the following setup. Kotlin Multiplatform project with a Web App and Shared module. I also have included a build of a library that I had to modify myself as it wasn't working properly.
When ...
15
votes
3
answers
2k
views
Kotlin/JS, Gradle Plugin : Unable to load '@webpack-cli/serve' command
I was doing the tutorial for React Kotlin and couldnt even finish the setup step because the server does not start.
The code is unchanged : https://github.com/kotlin-hands-on/web-app-react-kotlin-js-...
0
votes
2
answers
334
views
Kotlin js/jvm format templates
I am looking for an ability to describe format templates (eg. used in java.util.Formatter) for dates (like java.text.SimpleDateFormat) and numbers (like java.text.DecimalFormat) that could be ...
1
vote
1
answer
428
views
KotlinJS react-hook-form library, registering elements
Hello everyone I tried getting react-hook-form to work with KotlinJS using Dukat and Wrappers, this is what I got.
(the wrapper works fine, tried logging it in the console and it indeed is useForm ...
4
votes
1
answer
4k
views
How to compile a Kotlin file to JavaScript?
Hi I am getting started with KotlinJS on Node and I've put a very simple kotlin file and I want to compile it using the raw kotlinc-js compiler. Without using gradle
package main
fun heavy() {
(1....
1
vote
1
answer
860
views
White border on webpage
My website is displaying an undesired white border for all my components, even when using default configs:
Main.kt
fun main() {
renderComposable("root") {
Div({ style { height(...
2
votes
0
answers
759
views
Cannot read properties of undefined (reading 'iterator') in Kotlin Multiplatform
I am trying to run a kmm project js files on a browser. Here the html:
<html lang="en">
<head>
<meta charset="UTF-8">
<script src="../...
1
vote
1
answer
463
views
KotlinJS and React, get change value from TextArea
Hello everyone I am trying to get value from textArea DOM but it doesn't seem to work like regular react
val chat = fc<ChatProps> { props ->
val (mess, setMess) = useState("")
...
2
votes
0
answers
1k
views
How to use/create kotlin multiplatform JS library?
Created a Kotlin MPP for developing a JS library, and a JVM lib. Everything worked well in the Kotlin world and I was able to build the project. Once build was completed the distributions folder(...
1
vote
0
answers
111
views
Extending Kotlin's js wrapper classes
Using Kotlin/js, here's something that works:
fun main() {
val canvas=document.getElementById("mainCanvas") as HTMLCanvasElement
val ctx=canvas.getContext("2d") as ...
0
votes
1
answer
407
views
Is there a way to make equals (==) check on kotlin.js.Date object work?
I would like to ask for some help/suggestions on an issue we're facing when trying to unit test platform specific Date classes in our Kotlin Multiplatform project.
Our Kotlin Multiplatform library ...
1
vote
1
answer
821
views
Kotlin/JS: Check if T is Enum
I want to check if a given (reified) generic class is an enum:
console.log(isEnum<String>(), isEnum<MyObject>(), isEnum<MyEnum>())
should print false, false, true for following ...
0
votes
1
answer
361
views
How to use the Google Closure Compiler to optimize Kotlin JS
Is it possible to use the Google Closure Compiler to minify Kotlin JS code further than what Webpack offers? If so, how can it be done?
1
vote
1
answer
890
views
How to execute a Node command in a Kotlin/JS project
Kotlin/JS maintains a local Node installation, used by Yarn, etc.
Is there a way to execute commands via that installation, without using a Gradle plugin that downloads another one?
1
vote
0
answers
106
views
How do I use Kotlin functions exported to Javascript in browser?
I'm trying to build some basic Kotlin code as a JS library. Just for testing, I want to be able to call some of this code right from a browser console.
Here is some of the code I'm working with.
build....
0
votes
1
answer
287
views
Check if an image is loaded with Kotlin/JS for React
In my application (Kotlin/JS, React), the image is loaded from remote resource:
import org.w3c.dom.HTMLElement
import react.RBuilder
...
private var imageForLoad: HTMLElement? = null
...
override fun ...
6
votes
1
answer
2k
views
How to convert Javascript exported class to Kotlin/JS?
I am new to JS and to Kotlin/JS. I have the following minimal working Javascript code for a Plugin for Obsidian from an example. It works as expected:
var obsidian = require('obsidian');
class ...
2
votes
1
answer
1k
views
Kotlin/Js add npm dependency from custom registry
I'm developing an application with Kotlin/JS and Gradle. I can easily add npm dependencies from the default npm registry with the implementation npm("query-string", "7.0.0") ...
3
votes
0
answers
334
views
Kotlin/JS — Compile a JS library with types defined in NPM dependency
I’m trying to write a library using the new Kotlin/JS IR compiler. Specifically, I want to write the library using Kotlin, but to publish it as a NPM package to be used in a Typescript/Node project.
I ...
0
votes
1
answer
155
views
building kotlinJs app on github actions CI
I'm having some issues setting up github actions to build my kotlinJS project?
i have the js runtime dependency:
implementation(npm("kotlinx-serialization-kotlinx-serialization-core-jslegacy"...
2
votes
0
answers
201
views
RxJs in full stack Kotlin/JS
I'm having difficulty importing the RxJs library in my full stack Kotlin/JS project. I put the following in my build.gradle.kts file in the frontendMain section:
implementation(npm("@reactivex/...
13
votes
2
answers
4k
views
Is it possible to import a JavaScript file in a Kotlin/JS project?
If I have a JavaScript file called myfile.js as follows:
function myJsFunc() { return "Hello from JavaScript"; }
How can I import this file into a Kotlin/JS project and invoke myJsFunc() ...
0
votes
1
answer
894
views
Kotlin JS: Is it possible to set up a Kotlin Web application with Spring Boot and Kotlin/JS(without front-end framework)?
I've been reading books and trying examples for Kotlin full-stack development, but they all have one thing in common, that they are built for SPA apps and the logic is heavy on the client side. ...
5
votes
0
answers
423
views
Unable to download nodejs from kotlin multiplatform gradle project
I have built a kotlin multiplatform project using gradle from my home machine without any problems. However upon entering a corporate proxy that does not allow the downloading of executable files.
I ...
2
votes
0
answers
132
views
Kotlin/JS NPE Source Reference
I have a Kotlin/JS project that is throwing a null pointer exception, but I can't figure out where it is coming from. The source map in the browser references exceptionUtils.kt?24ab which is a generic ...
0
votes
1
answer
95
views
Linking JS stdlib to generated kdoc
Developing a Kotlin/JS project, we are generating KDoc using Dokka Maven plugin. However standard JS library classes are presented as ERROR CLASS in the generated doc.
Example: having function like ...
0
votes
1
answer
632
views
async event handlers in lit-html
Is there a way to have async event handlers in lit-html ?
I have this submit event that's being triggered when the form is submitted to create a new user, but I also want to reload the list of users ...
0
votes
1
answer
504
views
Not able to set max-height in css for navbar logo
Am trying to create navbar with logo but unable to increase the size of image.
This is written in kotlin/js but concept should be same for native html/js code.
Html index file:
fun HTML.index() {
...
4
votes
2
answers
3k
views
How do I add a JS target to a KMM project?
I have an AndrodiStudio KMM project and I'd like to add a JS target.
Given that JS development is only available in IntelliJ, I'd expect that I have to open the project in IDEA add a "Module"...
1
vote
0
answers
98
views
How to define external classes of a node module in separate files - kotlinjs
I'm attempting to write a wrapper for an npm package but I cannot figure out how to define classes within a module in a separate file. It works fine if I do it within the single class but the file ...
1
vote
0
answers
292
views
Build standalone NPM Module with KotlinJS
When I follow the guide Create a multiplatform library I manage to get Jar to be used in Kotlin/JVM side, but the npm module doesn't look good - it is generatesd with physical paths to dependenices to ...
2
votes
0
answers
205
views
What's the best pattern for exception handling when using coroutines in kotlinjs?
I have a kotlinjs app. I handle a particular event (dropping of data onto a component) like this:
onEvent {
drop = { event ->
GlobalScope.async {
...
2
votes
0
answers
808
views
How to reference image resource in kotlin/JS
I try to reference an image resource from react kotlin app.
welcome.kt under src/main/kotlin:
import react.dom.img
@JsModule("./logo.svg")
@JsNonModule
external val logo: dynamic
@JsExport
...
1
vote
0
answers
514
views
Error running test kotlin multiplatform. kotlinx-coroutines-test for js with Error: Fail to fetch
I am using the workaround for testing coroutines in common code. the most suggested workaround and seems to work for a lot of people kotlinx-coroutines-test for multiplatform, but by js test is ...
3
votes
1
answer
480
views
Koltin Multiplatform Multi Module JVM/JS Project Setup
I need to convert existing multi-module jvm project into a multiplatform project.
//Exisiting Modules: (JVM Project)
core
data
app
app_server
utils
db
//Need to add:
app_frontend (Kotlin/JS)
Need to ...
1
vote
0
answers
418
views
Create Google chrome Extension with Kotlin
I have a situation where I am trying to create a google chrome extension using KotlinJs and I was following the Rivas Diaz (https://github.com/rivasdiaz/helloworld-chrome-extension-kotlin).
With this, ...
1
vote
0
answers
131
views
Docker: SourceMap for KotlinJS not found
I am trying to get my KotlinJS running in a Docker container. Normally this should not be a problem. The programm itself is a KVision-website and runs without errors. When putting it into a Docker ...
8
votes
2
answers
4k
views
How do you add css to a Kotlin JS project?
I created a new Kotlin/JS Gradle project using the wizard in IntelliJ.
I'm unclear how I'm supposed to add css to the project. The documentation explains how to enable css webpack support, but it ...
0
votes
1
answer
1k
views
Using a KClass reference as a reified parameter to deserialize from JSON
I'm trying to implement a general serialization framework to convert outgoing and incoming messages to json using the kotlinx serialialization. I'm developing a multiplatform app, so I'm trying to get ...
0
votes
0
answers
92
views
Kotlin/JS web app doesn't start on Heroku
When I start the app, I get error code H14: no web proccess running.
I've already seen this: Gradle java web app doesn't start on heroku
heroku, and I've tried to run the command, yet I get this ...
0
votes
1
answer
208
views
I'm getting this error when trying to read a local JSON file in Kotlin/JS+React. What is going on?
I'm trying to read a JSON array from a file, store it as a List in my component, and use it to display some stuff, yet I'm getting this error: Warning: Can't call setState on a component that is not ...
3
votes
1
answer
2k
views
How do I export a Kotlin JS project?
Sorry, but the Kotlin documentation doesn't help me to export a Kotlin JS project to deploy it on my webserver.
I created a new Kotlin Browser Application with the new project wizard in IntelliJ.
...
0
votes
0
answers
638
views
KotlinJs : how to write HandleBarJS in kotlin
I have a running JS code that uses HandleBarJs:
var fs = require('fs');
let template = fs.readFileSync('template.txt', 'utf8')
let submissionJson = fs.readFileSync('submission.json', 'utf8')
var ...
1
vote
2
answers
3k
views
How to use/import TypeScript declaration files in JavaScript?
I'm playing a little bit with Kotlin Multiplatform.
Right now, I try to develop a Kotlin JS library to import and use it in an external JavaScript project. This works fine so far. Kotlin creates the ...
0
votes
1
answer
175
views
Why does my Kotlin app fail to load a Kotlin ServiceWorker script because 'kotlin' was not found?
I'm writing my first Progressive Web App for some experience with the concept. The web app is written in Kotlin.js and the ServiceWorker is too. When running the app I get this error
Uncaught Error: ...
0
votes
1
answer
876
views
kotlinNpmInstall behind corporate proxy
I'm trying to build kotlin multiplatfrom project behind corporate proxy connection and got and error:
Couldn't find package "[email protected]" required by "projectName@version" on ...
4
votes
3
answers
1k
views
Setting output path for Kotlin/JS distribution / webpack output
When building my project using the browserDistribution Gradle task, Kotlin/JS puts the output which has been processed by webpack into /build/distributions/myProject.js.
Instead, I would like my ...
1
vote
1
answer
494
views
Getting command line arguments for Kotlin/JS Node process
I have a very basic Kotlin/JS application targeting Node.js through the Gradle plugin. I want to read the command line arguments passed to the process when I execute it (using node build/js/packages/...
1
vote
2
answers
429
views
How to create an "options object" (Object with many optional properties) in Kotlin compiling to JavaScript?
Background: Options-objects in JavaScript
A common concept in JavaScript is something like this:
function MyLibrary(options) {
if (options.optionA) { /* ... */ }
if (options.optionB) { /* ... *...