Hi! I have 2 libraries. A and B B depends on A 1. ...
# javascript
c
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
@Ilya Goncharov [JB] could we do something like this?
c
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
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
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
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
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
peer dependencies
Could you make an example? Just so I understand
c
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
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
it appears in the json of A like this. but not in B
e
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