Hello all; an open question to know what direction...
# javascript
i
Hello all; an open question to know what direction I should investigate in. I’m using 1.4-M1, and aiming to build a multiplatform library to be used in a variety of products, including desktop and JS. Specifically for the JS library, what is generated under build/js seems to be a yarn-workspace, with kotlin, kotlin-source-map-loader, and my library, and links between all of them. I’m now trying to npm link from a sample js app that would use my library. I cannot use the library by itself, because it refers to kotlin 1.4M1 and kotlin-source-map-loader 1.4M1, but only Kotlin seems to be available on npm (why is kotlin-source-map-loader not on npm?) What is the suggested direction to go? Shoud I be webpacking my library? Am I missing something in terms of setup for npm or yarn? Does anyone have a relatively simple sample setup?
i
Hi! JavaScript libraries is not fully supported yes You are right, you can use webpack to build library (it is configured by default well already for it) The main problem is that generated
package.json
for yarn workspaces is for some details to run gradle with npm. And this
package.json
is not ready to use in external NPM application. So you can create your own
package.json
with
main
field referring on compiled file
i
Thanks Ilya. I got my sample app to use the package directly by modifying the generated package.json to:
Copy code
"kotlin": "../../packages_imported/kotlin/1.4.0-M1",
    "kotlin-source-map-loader": "../../packages_imported/kotlin-source-map-loader/1.4.0-M1"
instead of
Copy code
"kotlin": "1.4.0-M1",
    "kotlin-source-map-loader": "1.4.0-M1"
Perhaps this should be done by default, in particular since kotlin-source-map-loader is not on npm? I think source-map-loader should be published; then none of this copying of kotlin/kotlin-source-map-loader would be required. Would you like me to log these two items? (1, use local references, and 2, publish to npm)
i
In next versions, I believe local references will be by default ( I already experimented with it). Publishing of
kotlin-source-map-loader
can be ok, it solves this particular issue, but in fact it doesn’t solve all problems, because you can depends on some other Kotlin/JS library, which is not in NPM (3rd party I mean), and you will have similar problem But when this dependencies will be local paths, seems that it will not be the problem