minifier

package
v1.46.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 1, 2026 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Overview

Package minifier provides deterministic, scope-aware identifier minification for ELPS source files and parsed programs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadExcludeFile

func ReadExcludeFile(path string) ([]string, error)

ReadExcludeFile loads one symbol per line, ignoring blank lines and comment lines that start with ';'.

Types

type Config

type Config struct {
	Analysis            *analysis.Config
	Exclusions          map[string]bool
	RenameExports       bool
	PreserveParams      bool
	PackageSurfaceForms []PackageSurfaceFormSpec
	Formatter           *formatter.Config
}

Config controls minification behavior.

type FileResult

type FileResult struct {
	Path    string
	Source  []byte
	Output  []byte
	Program []*lisp.LVal
}

FileResult contains the minified output for one source unit.

type InputFile

type InputFile struct {
	Path   string
	Source []byte
}

InputFile is a source unit to minify.

type PackageSurfaceFormSpec added in v1.38.0

type PackageSurfaceFormSpec struct {
	Head       string
	NameIndex  int
	QuotedName bool
}

PackageSurfaceFormSpec declares a top-level form that creates a stable package-visible binding that should be preserved by default.

type Result

type Result struct {
	Files     []FileResult
	SymbolMap SymbolMap
}

Result contains the outputs of a minify run.

func Minify

func Minify(inputs []InputFile, cfg *Config) (*Result, error)

Minify rewrites one or more source units using a single deterministic symbol-assignment session.

type SymbolMap

type SymbolMap struct {
	Entries            []SymbolMapEntry    `json:"entries"`
	MinifiedToOriginal map[string]string   `json:"minified_to_original"`
	OriginalToMinified map[string][]string `json:"original_to_minified,omitempty"`
}

SymbolMap is the machine-readable symbol mapping emitted by a minify run.

func MinifySource

func MinifySource(source []byte, filename string, cfg *Config) ([]byte, SymbolMap, error)

MinifySource is a convenience wrapper for a single source unit.

func (SymbolMap) JSON

func (m SymbolMap) JSON() ([]byte, error)

JSON returns the symbol map encoded as indented JSON.

type SymbolMapEntry

type SymbolMapEntry struct {
	Minified string `json:"minified"`
	Original string `json:"original"`
	Kind     string `json:"kind"`
	File     string `json:"file,omitempty"`
	Line     int    `json:"line,omitempty"`
	Col      int    `json:"col,omitempty"`
}

SymbolMapEntry records one deterministic symbol assignment.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL