-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Open
Labels
TolkRelated to Tolk Language / compiler / toolingRelated to Tolk Language / compiler / tooling
Description
Motivation
In large smart-contract systems, contracts are often split across multiple modules and directories.
Currently, imports require relative paths, which quickly become cumbersome and fragile:
import "../../common/jettons"
import "../../common/utils"
import "../../../../third_party/jest-tolk/testing"
This leads to:
- Hard-to-read imports with lots of
../.. - Fragility when files are moved or refactored
- Repetition across multiple contracts in the same project
Proposed Solution
Introduce path mapping (similar to TypeScript’s paths), allowing developers to define import aliases in a project config (e.g. tolk.json):
{
"paths": {
"@*": [
"contracts/*",
"third_party/*"
]
}
}With this feature, imports become shorter and more elegant:
import "@common/jettons"
import "@common/utils"
import "@jest-tolk/testing"
Benefits
- Readability: Cleaner, shorter import statements
- Maintainability: Less risk of broken imports after refactoring file structure
- Consistency: Developers can share common alias mappings across projects
- Ecosystem growth: Third-party libraries (like
jest-tolk) can be imported with simple, predictable names
Alternatives Considered
- Continuing with relative paths → quickly becomes unmanageable in big repos
- Hard-coding a
lib/orstd/directory → too restrictive for multi-package projects
Implementation Notes
- Path resolution can follow the same priority system as TypeScript (check
pathsaliases first, then fallback to relative resolution). - A single alias (
@*) can expand to multiple directories (first match wins). - Should integrate naturally with existing build tools and IDE integrations.
1IxI1, memearchivarius, designervoid, Kaladin13, LevZed and 4 moreezjivich, ruslan-korneev and X1agruslan-korneev and X1ag
Metadata
Metadata
Assignees
Labels
TolkRelated to Tolk Language / compiler / toolingRelated to Tolk Language / compiler / tooling