Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 17 additions & 15 deletions vscode-extension/.vscodeignore
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
.vscode/**
**/*.ts
**/*.map
.gitignore
**/tsconfig.json
**/tsconfig.base.json
contributing.md
.travis.yml
client/node_modules/**
!client/node_modules/vscode-jsonrpc/**
!client/node_modules/vscode-languageclient/**
!client/node_modules/vscode-languageserver-protocol/**
!client/node_modules/vscode-languageserver-types/**
!client/node_modules/{minimatch,brace-expansion,concat-map,balanced-match}/**
!client/node_modules/{semver,lru-cache,yallist}/**
.vscode/**
.vscode-test/**
.claude/**
node_modules/**
src/**
scripts/**
docs/**
testFixture/**
.gitignore
**/*.ts
**/*.map
**/*.tsbuildinfo
**/tsconfig.json
**/tsconfig.base.json
eslint.config.mjs
esbuild.js
*.vsix
25 changes: 25 additions & 0 deletions vscode-extension/docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,28 @@
- Press ▷ to run the launch config (F5).
- In the [Extension Development Host](https://code.visualstudio.com/api/get-started/your-first-extension#:~:text=Then%2C%20inside%20the%20editor%2C%20press%20F5.%20This%20will%20compile%20and%20run%20the%20extension%20in%20a%20new%20Extension%20Development%20Host%20window.) instance of VSCode, open a Terragrunt HCL file.
- See the [capabilities documentation](../../docs/server-capabilities.md) for what the language server can do.

## Packaging

The VSIX is built by `@vscode/vsce`, which runs the `vscode:prepublish` script from `package.json` before it assembles the archive. Our prepublish pipeline does two things:

1. `npm run bundle` — runs `esbuild.js` with `--production`, which bundles `src/extension.ts` (and its `vscode-languageclient` dependency) into a single minified `out/extension.js`. The `vscode` module is marked external because it is provided by the VS Code runtime.
2. `./scripts/package.sh` — cross-compiles the `terragrunt-ls` Go binary into `out/terragrunt-ls` (or `out/terragrunt-ls.exe`) using the `GOOS`/`GOARCH` env vars passed by the release matrix.

`vsce` then zips everything not excluded by `.vscodeignore` into the `.vsix`. Only the bundled extension, the Go binary, and a handful of static assets (`package.json`, grammar, icon, README, LICENSE) end up in the package — no `node_modules`, no TypeScript sources.

### Commands

- `npm run bundle` — one-shot production bundle (used by `vscode:prepublish`).
- `npm run bundle:watch` — rebundle on change; useful if you want to test the bundled output locally.
- `npm run compile` / `npm run watch` — plain `tsc -b` build for local F5 debugging (the `.vscode/launch.json` pre-launch task runs `watch`). These do *not* bundle; they produce the same `out/extension.js` path but rely on `node_modules` at runtime, which is fine inside the Extension Development Host.

### Producing a VSIX locally

From `vscode-extension/`:

```sh
npx @vscode/vsce package --target <target>
```

where `<target>` is one of `linux-x64`, `linux-arm64`, `darwin-x64`, `darwin-arm64`, `win32-x64`, `win32-arm64` (these must match the `GOOS`/`GOARCH` combinations expected by `scripts/package.sh`). The release workflow at `.github/workflows/release.yml` runs the same command across all six targets.
31 changes: 31 additions & 0 deletions vscode-extension/esbuild.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
const esbuild = require('esbuild');

const production = process.argv.includes('--production');
const watch = process.argv.includes('--watch');

async function main() {
const ctx = await esbuild.context({
entryPoints: ['src/extension.ts'],
bundle: true,
format: 'cjs',
minify: production,
sourcemap: !production,
sourcesContent: false,
platform: 'node',
target: 'node20',
outfile: 'out/extension.js',
external: ['vscode'],
logLevel: 'info',
});
if (watch) {
await ctx.watch();
} else {
await ctx.rebuild();
await ctx.dispose();
}
}

main().catch((e) => {
console.error(e);
process.exit(1);
});
Loading
Loading