Another question. I can see my generated packages ...
# javascript
d
Another question. I can see my generated packages living in both
$rootDir/build/js/packages/...
and
sub-project/build/js/packages/...
. Which are the correct ones to use if I have a local TS project that need them? It seems that
npm-publish
uses the ones in the sub-projects, but the
kotlin { js { packageJson {} } }
directives are modifying the ones in the root build directory.
e
Prefer redirecting the distribution output to a specific directory of your choice. Than use that directly for local npm consumption (symlink/workspace project). Example taken from my own monorepository:
Copy code
distribution {
  val rootDir = rootProject.layout.projectDirectory
  val generatedPackageDir = rootDir.dir("generated-packages/${project.name}")
  outputDirectory.set(generatedPackageDir)
}
➕ 1
thank you color 1
a
In our examples, I usually use the
sub-project/build/dist/js/productionLibrary
or
sub-project/build/dist/js/developmentLibrary
(especially with npm-workspaces). But to do so, you need to have
binary.library()
inside of
js
block of your sub-project (and call task
jsBrowserProductionLibraryDistribution
or
jsBrowserDevelopmentLibraryDistribution
to build those distributions) Like here: https://github.com/Kotlin/kmp-logic-sharing-simple-example/blob/main/package.json But it's what we do in the educational examples, I believe @Edoardo Luppi way is more production-ready
➕ 1
thank you color 1
d
OK, thanks to you both. I will specify the output directory explicitly then. Thanks!