Robert Jaros
12/12/2019, 11:37 AMconfig.plugins.push(new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery",
"window.jQuery": "jquery"
}));
in webpack.config.d/jquery.js
. With new Kotlin/JS plugin it fails with an error:
webpack.config.js:69
config.plugins.push(new webpack.ProvidePlugin({
^
ReferenceError: webpack is not defined
Robert Jaros
12/12/2019, 2:05 PMbuild/js/packages/[name]/kotlin/[name].js
but resources from src/main/resources
are put into build/processedResources/Js/main/
. When I try to require
something from my code, webpack is unable to find these resources. Can it be configured somehow?galex
12/12/2019, 2:17 PM@JsName
on each function?Robert Jaros
12/12/2019, 6:58 PM*.js
files from webpack.config.d
inlined into generated karma.conf.js
when running build
or test
task? These files are for webpack.config.js
and karma config is completely different .Robert Jaros
12/12/2019, 7:01 PM> Task :browserTest
12 12 2019 19:59:43.293:ERROR [preprocess]: Can not load "webpack", it is not registered!
Perhaps you are missing some plugin?
12 12 2019 19:59:43.296:ERROR [preprocess]: Can not load "sourcemap", it is not registered!
Robert Jaros
12/12/2019, 7:02 PMRobert Jaros
12/13/2019, 12:10 PMRobert Jaros
12/13/2019, 1:57 PMgalex
12/13/2019, 6:48 PMgalex
12/14/2019, 5:06 AMBahaa Kallas
12/16/2019, 10:01 AMBahaa Kallas
12/16/2019, 10:37 AM"ourLibraryModule":browserWebpack
task it fails for some dependencies (kotlin-react, kotlin-react-dom, kotlin-extensions, kotlinx-html-js)
with the known error message “Module not found: Error: Can’t resolve etc.”
we had this issue before when we tried to manage our projects using the kotlin frontend plugin but in the end we end up giving up on that
some lines of code states how we doing this right now :
in ourModule build.gradle
sourceSets["main"].dependencies{
api(npm("kotlinx-html","0.6.12"))
api(npm("@jetbrains/kotlin-extensions","1.0.1-pre.89"))
api(npm("@jetbrains/kotlin-react", "16.9.0-pre.83"))
api(npm("@jetbrains/kotlin-react-dom", "16.9.0-pre.83"))
}
in parent build.gradle
dependencies {
implementation(kotlin("stdlib-js"))
implementation(project(":ourModule"))
}
in ourModule build.gradle
we have other dependencies but the webpack task fails only for those
does anyone has this project setup and were able to do it by gradle ?Bahaa Kallas
12/16/2019, 3:46 PMkotlinFrontend {
webpackBundle {
bundleName = "main"
sourceMapEnabled = true | false // enable/disable source maps
contentPath = file(...) // a file that represents a directory to be served by dev server)
publicPath = "/" // web prefix
host = "localhost" // dev server host
port = 8088 // dev server port
proxyUrl = "" | "http://...." // URL to be proxied, useful to proxy backend webserver
stats = "errors-only" // log level
}
}
bjonnh
12/16/2019, 11:25 PMbjonnh
12/16/2019, 11:55 PMbjonnh
12/17/2019, 1:49 AMbjonnh
12/17/2019, 6:23 AMval compileKotlin2Js by getting(org.jetbrains.kotlin.gradle.tasks.Kotlin2JsCompile::class)
compileKotlin2Js.apply { kotlinOptions.moduleKind = "commonjs" }
Egor Okhterov
12/18/2019, 10:02 AMplugins {
kotlin("js") version "1.3.61"
}
if we can use
plugins {
kotlin("multiplatform") version "1.3.61"
}
breandan
12/18/2019, 7:21 PMhttps://youtu.be/0xKTM0A8gdI?t=2076▾
1.4.0-dev-74
and enabling Gradle's --continuous
mode)
edit #2: It now appears to work, updating to 1.4.0-dev-74
was not necessary. Previously was using ./gradlew run --continuous
but ./gradlew browserRun --continuous
was the correct command.breandan
12/19/2019, 6:27 AMleftpad
seemed to fail with various build errors.jw
12/19/2019, 9:50 PMian.shaun.thomas
12/20/2019, 6:18 AM./gradlew :terrain-preview-web:run
. Has anyone tried anything similar for say some simple 3d backed by Kotlin JS? Wondering if you saw similar performance concerns doing quat maths or similar at higher frame rates.Egor Okhterov
12/20/2019, 9:27 AMindex.html
and then javaScript in that index.html makes REST API requests to the original backend? Would you make a separate module for a web client (similar to andoid module) or you just make a jsMain
sourceSet in the backend directory?fkrauthan
12/21/2019, 7:55 PMcreate-react-kotlin-app
is not the right choice (as that is more for standalone webapps with kotlin). The kotlin frontend plugin seem to be deprecated so I've tried it as plugin multiplatform
and then only have js { browser() }
configured (I assume that is currently the recommended way?). But now when I try to include the dependency to my commons library (which is also multiplatform
and has js()
as one of its target) I receive the error: project ':clients:clients-common' is not configured for JS usage
any idea what I am missing or am I going completely off the rails with my setup?diesieben07
12/21/2019, 10:05 PMtype Foo = "foo" | "bar"
cannot be expressed in Kotlin).
Another thing that I have noticed is that the kotlinx libraries (ktor, kotlinx.serialization, io) and the stdlib seem to think that they should be polyfilling things themselves if they are missing in the underlying platform. This leads to things like <http://kotlinx.io|kotlinx.io>
requiring an outdated npm library (text-encoding
) using dynamic calls to require (what if the underlying module system is not commonjs?) if the global TextEncoder
API is not found. Instead it should be the user's responsibility (based on their browser support demands) to load an appropriate polyfill if required.
There are great tools (babel and their preset-env) that make it so you can transpile modern Javascript code to run on older browsers and polyfill missing APIs (using core-js). Kotlin should imho use this amazing toolchain, instead of re-inventing the wheel.
</rant>coolcat
12/22/2019, 8:24 PMfun main() {}
that does a simple print, and an index.html
with <script src="project.js"></script>
. I run the jsBrowserRun
gradle task, and it works, I see the string printed in page console OK.
But I also see
[WDS] Live Reloading enabled.
So I tried changing the printed string, and I see:
[WDS] App updated. Recompiling...
[WDS] Nothing changed.
Quitting and restarting the server makes the amended string appear.
Any hints as to what I can do to make live reloading work correctlyfkrauthan
12/23/2019, 7:00 AMjs { browser() }
how can I run it though the kotlin-dce-js
plugin? Or is that at the moment not supported?jdemeulenaere
12/23/2019, 5:49 PMjdemeulenaere
12/23/2019, 5:50 PMEgor Okhterov
12/24/2019, 10:32 AMdata class User(val id: Int)
@RpcService
interface UserService {
suspend fun getUsers(): List<User>
}
and generates client for use in Kotlin/JS
class HomeView : ReactDOMComponent<HomeView.Props, HomeView.State>() {
prival val userService: UserService by removeServicesPlugin
override suspend fun componentWillMount() {
super.componentWillMount()
state.users = userService.getUsers()
}
}
Egor Okhterov
12/24/2019, 10:32 AMdata class User(val id: Int)
@RpcService
interface UserService {
suspend fun getUsers(): List<User>
}
and generates client for use in Kotlin/JS
class HomeView : ReactDOMComponent<HomeView.Props, HomeView.State>() {
prival val userService: UserService by removeServicesPlugin
override suspend fun componentWillMount() {
super.componentWillMount()
state.users = userService.getUsers()
}
}
Robert Jaros
12/24/2019, 11:20 AM