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

link-with

v0.4.0

Published

Links the local package and install its dependencies.

Downloads

80

Readme

Why

Unfortunately, build-in link command in npm and yarn (v1) will link your package without installing the transitive dependencies.

This tool will properly install the linked package with all its dependencies and sync any future changes while it runs.

Any changes to package.json in linked package will cause the reinstall, so your project will always be in sync.

Installation

$ yarn global add link-with

Usage

Just run link-with in your project and select the packages, which you want to link.

Linker needs to be configured first by running link-with -c

How it works

Tool is watching package.json file in every linked package. On a start or when a change is detected, the following will happen:

  1. Copy package's source into temporary folder. Omit any node_modules and git directories.
  2. Add/update resolutions property in project's package.json to point to temporary folder.
  3. Run yarn install (will remove temporary folder).
  4. Revert project's package.json.
  5. Watch & sync package's files.

This process makes sure that you always have all necessary dependencies and changes in place.

Integration with dev tools

Unfortunately, not all build tools are aware that files in node_modules could change. You can quite often find that node_modules are excluded from watch process to save a limited system resources.

As we are not able to detect this, you need to make sure that your build tool is watching the linked packages.

To know which packages are linked right now, you can use a getLinkedPackages function which will return the list of packages and their paths:

import { getLinkedPackages } from 'link-with';

/**
 * RESULT:
 *   [
 *     { name: 'my-dependency', root: '/Users/deftomat/dev/my-dependency' }
 *   ]
 */
const linked = getLinkedPackages();

You can easily use this helper function in your webpack config to know which packages must be included in watch process.

TypeScript tip

As a linked packages will probably contains JavaScript files compiled from TypeScript, your build tool will watch JS files for changes. The problem arise when you change the type definition in a linked package without changing the code itself. As you probably figured out, the TypeScript compiler will ignore this change because from its point of view, nothing changed.

To fix this issue, we recommend to always emit source maps together with JavaScript code to let TypeScript compiler know that something changed.

Current limitations

  • We only support yarn as this tool is using resolutions property in package.json.
  • When a linked package's name change, the tool must be restarted.
  • Package which will be linked must be specified in dependencies. This limitation provides us a way how to support monorepos as we don't know which package in your monorepo should depends on linked package. If you need to link a completely new package, then add it into package.json as file:/path/to/package dependency first.