From 8167430f2dc2dbaf35629192883c8e998f40797c Mon Sep 17 00:00:00 2001 From: Tyler Chan Date: Sat, 24 Jan 2026 15:24:30 +0800 Subject: [PATCH] feat: add initial VSCode extension build configuration with esbuild; create .vscodeignore for excluding unnecessary files; update package.json for new build scripts and repository information. --- editors/vscode/.vscodeignore | 9 ++++++ editors/vscode/esbuild.js | 56 ++++++++++++++++++++++++++++++++++++ editors/vscode/package.json | 20 ++++++++----- 3 files changed, 78 insertions(+), 7 deletions(-) create mode 100644 editors/vscode/.vscodeignore create mode 100644 editors/vscode/esbuild.js diff --git a/editors/vscode/.vscodeignore b/editors/vscode/.vscodeignore new file mode 100644 index 0000000..be080be --- /dev/null +++ b/editors/vscode/.vscodeignore @@ -0,0 +1,9 @@ +.vscode/** +.vscode-test/** +src/** +.gitignore +.eslintrc.json +tsconfig.json +esbuild.js +**/*.map +node_modules/** diff --git a/editors/vscode/esbuild.js b/editors/vscode/esbuild.js new file mode 100644 index 0000000..2abea92 --- /dev/null +++ b/editors/vscode/esbuild.js @@ -0,0 +1,56 @@ +const esbuild = require("esbuild"); + +const production = process.argv.includes('--production'); +const watch = process.argv.includes('--watch'); + +/** + * @type {import('esbuild').Plugin} + */ +const esbuildProblemMatcherPlugin = { + name: 'esbuild-problem-matcher', + + setup(build) { + build.onStart(() => { + console.log('[watch] build started'); + }); + build.onEnd((result) => { + result.errors.forEach(({ text, location }) => { + console.error(`✘ [ERROR] ${text}`); + console.error(` ${location.file}:${location.line}:${location.column}:`); + }); + console.log('[watch] build finished'); + }); + }, +}; + +async function main() { + const ctx = await esbuild.context({ + entryPoints: [ + 'src/extension.ts' + ], + bundle: true, + format: 'cjs', + minify: production, + sourcemap: !production, + sourcesContent: false, + platform: 'node', + outfile: 'dist/extension.js', + external: ['vscode'], + logLevel: 'silent', + plugins: [ + esbuildProblemMatcherPlugin, + ], + }); + + if (watch) { + await ctx.watch(); + } else { + await ctx.rebuild(); + await ctx.dispose(); + } +} + +main().catch(e => { + console.error(e); + process.exit(1); +}); diff --git a/editors/vscode/package.json b/editors/vscode/package.json index 625c99d..28382ee 100644 --- a/editors/vscode/package.json +++ b/editors/vscode/package.json @@ -4,6 +4,10 @@ "description": "Graph-based structured code navigation for Java", "version": "0.1.0", "publisher": "naviscope", + "repository": { + "type": "git", + "url": "https://github.com/biuld/naviscope.git" + }, "engines": { "vscode": "^1.75.0" }, @@ -13,15 +17,15 @@ "activationEvents": [ "onLanguage:java" ], - "main": "./out/extension.js", + "main": "./dist/extension.js", "scripts": { - "vscode:prepublish": "npm run compile", - "compile": "tsc -p ./", - "watch": "tsc -watch -p ./", - "package": "vsce package", - "pretest": "npm run compile && npm run lint", + "vscode:prepublish": "npm run package", + "compile": "npm run check-types && npm run lint && node esbuild.js", + "watch": "npm run check-types && npm run lint && node esbuild.js --watch", + "package": "npm run check-types && npm run lint && node esbuild.js --production", + "check-types": "tsc --noEmit", "lint": "eslint src --ext ts", - "test": "node ./out/test/runTest.js" + "test": "npm run compile && node ./dist/test/runTest.js" }, "devDependencies": { "@types/node": "16.x", @@ -29,7 +33,9 @@ "@typescript-eslint/eslint-plugin": "^5.53.0", "@typescript-eslint/parser": "^5.53.0", "@vscode/vsce": "^2.19.0", + "esbuild": "^0.24.2", "eslint": "^8.34.0", + "glob": "^10.3.10", "typescript": "^4.9.5" }, "dependencies": {