跳转到内容

Building

This guide covers how to build and package Feima Copilot for distribution.

Feima Copilot uses esbuild for fast compilation:

  • TypeScriptJavaScript
  • Source maps included
  • Minified for production
  • VSIX packaging for Marketplace
Terminal window
# Compile with source maps
npm run compile
Terminal window
# Watch for changes and rebuild
npm run watch
Terminal window
# Clean and build for production
npm run build
Terminal window
# Remove dist/ and docs-dist/
npm run clean

The build configuration is in .esbuild.ts:

import { build } from 'esbuild';
const options = {
entryPoints: ['src/extension.ts'],
bundle: true,
outfile: 'dist/extension.js',
external: ['vscode'],
format: 'cjs',
platform: 'node',
sourcemap: true,
minify: process.env.NODE_ENV === 'production'
};
build(options);
Terminal window
# Create .vsix file
npm run package

This creates feima-copilot-llms-extension.vsix in the project root.

Terminal window
# Update version in package.json first
npm version patch # or minor, major
# Then package
npm run package
Terminal window
# Update package.json version
npm version <patch|minor|major>
# Examples:
npm version patch # 0.1.0 → 0.1.1
npm version minor # 0.1.0 → 0.2.0
npm version major # 0.1.0 → 1.0.0

Edit CHANGELOG.md:

## [0.1.1] - 2024-02-23
### Added
- New feature description
### Fixed
- Bug fix description
### Changed
- Change description
Terminal window
# Run all tests
npm test
# Check coverage
npm run test:coverage
Terminal window
# Clean build
npm run clean
# Production build
npm run build
# Create package
npm run package
Terminal window
# List contents of VSIX
unzip -l feima-copilot-llms-extension.vsix
# Or inspect with vsce
vsce ls feima-copilot-llms-extension.vsix
Terminal window
# Publish to VS Code Marketplace
vsce publish
# Or publish specific version
vsce publish 0.1.1

Before publishing, verify:

  • Version updated in package.json
  • Changelog updated
  • All tests pass
  • No linting errors
  • Build successful
  • VSIX package verified
  • README updated if needed
  • Documentation updated if needed
  • Release notes prepared
Terminal window
# Install from command line
code --install-extension feima-copilot-llms-extension.vsix
# Or via VS Code:
# 1. Extensions → ... (menu)
# 2. Install from VSIX...
# 3. Select the .vsix file
Terminal window
# Uninstall from command line
code --uninstall-extension feima-copilot-llms-extension
# Or via VS Code:
# 1. Extensions → Find Feima Copilot
# 2. Click gear icon → Uninstall

Feima Copilot is published as two extensions:

Terminal window
# Publish to Open VSX (for VSCodium users in China)
ovsx publish
Terminal window
# Publish to VS Code Marketplace
vsce publish

The project uses GitHub Actions for automated builds:

name: Build
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
- run: npm ci
- run: npm run build
- run: npm test
- run: npm run package
- uses: actions/upload-artifact@v3
with:
name: extension-vsix
path: '*.vsix'
name: Release
on:
push:
tags:
- 'v*'
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
- run: npm ci
- run: npm run build
- run: npm run package
- name: Publish to Marketplace
run: vsce publish
env:
VSCE_PAT: ${{ secrets.VSCE_PAT }}

For automated publishing, configure these secrets:

SecretPurpose
VSCE_PATVS Code Marketplace personal access token
OVSX_PATOpen VSX personal access token

Problem: esbuild fails to compile

Solution:

Terminal window
# Clean and retry
npm run clean
npm install
npm run build

Problem: VSIX fails validation

Solution:

Terminal window
# Check package.json
cat package.json
# Verify publisher
# Verify version
# Verify icon size (128x128 pixels)

Problem: vsce publish fails

Solution:

Terminal window
# Check if token is valid
vsce ls-publishers
# Try with verbose output
vsce publish --no-dry-run

Problem: Icon not displaying correctly

Solution:

  • Verify icon is exactly 128x128 pixels
  • Verify icon is in PNG format
  • Verify icon path in package.json is correct

Contains compiled extension:

dist/
├── extension.js # Compiled code
├── extension.js.map # Source map
└── [other compiled files]

Contains built documentation:

docs-dist/
├── index.html
├── guides/
├── reference/
└── dev/

The VSIX package containing everything needed for installation.

Terminal window
# Use cache
npm install --prefer-offline
# Parallel builds (if needed)
npm run build:parallel
  • Externalize vscode module (already done)
  • Use tree-shaking (esbuild default)
  • Minify in production builds

Builds run on:

  • Every push to main
  • Every pull request
  • Every tag push (for releases)

View build status at:

  • GitHub Actions tab in repository