Asper Header  1.0.14
The header injector extension
Loading...
Searching...
No Matches
esbuild.js File Reference

Custom build script for VSCode extension packaging. More...

Go to the source code of this file.

Functions

function walk (dir, suffix)
 
function patternExists (from)
 
function checkedCopy (options)
 
function minifyJSON (src, dest)
 
function async main ()
 

Variables

import fs from fs
 
import path from path
 
import esbuild from esbuild
 
 import { copy } from "esbuild-plugin-copy"
 
const logLevel = 'info'
 
const production = process.argv.includes('--production')
 
const watch = process.argv.includes('--watch')
 
const esbuildProblemMatcherPlugin
 

Detailed Description

Custom build script for VSCode extension packaging.

Handles TypeScript bundling, JSON minification, asset copying with guard checks, and problem matcher integration for developer feedback.

Definition in file esbuild.js.

Function Documentation

◆ checkedCopy()

function checkedCopy ( options)

Wrapper around esbuild-plugin-copy that ensures each "from" pattern resolves to at least one file before proceeding.

Parameters
{Parameters<typeofcopy>[0]} options - Copy plugin options.
Returns
{import('esbuild').Plugin} Wrapped copy plugin.
Exceptions
{Error}If any "from" pattern resolves to no files.

Definition at line 107 of file esbuild.js.

◆ main()

function async main ( )

Main build entry point.

  • Bundles extension
  • Copies assets with validation
  • Runs in watch or production mode

Definition at line 171 of file esbuild.js.

◆ minifyJSON()

function minifyJSON ( src,
dest )

Minify JSON by reading a source file, parsing, and re-stringifying.

Parameters
{string}src - Path to source JSON file.
{string}dest - Destination path for minified JSON.

Definition at line 127 of file esbuild.js.

◆ patternExists()

function patternExists ( from)

Minimal glob-like existence check using Node built-ins. Does not attempt to fully emulate globbing libraries.

Parameters
{string| string[]} from - Path or glob-like pattern(s) to check. Supports:
  • *.ext → any file ending with .ext
  • prefix* → any file starting with prefix
  • <recursive>/*.ext → recursive search for .ext files
  • Direct file paths
Returns
{boolean} True if at least one match is found.
Exceptions
{Error}If a base directory in a pattern does not exist.
Note
<recursive> is represented by ** in the pattern.

Definition at line 52 of file esbuild.js.

◆ walk()

function walk ( dir,
suffix )

Recursively walks through a directory tree and checks if any file matches the expected suffix (after glob simplification).

Parameters
{string}dir - Directory to traverse recursively.
{string}suffix - File suffix to match (e.g., ".txt", ".min.json").
Returns
{boolean} True if at least one match is found, otherwise false.

Definition at line 24 of file esbuild.js.

Variable Documentation

◆ esbuild

import esbuild from esbuild

Definition at line 11 of file esbuild.js.

◆ esbuildProblemMatcherPlugin

const esbuildProblemMatcherPlugin
Initial value:
= {
name: 'esbuild-problem-matcher',
setup(build) {
build.onStart(() => {
console.log('[watch] build started');
});
build.onEnd((result) => {
if (result.errors.length > 0) {
result.errors.forEach(({ text, location }) => {
console.error(`✘ [ERROR] ${text}`);
if (location) {
console.error(` ${location.file}:${location.line}:${location.column}`);
}
});
}
console.log('[watch] build finished');
});
},
}

Problem matcher plugin for esbuild. Helps VSCode surface build errors in Problems panel.

Definition at line 144 of file esbuild.js.

◆ fs

import fs from fs

Definition at line 9 of file esbuild.js.

◆ import

import { copy } from "esbuild-plugin-copy"

Definition at line 12 of file esbuild.js.

◆ logLevel

const logLevel = 'info'

Definition at line 14 of file esbuild.js.

◆ path

import path from path

Definition at line 10 of file esbuild.js.

◆ production

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

Definition at line 118 of file esbuild.js.

◆ watch

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

Definition at line 119 of file esbuild.js.