npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

rn-unify

v1.0.0

Published

<!--toc:start-->

Downloads

52

Readme

rn-unify - A magical react-native dependency resolver 🪄

Description

Warning: This project only supports the yarn package manager at the moment. I may update this to support other package managers if there is enough interest.

rn-unify (React Native Unify) is a CLI tool to help identify conflicting react native packages within an iOS, Android, or RN project, when consuming multiple component libraries and attempt to resolve (unify) package versions.

Rationale

We developed this tool to help automate the resolutions of packages between our component library and our consuming native application which has implemented the react native framework.

Why not use a monorepo or workspaces?

There are many tools provide the ability to align dependencies within workspaces or using a monorepo structure. If this is a possibility, by all means, this project serves as a band-aid for teams in an in-between state or one without plans to fully build a RN application along side a RN component library.

There are times where a rewrite or re-scaffolding of a project does takes tremendous effort and planning. In the mean time there may be needs to export components and be consumable within certain portions of legacy or native application are still supported.

Isn't peer dependencies enough?

While teams and most projects often list peer dependencies within react-native projects I've experienced that without clear instruction and without some automation, the warning of mismatched or required versions can be locked, become outdated, or simply ignored.

The consuming team may forget to align version, someone might accidentally upgrade, or even nuke the lock files (yarn.lock, package-lock.json, etc).

This leads to mismatching versions of the RN dependency and underlying native module.

Examples

Below are a few examples of when you might want to consider this package.

  • Multiple RN teams/components consumed into a native shell application
  • Differing react native animation libraries and wrappers
  • Payment processors webview and/or iframe implementations
  • Geolocation services or libraries

Usage

This project is intended to be run as a post install script within the package.json.

{
  "scripts": {
    "postinstall": "rn-unify"
  }
}

How it works

The process to determine and identify RN dependencies which have native modules is straight-forward

  1. Identify dependencies using search and AST parsing for native modules
  2. Gather a list of dependencies which are duplicated via yarn list
  3. Identify the newest version of the duplicated modules
  4. Add or update a "resolutions" field within the package.json to enforce only one version of a dependency to install, repeat remaining duplicates found.
  5. Re-run yarn install to fix auto linking of modules to the RN or native application.

Caveats

This project has only been tested internally within my workplace. Please see the Licence within this repository to understand the limitations and risks of using this software.