version relationship between package.json dependencies and build.gradle dependencies? - react-native

I'm trying to understand the version relationship between package.json dependencies and build.gradle dependencies. For example, I have the following dependency configured in package.json:
"firebase-auth": "^0.1.2"
I have the corresponding dependency configured in my build.gradle:
implementation "com.google.firebase:firebase-auth:19.1.0"
I think I had originally installed the firebase-auth package and encountered an error which led me down a path where I googled and determined that the build.gradle dependency above was required. Based on some more googling, I got lucky with the version 19.1.0 but I really don't know how version dependencies between package.json packages and build.gradle dependency references are correlated. Can someone here provide some insight on this?

The difference between package.json and gradle is the difference between storage.
package.json is literally a file for js, and the gradle is like a repository made to protect Maven's shortcomings and Ant's.
The relationship between the two is defined when making a module through npm, build.gradle has content related to building libraries (such as SDK version), you can find the version here.
The version listed in package.json is modified each time an update is made on the github, and depending on the module in the dependency, the link will install the corresponding android and iOS modules for the version of dependencies.

Related

How to count all npm packages used in the monorepo project?

The current project is an older monorepo project, which uses yarn to manage dependency packages, and many subprojects use phantom dependencies. At present, the project is gradually migrating to pnpm, but there is a problem that each subproject uses many npm packages that are not in its own package.json. However, there are dozens of such sub-projects, and manual statistics are a very heavy workload. Is there any good tool that can help me find out all the npm packages that each sub-project depends on through text analysis? In this way, I can find all missing dependencies by comparing the subproject's package.json and add them to the subproject's package.json.
There is currently no good idea to solve this problem. In the search tool, if there is no such tool, consider using python to write a new one.

Inherit or share package.json dependencies

We got couple of different projects that are using main dependencies like React and TypeScript packages. Each of those projects(maintained by different dev team) is using diferent version of React and TypeScript - question here:
Is there any clever way to share/inherit/force to use specific version of main dependencies across all those projects? i.e.:
Yes, this is definitely possible. Simplest way is to create an npm module with the required common dependencies in a package.json file and publish this into your repo. Then in the projects, require that published npm module as a dependency. The projects can than further require other dependencies and override any from the parent if needed.

How does signalr.js find its associated dependencies from inside my project?

When I run npm install #aspnet/signalr in my project directory, over 20 modules are installed into node_modules. However, in the actuall project, for example on a webpage, only signalr.js needs to be referenced. How does signalr.js reference its dependencies?
One additional example I find confusing is that when bundling, only signalr.js needs to be put into bundleconfig.json for SignalR to work in the project. Are the other dependencies actually needed?

Do I need dependencies after webpack bundled my code

When webpack bundles the node_modules my project needs, do I still need dependencies or could I list everything to devDependencies?
I have created a react component library and have published it to npm. The only peerDependencies I've listed are react and react-dom, because, well, you'll need them when using my library. At first I set up my project like I normally would, stuff like babel, eslint, css-loader listed in the devDependencies, and stuff I actually use in my code, like prop-types, classnames, react-slick, listed as dependencies.
I then use webpack with babel to create one main.js with the module imports included
When someone on my team tries to use my library npm will give some errors 'Peer dependencies unmet' with stuff like webpack, eslint & #babel/core. So I'm guessing these are some peer dependencies from my dependencies? (that's a little side question)
That got me thinking, do I even need dependencies at all? Since webpack bundles everything and I only use my main.js, shouldn't everything be a devDependency?
Dependencies are those that your project needs to run, like a library that provides functions that you call from your code.
Dev dependencies are dependencies you only need during development or releasing, like compilers that take your code and compile it into javascript, test frameworks or documentation generators.

Intellij IDEA With Multiple Gradle Projects

I am working on two Gradle projects. One of these projects is a supporting library that will be used by other projects in the future so project A depends on project B but not as a 'multi module project'. The dependency is to be resolved through the artifact repo so project a declares it as a compile dependency using it's maven coordinates.
My problem is when working on these two projects in IntelliJ changes to project B aren't made available to project A until I install it (using the Gradle Maven plugin) in my local repo. This is kind of annoying and slows down my workflow. Is there a way to get IntelliJ to automatically update the dependency internally?
This is supported in the latest versions of Gradle and IntelliJ. It is known as a Composite Build.
Composite builds can be declared in the project's settings.gradle file as follows:
includeBuild '../my-app'
or by using the --include-build command line argument:
$ gradle --include-build ../my-utils run
Take a look at the Composite Builds with Gradle and IntelliJ IDEA Webinar for instructions on how to configure the integration.
In IDEA 2017 you can right-click on the gradle module and use Composite Build Configuration to link the current module to one or more gradle module already opened in the current workspace.