You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+67Lines changed: 67 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -140,6 +140,7 @@ If you prefer not to use the devcontainer, you can set up the extension locally:
140
140
### Prerequisites
141
141
142
142
-[Node.js](https://nodejs.org/) 18.x or 20.x
143
+
-[npm](https://www.npmjs.com/) (comes with Node.js)
143
144
-[Visual Studio Code](https://code.visualstudio.com/)
144
145
-[Git](https://git-scm.com/)
145
146
@@ -158,6 +159,8 @@ If you prefer not to use the devcontainer, you can set up the extension locally:
158
159
npm install
159
160
```
160
161
162
+
**Note:** The project uses `package-lock.json` for reproducible builds. The `.npmrc` file ensures consistent behavior across different npm versions and environments. CI/CD workflows use `npm ci` to ensure exact dependency versions are installed.
163
+
161
164
3.**Build the extension:**
162
165
163
166
```bash
@@ -239,6 +242,70 @@ npx vsce package
239
242
-`npm test` - Run tests (requires VS Code)
240
243
-`npm run watch-tests` - Run tests in watch mode
241
244
245
+
## NPM and Dependency Management
246
+
247
+
The project uses **`package-lock.json`** for reproducible builds and dependency consistency across all environments.
-**`package-lock.json`**: Lockfile that pins exact dependency versions (committed to the repository)
253
+
-**`package.json`**: Defines project dependencies and scripts
254
+
255
+
### Installation Commands
256
+
257
+
**RECOMMENDED for day-to-day development:**
258
+
259
+
-**`npm ci`**: Clean install from lockfile
260
+
- Requires `package-lock.json` to exist
261
+
- Installs exact versions from the lockfile (no modifications)
262
+
- Deletes `node_modules` before installing
263
+
-**Use this after pulling changes** to avoid lockfile churn
264
+
-**Used in all CI/CD workflows** for reproducible builds
265
+
- Faster and more reliable than `npm install`
266
+
267
+
**Only when adding/updating dependencies:**
268
+
269
+
-**`npm install`**: Install/update dependencies
270
+
- Respects `package-lock.json` and may update it
271
+
- Use when adding new dependencies: `npm install <package>`
272
+
- Use when updating dependencies: `npm install <package>@latest`
273
+
-**After adding dependencies, commit both `package.json` and `package-lock.json`**
274
+
275
+
### Best Practices
276
+
277
+
1.**Use `npm ci` for routine development** - This prevents accidental lockfile changes and ensures you have the exact dependency versions
278
+
2.**Only use `npm install` when intentionally changing dependencies** - This makes dependency updates explicit and trackable
279
+
3.**Always commit both files together** - When you modify dependencies, commit both `package.json` and `package-lock.json` in the same commit
280
+
4.**Don't manually edit `package-lock.json`** - Let npm manage it automatically
281
+
282
+
### Why We Use package-lock.json
283
+
284
+
1.**Reproducible Builds**: Ensures all developers and CI/CD get identical dependency versions
285
+
2.**Consistency**: Prevents "works on my machine" issues caused by different dependency versions
286
+
3.**Security**: Locks down transitive dependencies to prevent supply chain attacks
287
+
4.**Performance**: CI/CD can cache dependencies more effectively with a lockfile
288
+
289
+
### About Peer Dependencies and "peer": true
290
+
291
+
Different npm versions (7+) may add or remove `"peer": true` properties in `package-lock.json` when running `npm install`. This is expected behavior for peer dependencies that aren't satisfied.
292
+
293
+
Some dependencies (like `@vscode/webview-ui-toolkit`) declare peer dependencies (e.g., `react`) that we don't use directly. You may see entries like this in `package-lock.json`:
294
+
295
+
```json
296
+
"node_modules/react": {
297
+
"version": "19.2.3",
298
+
"peer": true,
299
+
...
300
+
}
301
+
```
302
+
303
+
**This is normal and doesn't affect functionality.** To avoid lockfile churn from these changes:
304
+
305
+
-**Use `npm ci` for routine development** (doesn't modify the lockfile)
306
+
- Only use `npm install` when you're intentionally adding or updating dependencies
307
+
- If you accidentally modify the lockfile, run `git checkout package-lock.json` to restore it
0 commit comments