diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 64e0f9c..7e493d4 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -17,9 +17,9 @@ jobs: - run: | bun install - bun run vsce package - echo "filepath=$(ls *.vsix)" >> $GITHUB_ENV - echo "version=$(ls *.vsix | grep -oE '\d+\.\d+\.\d+')" >> $GITHUB_ENV + bun run build:vsix + echo "filepath=$(ls dist/*.vsix)" >> $GITHUB_ENV + echo "version=$(ls dist/*.vsix | grep -oE '\d+\.\d+\.\d+')" >> $GITHUB_ENV - env: VSCE_PAT: ${{ secrets.VSCE_PAT }} diff --git a/.vscode/launch.json b/.vscode/launch.json index 3f4ab1a..bfee349 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -8,8 +8,9 @@ "args": [ "${workspaceFolder}/..", "--disable-extensions", - "--extensionDevelopmentPath=${workspaceFolder}" - ] + "--extensionDevelopmentPath=${workspaceFolder}/dist" + ], + "preLaunchTask": "build extension" } ] } diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..4ea388d --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,10 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build extension", + "type": "shell", + "command": "bun run build" + } + ] +} diff --git a/bun.lockb b/bun.lockb index 2f73dad..f9e6799 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index 6dd3d61..e6d38e8 100644 --- a/package.json +++ b/package.json @@ -30,6 +30,10 @@ "minimal", "theme" ], + "main": "src/extension.js", + "activationEvents": [ + "onStartupFinished" + ], "contributes": { "iconThemes": [ { @@ -45,13 +49,20 @@ ] }, "scripts": { + "build": "bun run clean && bun run scripts/build.ts", + "build:vsix": "bun run build --production", + "clean": "git clean -xdf dist", "prepare": "husky" }, "devDependencies": { "@commitlint/cli": "^19", "@commitlint/config-conventional": "^19", + "@tsconfig/bun": "^1.0.7", + "@tsconfig/strictest": "^2.0.5", + "@types/bun": "^1.1.6", "@types/vscode": "^1.87", - "@vscode/vsce": "^2", + "@vscode/vsce": "^2.25.0", + "esbuild": "^0.23.0", "husky": "^9" }, "commitlint": { diff --git a/scripts/build.ts b/scripts/build.ts new file mode 100644 index 0000000..f4ef6b5 --- /dev/null +++ b/scripts/build.ts @@ -0,0 +1,36 @@ +import { build } from "esbuild"; + +const isProduction = process.argv.includes("--production"); + +// see: https://code.visualstudio.com/api/working-with-extensions/bundling-extension#using-esbuild +await build({ + entryPoints: [ + "static/**/*", + "theme/**/*", + "src/extension.ts", + "package.json", + "package.nls.json", + "CHANGELOG.md", + "LICENSE.md", + "README.md", + ], + loader: { + ".json": "copy", + ".md": "copy", + ".png": "copy", + ".svg": "copy", + }, + outdir: "dist", + external: ["vscode"], + format: "cjs", + platform: "node", + bundle: true, + sourcesContent: false, + minify: isProduction, + sourcemap: !isProduction, +}); + +if (isProduction) { + const { createVSIX } = await import("@vscode/vsce"); + await createVSIX({ cwd: "dist" }); +} diff --git a/src/extension.ts b/src/extension.ts new file mode 100644 index 0000000..3497355 --- /dev/null +++ b/src/extension.ts @@ -0,0 +1,5 @@ +import * as vscode from "vscode"; + +export function activate(context: vscode.ExtensionContext) { + console.log(`[${context.extension.id}] active`); +} diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..22949dc --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": ["@tsconfig/bun", "@tsconfig/strictest"], + "include": ["scripts", "src"] +}