Skip to content

File Scanning

ScaffScript recursively scans your source directory for *.ss and *.gml files. Understanding how files are discovered and ordered helps when structuring larger projects.

Both .ss and .gml files are picked up from the scanPath directory recursively.

Will participate fully in the ScaffScript’s module system.

Treated as a raw content, only usable via include statement.


Files are internally split into three groups:

GroupDescription
generate.ss files with an intg statement, these produce an output
scaff.ss files without an intg statement, these are used for module resolution only
normal.gml files

Order matters for dependency resolution:

  1. Files with export statements:
    • Start from the deepest directories first, so nested modules are resolved before their parents.
    • The children modules are always processed before their parent modules. So, you must not have circular dependencies between modules, such as import/include/export ... from a module from a parent directory.
  2. index.ss files:
    • Always processed last at each directory depth.
    • You can have multiple index.ss files in a project, each processed last in their respective directories.
  3. Files with impl statements:
    • Always processed after all export statements are processed.

  • index.ss is always the last file processed in its directory.
  • Its module store key is the directory path (not dir/index), so you import from the directory directly.
my_dir/other.ss
export var x = 10;
my_dir/index.ss
export function hello() {
show_debug_message("Hello, World!");
}
export * from "./other"
index.ss
import * from "./my_dir/index" // index is removed from the path
import * from "./my_dir" // use the directory path instead, which resolves to my_dir/index.ss

Use index.ss as your barrel file for re-exports and intg statements.


ScaffScript finds your config by walking up the directory tree from process.cwd(). The first matching config file found wins. This means you can run bun|pnpm|npm run generate from any subdirectory of your project and it will still pick up the config at the root.