Skip to content

reorganize main module to import from the utpm library#111

Merged
Thumuss merged 1 commit intotypst-community:mainfrom
ensko:no-main-modules
Mar 4, 2026
Merged

reorganize main module to import from the utpm library#111
Thumuss merged 1 commit intotypst-community:mainfrom
ensko:no-main-modules

Conversation

@ensko
Copy link
Copy Markdown
Collaborator

@ensko ensko commented Feb 19, 2026

The main.rs and lib.rs declare the same modules (utils, commands, build through shadow_rs). This is a bit of a footgun, because the library and binary are two separate crates. Worst case, something like this can happen:

// lib.rs
mod x;

// main.rs
mod x;

fn main() {
    x::foo();  // modifies a static variable
    utpm::x::bar();  // reads that static variable, but it's actually a different one
}

I thus removed all modules declared in main.rs and replaced them with imports of utpm::.... If my intuition is correct, this should also improve compile times, since the utpm could should previously have been compiled twice. (Edit: CI runs indicate there is a time difference, although not as significant as halving compilation time would be.)

@Thumuss Thumuss merged commit ba45bdf into typst-community:main Mar 4, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants