https://kotlinlang.org logo
#javascript
Title
# javascript
c

Császár Ákos

03/27/2024, 1:12 PM
Hi! I have 2 libraries. A and B B depends on A 1. Can I configure the generated
package.json
file of A? 2. When I run
jsonBrowserProductionWebpack
on B, will the generated
package.json
contain the dependencies/fields from A?
a

Artem Kobzar

03/27/2024, 1:21 PM
@Ilya Goncharov [JB] could we do something like this?
c

Császár Ákos

03/27/2024, 1:27 PM
For example: I want to add
@react-native-async-storage/async-storage
to A as
implementation(npm("@react-native-async-storage/async-storage", "1.23.1"))
But when I run
jsonBrowserProductionWebpack
on B (or even on A) the generated package.json file doesn't contain this dependency (Maybe I am doing someting wrong). So when I want to publish B I need to manually add the dependency to the package.json of B
It would be awesome to add it just to A, and when I want to publish B, it generates the correct json
e

Edoardo Luppi

03/27/2024, 1:28 PM
It's very strange. The
npm
implementation dependency of A should definitely appear when creating B distribution.
Example: my project A declares a dependency on Linkedom. I then make project B depend on project A (transitively too!), and the package.json correctly contains Linkedom.
c

Császár Ákos

03/27/2024, 1:34 PM
Interesting. I will try with an empty project to see if it really should do automatically. Currently not even in the package.json of A doesn't appear as dependency.
e

Edoardo Luppi

03/27/2024, 1:37 PM
However, I think the problem you're seeing depends on the task you're executing. You should use
jsBrowserProductionLibraryDistribution
, and not
jsBrowserProductionWebpack
The task you mentioned doesn't seem to exist
I recently asked about Webpack and
binaries.library()
, and the answer is Webpack won't run with a library target. So I'm not sure where you found that Webpack task
c

Császár Ákos

03/28/2024, 6:56 AM
You are right. I can use
jsBrowserProductionLibraryDistribution
.
As I see, the dependencies from A appears in the generated files of B, but not the peer dependencies. Do you know why is that? Is there any step by step guide for how to publish the library to npm?
e

Edoardo Luppi

03/28/2024, 9:08 AM
peer dependencies
Could you make an example? Just so I understand
c

Császár Ákos

03/28/2024, 9:09 AM
using implementation(peerNpm("@react-native-async-storage/async-storage", "1.23.1")) instead of implementation(npm("@react-native-async-storage/async-storage", "1.23.1"))
e

Edoardo Luppi

03/28/2024, 9:09 AM
Is there any step by step guide for how to publish the library to npm
You can have a look at https://github.com/mpetuska/npm-publish Or, you can set up scripts/tasks and publish it on your own
👍 1
c

Császár Ákos

03/28/2024, 9:10 AM
it appears in the json of A like this. but not in B
e

Edoardo Luppi

03/28/2024, 9:10 AM
using implementation(peerNpm
That's something I never tried. I think this is a question for K/JS devs
If it doesn't work, maybe it's a missing functionality