georgi
09/30/2022, 4:36 PMpackage.json
file does not have a main
entry point, while all my module `package.json`s do have corresponding entries for the main .js
file. I'm aware we can customise these by doing something like the below, but that only changes the relevant module's package.json
.
js(IR) {
compilations["main"].packageJson {
customField(
"dependencies", mapOf(
"a" to "b"
)
)
}
}
Is there a way to modify the root package.json
, i.e. the one that lives in build/js/package.json
? I basically want to add a main
property pointing to my module entry point.georgi
09/30/2022, 4:37 PMpackage.json
looks like this
{
"name": "thecodinglove-kmp",
"version": "unspecified",
"private": true,
"workspaces": [
"packages/thecodinglove-kmp-appJs",
"packages/thecodinglove-kmp-appJs-test",
"packages/thecodinglove-kmp-kmp-module-b",
"packages/thecodinglove-kmp-kmp-module-b-test",
"packages/thecodinglove-kmp-module-a",
"packages/thecodinglove-kmp-module-a-test",
"packages_imported/kotlin/1.7.20-RC",
"packages_imported/kotlin-test-js-runner/1.7.20-RC",
"packages_imported/kotlin-test/1.7.20-RC"
],
"resolutions": {},
"devDependencies": {},
"dependencies": {},
"peerDependencies": {},
"optionalDependencies": {},
"bundledDependencies": []
}
which seems okay but there's no main
entry ๐คBig Chungus
09/30/2022, 5:39 PMBig Chungus
09/30/2022, 5:39 PMBig Chungus
09/30/2022, 5:40 PMBig Chungus
09/30/2022, 5:42 PMgeorgi
09/30/2022, 9:54 PMgeorgi
09/30/2022, 9:56 PMFinally build/js is an intermediate output and should never be directly relied uponIm using a nodejs target so I donโt have webpack or the ability to set an output directory. What would be a reliable output folder for nodejs?
Big Chungus
10/01/2022, 10:43 AMgeorgi
10/01/2022, 2:38 PMgeorgi
10/01/2022, 2:39 PMBig Chungus
10/01/2022, 3:19 PMBig Chungus
10/01/2022, 3:21 PMgeorgi
10/01/2022, 4:20 PMBig Chungus
10/01/2022, 4:29 PMgeorgi
10/01/2022, 7:15 PMBig Chungus
10/01/2022, 7:21 PMBig Chungus
10/01/2022, 7:21 PMBig Chungus
10/01/2022, 7:23 PMgeorgi
10/01/2022, 8:03 PMThere should be. Just specify binaries.library (or binary) and look through your build/ folderYep, I'm already specifying
binaries.executable()
for nodejs
, similarly to what the IntelliJ template/online sample do, and all I get is build/js
which contains the resulting binaries.
js(IR) {
binaries.executable()
nodejs()
}
I also don't think KotlinJsBinaryContainer
for nodejs
supports further customisation, based on the dsl reference here (and what I tried with the latest version). However, browserjs
does support webpack
and distribution
config blocks which allow us to set output destination.
Thanks for the sample btw, some great stuff over there!Big Chungus
10/01/2022, 8:05 PMBig Chungus
10/01/2022, 8:06 PMgeorgi
10/01/2022, 8:10 PMWhat gradle command do you run?
./gradlew assemble
. I essentially would like to run this as part of a CI job which would generate the binaries to be exported over to Firebase Cloud Functionsgeorgi
10/01/2022, 8:11 PMBig Chungus
10/01/2022, 8:13 PMBig Chungus
10/01/2022, 8:13 PMgeorgi
10/01/2022, 8:18 PMbuild
folders of all of them. Based on this the root project's build
contains only a js
folder with the binariesgeorgi
10/01/2022, 8:21 PMbuild/js
further, it contains the .js
files with all the individual submodules which all seems correct to me, unless I'm missing something ๐georgi
10/01/2022, 8:23 PMNodeJS
IntelliJ template, which I suspect is what Gradle uses when I run ./gradlew run
(which executes the NodeJs project)Big Chungus
10/01/2022, 8:24 PMBig Chungus
10/01/2022, 8:24 PMBig Chungus
10/01/2022, 8:25 PMBig Chungus
10/01/2022, 8:26 PMgeorgi
10/01/2022, 8:26 PMWhich module has binaries configured? Does root module have any source files?The
appJs
module has a binary configured. The root project doesn't have any KotinJS config, only this:
allprojects {
repositories {
mavenCentral()
}
}
Big Chungus
10/01/2022, 8:27 PMBig Chungus
10/01/2022, 8:27 PMgeorgi
10/01/2022, 8:28 PMcompileSync
I'm finding this! Quite interesting ๐
Big Chungus
10/01/2022, 8:29 PMBig Chungus
10/01/2022, 8:29 PMgeorgi
10/01/2022, 8:29 PMnpm-publish
could help with?Big Chungus
10/01/2022, 8:30 PMBig Chungus
10/01/2022, 8:30 PMBig Chungus
10/01/2022, 8:31 PMgeorgi
10/01/2022, 8:31 PMBig Chungus
10/01/2022, 8:32 PMgeorgi
10/01/2022, 8:46 PMBig Chungus
10/01/2022, 8:59 PMBig Chungus
10/01/2022, 9:00 PMgeorgi
10/01/2022, 9:14 PMgeorgi
10/02/2022, 11:38 AMnpm-publish
plugin simplifies all this and I end up with a correct package.json
when using implementation(npm(..))
+ binaries.library
configuration.Big Chungus
10/02/2022, 11:42 AMgeorgi
11/17/2022, 11:06 PMnpm-publish
plugin handle npm()
dependencies of submodules?
My main app module is set as binaries.library()
and I'm applying the dev.petuska.npm.publish
plugin which gives me a correct package.json containing any npm
dependencies I've added to that module. However, if I try to move the same npm
dependency to a sub-module I get Error: Cannot find module
errors, which makes me think that the submodule's npm
dependencies aren't included or I'm missing some config. The submodule itself is marked as js(IR) { nodejs() }
Big Chungus
11/18/2022, 7:38 AMBig Chungus
11/18/2022, 7:40 AMgeorgi
11/18/2022, 8:01 AMgeorgi
11/18/2022, 9:30 AM