Skip to content

Add bundler configuration (esbuild) for production builds #738

Description

@andi1984

Priority: HIGH

Problem

The extension currently ships raw TypeScript output instead of optimized bundles, which impacts:

  • Activation time: All dependencies loaded unbundled at runtime
  • Extension size: Currently 176KB but includes dependencies loaded separately
  • Performance: Slower startup compared to bundled extensions

Solution

Implement esbuild bundling (modern, faster alternative to webpack).

Implementation Steps

  1. Install esbuild:
npm install --save-dev esbuild
  1. Create esbuild.js:
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',
    outfile: 'dist/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);
});
  1. Update package.json:
{
  "main": "./dist/extension.js",
  "scripts": {
    "vscode:prepublish": "npm run package",
    "compile": "tsc -p tsconfig.json",
    "package": "node esbuild.js --production",
    "watch": "node esbuild.js --watch"
  }
}
  1. Update .vscodeignore:
src/**
tsconfig.json
out/**

Reference

VSCode Extension Bundling Guide

Expected Impact

  • Faster activation time
  • Smaller extension package size (~50KB bundled vs 176KB+ unbundled)
  • Better user experience

Priority

HIGH - Should be implemented before next release

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions