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.
What Gets Scanned?
Section titled “What Gets Scanned?”Both .ss and .gml files are picked up from the scanPath directory recursively.
.ss Files
Section titled “.ss Files”Will participate fully in the ScaffScript’s module system.
.gml Files
Section titled “.gml Files”Treated as a raw content, only usable via include statement.
File Groups
Section titled “File Groups”Files are internally split into three groups:
| Group | Description |
|---|---|
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 |
Processing Order
Section titled “Processing Order”Order matters for dependency resolution:
- Files with
exportstatements:- 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 ... froma module from a parent directory.
index.ssfiles:- Always processed last at each directory depth.
- You can have multiple
index.ssfiles in a project, each processed last in their respective directories.
- Files with
implstatements:- Always processed after all
exportstatements are processed.
- Always processed after all
index.ss Behavior
Section titled “index.ss Behavior”index.ssis 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.
Example
Section titled “Example”export var x = 10;export function hello() { show_debug_message("Hello, World!");}export * from "./other"import * from "./my_dir/index" // index is removed from the pathimport * from "./my_dir" // use the directory path instead, which resolves to my_dir/index.ssUse index.ss as your barrel file for re-exports and intg statements.
Config Discovery
Section titled “Config Discovery”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.