Skip to content

Modules and Imports

In Vertex, every .vtx file is a module. No explicit module declaration is needed. The module name is derived from the filename:

  • accounts.vtx → module accounts
  • billing/invoices.vtx → module billing.invoices

Declarations are private by default. Use pub to export:

accounts.vtx
pub fn findById(id: String): Option<Account> { ... } // exported
fn validate(a: Account): Bool { ... } // private

Bare import. Access symbols via a qualifier:

import accounts
let acc = accounts.findById("001")

For nested modules, the qualifier is the last path segment:

import billing.invoices
let inv = invoices.create()

Aliased import. Choose your own qualifier:

import billing.invoices as inv
let i = inv.create()

Selective import. Bring specific symbols directly into scope:

import accounts.{ findById, Account }
let acc = findById("001") // no qualifier needed

Each module maps to an Apex class when compiled:

Module pathApex class
accountsAccounts
billing/invoicesBilling_Invoices
lang/greeterLang_Greeter
CodeMeaning
E122Module not found
E123Symbol not found in module’s public API
E124Attempted access to a private declaration
E125Cyclic import detected
E126Name conflict from two selective imports

vertex run supports imports without a build step. Point it at any entry script and it discovers the project automatically by walking upward from the file’s directory to find sfdx-project.json:

vertex run scripts/hello.vtx

Only the transitively reachable modules are loaded. Files in src/ that are not imported are never touched.

A file with no imports runs anywhere. No project required.

See the Imports reference for the full discovery rules and --sf preconditions.