Documentation menu
API referenceMarkdown ↗

Build configuration

On this page
API reference0.1.0-alpha.36

Import defineBuild from @maligator/cli in a trusted maligator.build.ts. These types describe build choices; the CLI validates the resulting value when loading configuration.

maligator.build.ts
import { defineBuild } from "@maligator/cli";

export default defineBuild({
	entry: "src/index.ts",
	outputName: "my-app",
});

All configuration fields are optional. Entries resolve from the project root, which is the working directory. An explicit CLI entry takes precedence. outputName must be a safe single filename component. Without it, the CLI uses the unscoped package name or directory name.

To use a C library, name it under ffi and set its contract to the file that declares it with defineLibrary.

Configure a build explains feature selection. Embed files covers asset patterns and materialization. The signatures and field documentation below are extracted from the shipped declarations.

MaligatorIntlFeature

Service selections used when Intl is enabled; an empty list includes every service.

typescript
export type MaligatorIntlFeature =
	| "collator"
	| "number-format"
	| "date-time-format"
	| "plural-rules"
	| "list-format"
	| "segmenter"
	| "display-names"
	| "relative-time-format"
	| "duration-format";

MaligatorFfiLibrary

A C library the program imports as maligator:ffi/<name>.

Full TypeScript declaration
typescript
export interface MaligatorFfiLibrary {
	/** Project-root-relative path to the library's contract, a module exporting `defineLibrary(...)`. */
	contract: string;
	/** Machine-specific discovery that replaces the contract's `find` alternatives. */
	find?: MaligatorFfiFind;
	/** Link the static archive or the shared library. Without a choice, the build links
	 * statically when every library has an archive. Sources always link statically.
	 */
	link?: "static" | "shared";
}

Types: MaligatorFfiFind

MaligatorFfiLibrary.contract

Project-root-relative path to the library's contract, a module exporting defineLibrary(...).

typescript
contract: string;

MaligatorFfiLibrary.find

Machine-specific discovery that replaces the contract's find alternatives.

typescript
find?: MaligatorFfiFind;

Types: MaligatorFfiFind

Link the static archive or the shared library. Without a choice, the build links statically when every library has an archive. Sources always link statically.

typescript
link?: "static" | "shared";

MaligatorBuildConfig

Trusted, strictly validated configuration evaluated for each CLI invocation.

Full TypeScript declaration
typescript
export interface MaligatorBuildConfig {
	/** Project-root-relative entry; an explicit CLI entry takes precedence. */
	entry?: string;
	/** Binary name; otherwise inferred from the unscoped package name or project directory. */
	outputName?: string;
	modules?: {
		/** Exact specifier replacements applied before module resolution. Defaults to an empty map. */
		aliases?: Record<string, string>;
		/** Package `exports` conditions to resolve with. Omit `import`, `require`, and `default`.
		 * The first two follow the dependency edge and `default` always matches.
		 * @default ["maligator", "node"]
		 */
		conditions?: Array<string>;
	};
	engine?: {
		/** Lock built-in objects for the entire build. Mutable is intended for compatibility experiments.
		 * @default "locked"
		 */
		primordials?: "locked" | "mutable";
		/** Control dynamic compilation in the application image. `false` makes eval and
		 * function constructors throw at runtime. `true` embeds the compiler, which requires
		 * `engine.regexp` to be enabled. `"compile-check"` also rejects statically visible
		 * dynamic compilation calls during the build.
		 * @default false
		 * @see https://maligator.ddv.tools/api/build#engine.eval
		 */
		eval?: boolean | "compile-check";
		/** Enable ShadowRealm. Evaluating source in a realm also requires `engine.eval: true`.
		 * @default false
		 */
		realms?: boolean;
		/** Allow RegExp. Disable it only when runtime eval is off. Native executables link
		 * the matcher when the application or the embedded compiler can use it.
		 * @default true
		 */
		regexp?: boolean;
		/** Allow Temporal. A program links its calendar and time-zone data only when it can reach Temporal.
		 * @default false
		 */
		temporal?: boolean;
		intl?: {
			/** Allow internationalization. A program links only the services, and their native data, it can reach.
			 * @default false
			 */
			enabled?: boolean;
			/** Select the services a program may use. An empty list allows all services when enabled.
			 * @default []
			 */
			features?: Array<MaligatorIntlFeature>;
			/** Reserved for locale-data filtering. Leave empty when enabling Intl.
			 * @default []
			 */
			languages?: Array<string>;
		};
	};
	/** C libraries keyed by the name the program imports them under (`maligator:ffi/<name>`).
	 * Names use lowercase letters, digits, and underscores.
	 * @see https://maligator.ddv.tools/guides/c-libraries
	 */
	ffi?: Record<string, MaligatorFfiLibrary>;
}

Types: MaligatorIntlFeature, MaligatorFfiLibrary

entry

Project-root-relative entry; an explicit CLI entry takes precedence.

typescript
entry?: string;

outputName

Binary name; otherwise inferred from the unscoped package name or project directory.

