Glossary
This glossary defines the technical terms, internal concepts, and domain-specific jargon used within the susee codebase. It serves as a reference for onboarding engineers to understand the relationship between high-level bundling concepts and their specific implementations in the code.
Core Terminology
Entry Point
An EntryPoint represents a single source file that susee uses as a root to resolve dependencies and generate a bundle. It is defined in the configuration (susee.config.{ts,js,mjs}) and mapped to a specific exportPath in the resulting package.
- Data Flow: Each entry point is validated for existence and uniqueness by
checkEntries(insrc/config/index.ts) before being transformed into aBuildEntryPointobject for the internal pipeline.
Build Options
The BuildOptions object is the final, normalized configuration used by the Compiler. It contains the processed list of entry points and global settings like the output directory and the package update flag.
- Generation: Produced by the
generateBuildOptionsfunction which defaultsoutDirto"dist"if not specified.
Output Format
The module system used for the emitted files. susee supports dual-format output, represented by the OutputFormat type ("commonjs" | "esm").
- Default: If no format is provided in the config, it defaults to
["esm"]. - Extensions: ESM emits
.mjs/.d.mts/.mjs.map; CommonJS emits.cjs/.d.cts/.cjs.map.
System Architecture Concepts
The Build Pipeline
The susee execution flow is managed by the Compiler class (src/compiler/index.ts), which orchestrates bundling and TypeScript compilation.
1. Configuration & Initialization
The system loads the config file and converts it into BuildOptions.
- Key Function:
build(options?)insrc/build.ts. It normalizes the config viagenerateFinalBuildOptions, which prefers an explicitoptionsargument over the config file. - Resolution:
getSuseeConfigPath()checks forsusee.config.ts,susee.config.js, andsusee.config.mjsin the current working directory.
2. Bundling Phase
The system uses @suseejs/susee_bundler to resolve the dependency tree and merge files into a single source string.
- Key Functions:
bundler(point)insrc/bundler.tscallssuseeBundler(entry, root, checks)from@suseejs/susee_bundler.suseeBundle(entry, checkOptions?)is the public lower-level API that returns the bundled source string without compiling.suseeCliBundle(opts)insrc/bundler.tsis used by the CLIbundlecommand to write the bundled source to disk without compilation. - Logic: It applies dependency resolution, bundling, and lint checks. The bundled source is cached per entry point using a
WeakMapinside@suseejs/susee_bundler.
3. Compilation Phase
The bundled source is compiled per output format by suseeCompiler (src/compiler/suseeCompiler.ts), using @suseejs/ts6 as the TypeScript compiler. It emits JavaScript (ESM or CJS), type declarations (.d.mts/.d.cts), and source maps. When minify is enabled for an entry, oxc-minify runs as a post-compile step before files are written. When allowUpdatePackageJson is enabled, package.json export metadata is updated from the build output.
Compiler Options Resolution
TypeScript compiler options are resolved in src/compiler/tsoptions.ts using this priority:
- A custom
tsconfigFilePathon the entry point - The root
tsconfig.json(found viats6.findConfigFile) - Susee’s internal defaults (
CommonJS/ES2020module kind,Latesttarget)
JSX Handling
The compiler detects JSX syntax in the bundled source using @suseejs/ts6’s AST visitor (isJsxElement, isJsxSelfClosingElement, isJsxFragment). When JSX is found, it validates that the source imports either a React runtime or the configured jsxImportSource package. If neither is present, the build fails with an error. Compiler options are then adjusted to set jsx: ReactJSX and lib: ["dom", "dom.iterable", "esnext"].
Checks
The checks field on each EntryPoint provides optional lint validation:
checkAnonymous— detects anonymous default exports/importscheckDefaultExports— lints default export patternscheckNpmInstalled— verifies referenced npm modules are installed; whentrue, missing modules cause the build to fail
CLI Commands
The CLI dispatcher (src/cli/index.ts) routes to four subcommands:
build— config-driven or flag-based build (compiles and writes output)bundle— bundle-only; writes the bundled source string to disk without compilation (handled bysuseeCliBundleinsrc/bundler.ts)check— lint-only; runssuseeCheck(src/cli/lint.ts) on every config entry point usingsuseeLintfrom@suseejs/susee_bundler, without bundling or compilinginit— scaffolds a starter config file
Public Exports
The susee package main entry (src/index.ts) re-exports:
build— async config-driven build functionsuseeBundle— synchronous lower-level bundling function returning the merged source stringSuSeeConfig(type) — configuration interfaceCheckOptions(type) — lint check options, re-exported from@suseejs/susee_bundler