CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-pnpm--make-dedicated-lockfile

Creates dedicated lockfiles for specific workspace projects within a pnpm monorepo

Pending

Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

Overview
Eval results
Files

@pnpm/make-dedicated-lockfile

⚠️ DEPRECATED: This package is deprecated. Please use the pnpm deploy command instead.

Creates dedicated lockfiles for specific workspace projects within a pnpm monorepo. This package extracts dependency information from the main workspace lockfile and generates a focused lockfile containing only the dependencies relevant to a particular project and its subdirectories.

Package Information

  • Package Name: @pnpm/make-dedicated-lockfile
  • Package Type: npm
  • Language: TypeScript
  • Installation: npm install @pnpm/make-dedicated-lockfile
  • Version: 1000.0.23
  • License: MIT

Core Imports

import { makeDedicatedLockfile } from "@pnpm/make-dedicated-lockfile";

For CommonJS:

const { makeDedicatedLockfile } = require("@pnpm/make-dedicated-lockfile");

Basic Usage

Programmatic Usage

import { makeDedicatedLockfile } from "@pnpm/make-dedicated-lockfile";

// Create dedicated lockfile for a specific project
await makeDedicatedLockfile(
  "/path/to/workspace/root",    // lockfileDir - where pnpm-lock.yaml exists
  "/path/to/workspace/root/packages/my-project"  // projectDir - target project
);

CLI Usage

# Navigate to the project directory first
cd packages/my-project

# Run the CLI command
npx @pnpm/make-dedicated-lockfile
# or if installed globally
make-dedicated-lockfile

Capabilities

Dedicated Lockfile Creation

Creates a dedicated lockfile for a specific project directory within a workspace, extracting only the dependencies relevant to that project.

/**
 * Creates a dedicated lockfile for a specific project directory within a workspace
 * @param lockfileDir - Directory containing the workspace lockfile (typically workspace root)
 * @param projectDir - Target project directory to create dedicated lockfile for
 * @throws Error if no lockfile found in lockfileDir
 * @throws PnpmError if not in a workspace (CLI usage)
 */
function makeDedicatedLockfile(lockfileDir: string, projectDir: string): Promise<void>;

Process Overview:

  1. Reads the workspace lockfile from lockfileDir
  2. Filters importers to include only the target project and its subdirectories
  3. Removes linked dependencies (workspace:* dependencies) from project snapshots
  4. Prunes unused packages from the lockfile using @pnpm/lockfile.pruner
  5. Creates exportable manifest and temporarily modifies package.json
  6. Installs dependencies using pnpm install with dedicated lockfile settings
  7. Restores original manifest after installation

Side Effects:

  • Creates pnpm-lock.yaml in the target project directory
  • Temporarily modifies package.json during installation process
  • Manages node_modules directory reorganization during process
  • Installs dependencies via pnpm exec with specific flags

Error Conditions:

  • Throws Error with message "no lockfile found" if workspace lockfile doesn't exist
  • Throws PnpmError with code 'WORKSPACE_NOT_FOUND' if project is not in a workspace (CLI usage)

Installation Flags Used:

  • --frozen-lockfile: Use exact versions from lockfile
  • --lockfile-dir=.: Use current directory as lockfile location
  • --fix-lockfile: Fix any lockfile inconsistencies
  • --filter=.: Install only current project dependencies
  • --no-link-workspace-packages: Don't link workspace packages
  • --config.dedupe-peer-dependents=false: Disable peer dependency deduplication

Types

// Re-exported from @pnpm/types  
type ProjectId = string & { __brand: 'ProjectId' };

// Re-exported from @pnpm/types
type DependenciesField = 'optionalDependencies' | 'dependencies' | 'devDependencies';

// Re-exported from @pnpm/types
const DEPENDENCIES_FIELDS: DependenciesField[] = [
  'optionalDependencies',
  'dependencies', 
  'devDependencies',
];

// Re-exported from @pnpm/lockfile.types
type ResolvedDependencies = Record<string, string>;

// Re-exported from @pnpm/lockfile.types
interface ProjectSnapshot {
  specifiers: ResolvedDependencies;
  dependencies?: ResolvedDependencies;
  devDependencies?: ResolvedDependencies;
  optionalDependencies?: ResolvedDependencies;
  dependenciesMeta?: DependenciesMeta;
  publishDirectory?: string;
}

// Re-exported from @pnpm/types
interface DependenciesMeta {
  [depName: string]: {
    injected?: boolean;
    node?: string;
    patch?: string;
  };
}

// Re-exported from @pnpm/error
class PnpmError extends Error {
  constructor(
    code: string,
    message: string,
    opts?: {
      attempts?: number;
      hint?: string;
      prefix?: string;
    }
  );
  code: string;
  hint?: string;
  attempts?: number;
  prefix?: string;
  pkgsStack?: Array<{ id: string; name: string; version: string }>;
}

CLI Architecture

The CLI entry point automatically determines the required directories:

  • Project Directory: Uses process.cwd() (current working directory)
  • Lockfile Directory: Uses @pnpm/find-workspace-dir to locate workspace root
  • Validation: Ensures the current directory is within a pnpm workspace
# The CLI workflow:
# 1. Get current directory as project directory
# 2. Find workspace root containing pnpm-lock.yaml
# 3. Call makeDedicatedLockfile with both paths
# 4. Handle workspace detection errors

Migration Guide

This package is deprecated. Use pnpm deploy instead:

# Instead of:
cd packages/my-project
make-dedicated-lockfile

# Use:
pnpm deploy packages/my-project /output/directory

The pnpm deploy command provides similar functionality with better integration into the pnpm ecosystem and additional features like copying project files and handling deployment scenarios.

Install with Tessl CLI

npx tessl i tessl/npm-pnpm--make-dedicated-lockfile
Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/@pnpm/make-dedicated-lockfile@1000.0.x
Publish Source
CLI
Badge
tessl/npm-pnpm--make-dedicated-lockfile badge