Extending the Build
This guide explains how to influence the susee build pipeline through configuration.
1. Use the minify option
The built-in minifier is toggled via the minify field on each entry point or the --minify CLI flag.
import type { SuSeeConfig } from "susee";
const config: SuSeeConfig = {
entryPoints: [
{
entry: "src/index.ts",
exportPath: ".",
format: ["esm", "commonjs"],
minify: true,
},
],
outDir: "dist",
};
export default config;
When enabled, susee runs the oxc minifier (oxc-minify) — compression + mangling — over the final emitted .mjs/.cjs output before writing it to disk. If the minifier cannot parse the code, susee falls back to the unminified source so the build never breaks.
You can also pass custom minify options:
{
entry: "src/index.ts",
exportPath: ".",
format: ["esm", "commonjs"],
minify: { options: { /* MinifyOptions */ } },
}
2. Use the checks option
The checks field on each entry point provides optional lint checks on the bundled output:
import type { SuSeeConfig } from "susee";
const config: SuSeeConfig = {
entryPoints: [
{
entry: "src/index.ts",
exportPath: ".",
format: ["esm"],
checks: {
checkAnonymous: true,
checkDefaultExports: true,
checkNpmInstalled: true,
},
},
],
};
export default config;
When checkNpmInstalled is true, susee exits with code 1 if it finds referenced npm modules that are not installed during dependency analysis.
On the CLI, the --check flag enables all three checks simultaneously.
3. Use per-entry tsconfigFilePath
When one entry needs compiler settings that differ from the rest of the package, assign a custom tsconfig to that entry:
import type { SuSeeConfig } from "susee";
const config: SuSeeConfig = {
entryPoints: [
{
entry: "src/index.ts",
exportPath: ".",
format: ["esm", "commonjs"],
tsconfigFilePath: "tsconfig.build.json",
},
{
entry: "src/cli.ts",
exportPath: "./cli",
format: ["esm"],
tsconfigFilePath: "configs/tsconfig.cli.json",
},
],
outDir: "dist",
};
export default config;
See tsconfig.json and Custom tsconfig Path Integration for the full resolution priority.
4. Run builds from the programmatic API
For custom orchestration, drive susee from a script:
import { build } from "susee";
await build({
entryPoints: [
{ entry: "src/index.ts", exportPath: ".", format: ["esm", "commonjs"], minify: true },
],
outDir: "dist",
});
For lower-level access to just the bundled source string (no compilation), use suseeBundle:
import { suseeBundle } from "susee";
const code = suseeBundle("src/index.ts", {
checkAnonymous: true,
checkDefaultExports: true,
checkNpmInstalled: true,
});
See the Programmatic API reference for all exports.
5. Run lint checks without building
Use the susee check CLI command to run lint checks on every entry point in your config — without bundling, compiling, or writing output:
npx susee check
This enables all three checks (checkAnonymous, checkDefaultExports, checkNpmInstalled) and reports errors and warnings per entry.
6. Bundle without compiling
Use the susee bundle CLI command to write the bundled source string for a single entry to disk — without TypeScript compilation, declarations, or package.json updates:
npx susee bundle src/index.ts --outdir dist