or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

index.md

index.mddocs/

0

# @pnpm/make-dedicated-lockfile

1

2

**⚠️ DEPRECATED: This package is deprecated. Please use the [pnpm deploy](https://pnpm.io/cli/deploy) command instead.**

3

4

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.

5

6

## Package Information

7

8

- **Package Name**: @pnpm/make-dedicated-lockfile

9

- **Package Type**: npm

10

- **Language**: TypeScript

11

- **Installation**: `npm install @pnpm/make-dedicated-lockfile`

12

- **Version**: 1000.0.23

13

- **License**: MIT

14

15

## Core Imports

16

17

```typescript

18

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

19

```

20

21

For CommonJS:

22

23

```javascript

24

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

25

```

26

27

## Basic Usage

28

29

### Programmatic Usage

30

31

```typescript

32

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

33

34

// Create dedicated lockfile for a specific project

35

await makeDedicatedLockfile(

36

"/path/to/workspace/root", // lockfileDir - where pnpm-lock.yaml exists

37

"/path/to/workspace/root/packages/my-project" // projectDir - target project

38

);

39

```

40

41

### CLI Usage

42

43

```bash

44

# Navigate to the project directory first

45

cd packages/my-project

46

47

# Run the CLI command

48

npx @pnpm/make-dedicated-lockfile

49

# or if installed globally

50

make-dedicated-lockfile

51

```

52

53

## Capabilities

54

55

### Dedicated Lockfile Creation

56

57

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

58

59

```typescript { .api }

60

/**

61

* Creates a dedicated lockfile for a specific project directory within a workspace

62

* @param lockfileDir - Directory containing the workspace lockfile (typically workspace root)

63

* @param projectDir - Target project directory to create dedicated lockfile for

64

* @throws Error if no lockfile found in lockfileDir

65

* @throws PnpmError if not in a workspace (CLI usage)

66

*/

67

function makeDedicatedLockfile(lockfileDir: string, projectDir: string): Promise<void>;

68

```

69

70

**Process Overview:**

71

72

1. **Reads the workspace lockfile** from `lockfileDir`

73

2. **Filters importers** to include only the target project and its subdirectories

74

3. **Removes linked dependencies** (workspace:* dependencies) from project snapshots

75

4. **Prunes unused packages** from the lockfile using `@pnpm/lockfile.pruner`

76

5. **Creates exportable manifest** and temporarily modifies package.json

77

6. **Installs dependencies** using `pnpm install` with dedicated lockfile settings

78

7. **Restores original manifest** after installation

79

80

**Side Effects:**

81

- Creates `pnpm-lock.yaml` in the target project directory

82

- Temporarily modifies `package.json` during installation process

83

- Manages `node_modules` directory reorganization during process

84

- Installs dependencies via `pnpm exec` with specific flags

85

86

**Error Conditions:**

87

- Throws `Error` with message "no lockfile found" if workspace lockfile doesn't exist

88

- Throws `PnpmError` with code 'WORKSPACE_NOT_FOUND' if project is not in a workspace (CLI usage)

89

90

**Installation Flags Used:**

91

- `--frozen-lockfile`: Use exact versions from lockfile

92

- `--lockfile-dir=.`: Use current directory as lockfile location

93

- `--fix-lockfile`: Fix any lockfile inconsistencies

94

- `--filter=.`: Install only current project dependencies

95

- `--no-link-workspace-packages`: Don't link workspace packages

96

- `--config.dedupe-peer-dependents=false`: Disable peer dependency deduplication

97

98

## Types

99

100

```typescript { .api }

101

// Re-exported from @pnpm/types

102

type ProjectId = string & { __brand: 'ProjectId' };

103

104

// Re-exported from @pnpm/types

105

type DependenciesField = 'optionalDependencies' | 'dependencies' | 'devDependencies';

106

107

// Re-exported from @pnpm/types

108

const DEPENDENCIES_FIELDS: DependenciesField[] = [

109

'optionalDependencies',

110

'dependencies',

111

'devDependencies',

112

];

113

114

// Re-exported from @pnpm/lockfile.types

115

type ResolvedDependencies = Record<string, string>;

116

117

// Re-exported from @pnpm/lockfile.types

118

interface ProjectSnapshot {

119

specifiers: ResolvedDependencies;

120

dependencies?: ResolvedDependencies;

121

devDependencies?: ResolvedDependencies;

122

optionalDependencies?: ResolvedDependencies;

123

dependenciesMeta?: DependenciesMeta;

124

publishDirectory?: string;

125

}

126

127

// Re-exported from @pnpm/types

128

interface DependenciesMeta {

129

[depName: string]: {

130

injected?: boolean;

131

node?: string;

132

patch?: string;

133

};

134

}

135

136

// Re-exported from @pnpm/error

137

class PnpmError extends Error {

138

constructor(

139

code: string,

140

message: string,

141

opts?: {

142

attempts?: number;

143

hint?: string;

144

prefix?: string;

145

}

146

);

147

code: string;

148

hint?: string;

149

attempts?: number;

150

prefix?: string;

151

pkgsStack?: Array<{ id: string; name: string; version: string }>;

152

}

153

```

154

155

## CLI Architecture

156

157

The CLI entry point automatically determines the required directories:

158

159

- **Project Directory**: Uses `process.cwd()` (current working directory)

160

- **Lockfile Directory**: Uses `@pnpm/find-workspace-dir` to locate workspace root

161

- **Validation**: Ensures the current directory is within a pnpm workspace

162

163

```bash

164

# The CLI workflow:

165

# 1. Get current directory as project directory

166

# 2. Find workspace root containing pnpm-lock.yaml

167

# 3. Call makeDedicatedLockfile with both paths

168

# 4. Handle workspace detection errors

169

```

170

171

## Migration Guide

172

173

**This package is deprecated.** Use `pnpm deploy` instead:

174

175

```bash

176

# Instead of:

177

cd packages/my-project

178

make-dedicated-lockfile

179

180

# Use:

181

pnpm deploy packages/my-project /output/directory

182

```

183

184

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.