Build configuration
On this page
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.
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.
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
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(...).
contract: string;MaligatorFfiLibrary.find
Machine-specific discovery that replaces the contract's find alternatives.
find?: MaligatorFfiFind;Types: MaligatorFfiFind
MaligatorFfiLibrary.link
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";MaligatorBuildConfig
Trusted, strictly validated configuration evaluated for each CLI invocation.
Full TypeScript declaration
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>;
}entry
Project-root-relative entry; an explicit CLI entry takes precedence.
entry?: string;outputName
Binary name; otherwise inferred from the unscoped package name or project directory.
outputName?: string;modules
Full TypeScript declaration
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.
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"].
conditions?: Array<string>;engine
Full TypeScript declaration
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".
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.
eval?: boolean | "compile-check";engine.realms
Enable ShadowRealm. Evaluating source in a realm also requires engine.eval: true.
Default: false.
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.
regexp?: boolean;engine.temporal
Allow Temporal. A program links its calendar and time-zone data only when it can reach Temporal.
Default: false.
temporal?: boolean;engine.intl
Full TypeScript declaration
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.
enabled?: boolean;engine.intl.features
Select the services a program may use. An empty list allows all services when enabled.
Default: [].
features?: Array<MaligatorIntlFeature>;Types: MaligatorIntlFeature
engine.intl.languages
Reserved for locale-data filtering. Leave empty when enabling Intl.
Default: [].
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.
ffi?: Record<string, MaligatorFfiLibrary>;Types: MaligatorFfiLibrary
defineBuild
Preserve the inferred config type. Validation happens when the CLI loads the config.
export declare function defineBuild<const Config extends MaligatorBuildConfig>(
config: Config,
): Config;Types: MaligatorBuildConfig
import { defineBuild } from "@maligator/cli";
export default defineBuild({ entry: "src/index.ts" });