Module Files
Val content is defined in .val.ts (or .val.js) files. Only these files can export content using the c.define() function. They must be defined in the val.modules.ts file (see below).
NOTE: .val.ts files can also export only schemas without content, useful for shared type definitions. Only files that export c.define() must be registered in val.modules.ts. Val files can only import from other .val.ts files or type definitions (using import type).
Structure
To define content, use c.define() as the default export with three arguments:
modulePath- The file path relative to the project rootschema- The schema definition using schema typescontent- The actual content data
Example
Requirements
Val module files are evaluated by Val and must follow these rules:
The first argument to
c.define()must match the file pathMust be declared in the
val.modules.tsfileCan only import Val-related files or types (using
import type)
Use the eslint plugin or npx -p @valbuild/cli val validate to enforce these requirements.
Registering modules
Files that export c.define() must be registered in val.modules.ts. Schema-only .val.ts files don't need registration.