vscode extension package update

vscode extension package update

By medeb | personalblog | 19 Apr 2025


1. Modify package.json:
Open the package.json file.
Add a commands section to define your command:
JSON
{
 "name": "auto-import-shared-module",
 "displayName": "Auto Import Shared Module",
 "description": "Auto imports a shared module into all relevant files.",
 "version": "0.0.1",
 "engines": {
 "vscode": "^1.75.0"
 },
 "categories": [
 "Other"
 ],
 "activationEvents": [
 "onCommand:extension.autoImportSharedModule"
 ],
 "main": "./out/extension.js",
 "contributes": {
 "commands": [
 {
 "command": "extension.autoImportSharedModule",
 "title": "Auto Import Shared Module"
 }
 ]
 },
 "scripts": {
 "vscode:prepublish": "npm run compile",
 "compile": "tsc -p ./",
 "watch": "tsc -watch -p ./",
 "pretest": "npm run compile && npm run lint",
 "lint": "eslint src --ext ts",
 "test": "node ./out/test/runTest.js"
 },
 "devDependencies": {
 "@types/node": "18.x",
 "@types/vscode": "^1.75.0",
 "@typescript-eslint/eslint-plugin": "^5.27.0",
 "@typescript-eslint/parser": "^5.27.0",
 "eslint": "^8.16.0",
 "typescript": "^4.7.2",
 "@vscode/test-electron": "^2.1.3"
 }
}
2. Compile and Run the Extension:
Open the integrated terminal in VS Code (View > Terminal).
Run npm install to install dependencies.
Run npm run compile to compile the typescript code into javascript.
Press F5 to start debugging the extension. This will open a new VS Code
window (the Extension Development Host).
3. Test the Extension:
In the Extension Development Host window, open a project that contains
TypeScript files.
Open the command palette (Ctrl+Shift+P or Cmd+Shift+P).
Type "Auto Import Shared Module" and select your command.
The extension should run, and you should see the import statements added
to your files.

5c370356982f0e79f71b09a4b0bf7d3ef3a37990b6c8cfc32c819cf5a3fdb80e.png

How do you rate this article?

1



personalblog
personalblog

My daily experience in crypto world

Publish0x

Send a $0.01 microtip in crypto to the author, and earn yourself as you read!

20% to author / 80% to me.
We pay the tips from our rewards pool.