typescript
outputName?: string;

modules

Full TypeScript declaration
typescript
modules?: {
		/** Exact specifier replacements applied before module resolution. Defaults to an empty map. */
		aliases?: Record<string, string>;
		/** Package `exports` conditions to resolve with. Omit `import`, `require`, and `default`.
		 * The first two follow the dependency edge and `default` always matches.
		 * @default ["maligator", "node"]
		 */
		conditions?: Array<string>;
	};

modules.aliases

Exact specifier replacements applied before module resolution. Defaults to an empty map.

typescript
aliases?: Record<string, string>;

modules.conditions

Package exports conditions to resolve with. Omit import, require, and default. The first two follow the dependency edge and default always matches. Default: ["maligator", "node"].

typescript
conditions?: Array<string>;

engine

Full TypeScript declaration
typescript
engine?: {
		/** Lock built-in objects for the entire build. Mutable is intended for compatibility experiments.
		 * @default "locked"
		 */
		primordials?: "locked" | "mutable";
		/** Control dynamic compilation in the application image. `false` makes eval and
		 * function constructors throw at runtime. `true` embeds the compiler, which requires
		 * `engine.regexp` to be enabled. `"compile-check"` also rejects statically visible
		 * dynamic compilation calls during the build.
		 * @default false
		 * @see https://maligator.ddv.tools/api/build#engine.eval
		 */
		eval?: boolean | "compile-check";
		/** Enable ShadowRealm. Evaluating source in a realm also requires `engine.eval: true`.
		 * @default false
		 */
		realms?: boolean;
		/** Allow RegExp. Disable it only when runtime eval is off. Native executables link
		 * the matcher when the application or the embedded compiler can use it.
		 * @default true
		 */
		regexp?: boolean;
		/** Allow Temporal. A program links its calendar and time-zone data only when it can reach Temporal.
		 * @default false
		 */
		temporal?: boolean;
		intl?: {
			/** Allow internationalization. A program links only the services, and their native data, it can reach.
			 * @default false
			 */
			enabled?: boolean;
			/** Select the services a program may use. An empty list allows all services when enabled.
			 * @default []
			 */
			features?: Array<MaligatorIntlFeature>;
			/** Reserved for locale-data filtering. Leave empty when enabling Intl.
			 * @default []
			 */
			languages?: Array<string>;
		};
	};

Types: MaligatorIntlFeature

engine.primordials

Lock built-in objects for the entire build. Mutable is intended for compatibility experiments. Default: "locked".

typescript
primordials?: "locked" | "mutable";

engine.eval

Control dynamic compilation in the application image. false makes eval and function constructors throw at runtime. true embeds the compiler, which requires engine.regexp to be enabled. "compile-check" also rejects statically visible dynamic compilation calls during the build. Default: false.

typescript
eval?: boolean | "compile-check";

engine.realms

Enable ShadowRealm. Evaluating source in a realm also requires engine.eval: true. Default: false.

typescript
realms?: boolean;

engine.regexp

Allow RegExp. Disable it only when runtime eval is off. Native executables link the matcher when the application or the embedded compiler can use it. Default: true.

typescript
regexp?: boolean;

engine.temporal

Allow Temporal. A program links its calendar and time-zone data only when it can reach Temporal. Default: false.

typescript
temporal?: boolean;

engine.intl

Full TypeScript declaration
typescript
intl?: {
			/** Allow internationalization. A program links only the services, and their native data, it can reach.
			 * @default false
			 */
			enabled?: boolean;
			/** Select the services a program may use. An empty list allows all services when enabled.
			 * @default []
			 */
			features?: Array<MaligatorIntlFeature>;
			/** Reserved for locale-data filtering. Leave empty when enabling Intl.
			 * @default []
			 */
			languages?: Array<string>;
		};

Types: MaligatorIntlFeature

engine.intl.enabled

Allow internationalization. A program links only the services, and their native data, it can reach. Default: false.

typescript
enabled?: boolean;

engine.intl.features

Select the services a program may use. An empty list allows all services when enabled. Default: [].

typescript
features?: Array<MaligatorIntlFeature>;

Types: MaligatorIntlFeature

engine.intl.languages

Reserved for locale-data filtering. Leave empty when enabling Intl. Default: [].

typescript
languages?: Array<string>;

ffi

C libraries keyed by the name the program imports them under (maligator:ffi/<name>). Names use lowercase letters, digits, and underscores.

typescript
ffi?: Record<string, MaligatorFfiLibrary>;

Types: MaligatorFfiLibrary

defineBuild

Preserve the inferred config type. Validation happens when the CLI loads the config.

typescript
export declare function defineBuild<const Config extends MaligatorBuildConfig>(
	config: Config,
): Config;

Types: MaligatorBuildConfig

typescript
import { defineBuild } from "@maligator/cli";
export default defineBuild({ entry: "src/index.ts" });
Maligator 0.1.0-alpha.36 · Experimental · Source 6af07bd09681
Edit this page · Compatibility

Search guides and API reference.

Browse the API · Troubleshooting