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

lopm

v1.1.3

Published

CLI to Support Monorepo for local packages

Downloads

6

Readme

lopm

NPM

Monorepo supports local packages.

Why use lopm?

When using local packages in a monorepo, you might experience peer dependency problems because you use symbolic links.

But if you use lopm, hard links the files declared in the files field in the package.json

In other words, it has the same effect as a package installed by the npm registry.

It is similar to dependenciesMeta.*.injected of pnpm, but sync is difficult periodically at current pnpm and does not support watch mode.

Installation

  • pnpm
$ pnpm install lopm -D -w
$ pnpm lopm -v
  • yarn
$ yarn add lopm -D
$ yarn lopm -v
  • npm
$ npm install lopm --save-dev
$ npm lopm -v

Command

  • lopm list

    Displays a list of available local packages and local packages specified in the current project.

    • Example
    {
      "name": "foo",
      "dependencies": {
          "bar": "workspace:^1.0.0",
          "bar2": "workspace:^1.0.0"
      }
    }
  • lopm sync

    Hardlink the local packages.

    Example: node_modules capacity increases due to changes from pnpm symbolic links to hard links.

  • lopm run <command>

    The command entered in the parameter is executed.
    While command is running, lopm runs in watch mode.
    Monitor the files field in the local package package.json and when a change occurs, the sync command is executed after 3 seconds.

Getting Started

package.json setting for local package

Specify files field to export out

  • example
"name": "bar"
...
"files": [
    "dist",
    "package.json"
],
...

package.json setting for app

After pnpm install or yarn install, synchronization must be performed through the lopm sync command.
That is, it must be done immediately before build or development.

The lopm run <command> command is in watch mode. Hard link again if any changes to the local package occur while the command is running.

The command pnpm install or yarn install will restore it.

  • example
"name": "foo"
...
"scripts": {
    "build": "lopm sync && vite build",
    "dev": "lopm run vite"
},
...

The dependency field must specify the local package name.
Supports workspace, link and file protocols.

  • example
"name": "foo"
...
"dependencies": {
    "foo": "workspace:0.0.1",
    "foo2": "link:../../packages/foo",
    "foo3": "file:../../packages/foo",
},
...

How to use after sync

If you followed the example above well, you can use it inside the bar package as follows:

$ pnpm lopm sync
// This code in "bar" package
import { sum } from "foo";

Getting Started with Turborepo

Similar to the original Getting Started, except that there is a scripts field in package.json and a turbo.json file.

package.json setting for app

"name": "bar"
...
"scripts": {
    "sync": "lopm sync",    
    "build": "vite build",
},
...

package.json setting for root

"name": "monorepo-root"
...
"scripts": {
    "build": "turbo rub build --filter='./packages/bar'",
},
...

turbo.json

{
  "$schema": "https://turbo.build/schema.json",
  "pipeline": {
    "build": {
      "dependsOn": ["sync"]
    },
  }
}

Even if you set this much, Turbo will sync before the build!