Skip to main content

File Splitting

In Geajs, strict file separation is required to make it easier for Vite plugins to optimize your code. Once you master this, your Geajs applications will perform even better.

Why File Splitting Matters​

The Geajs compiler performs static analysis at the module (file) level. Defining multiple entities in a single file forces the compiler to take a conservative, "all-or-nothing" approach, often missing out on aggressive optimizations.

Stores​

Defining multiple stores in a single file works fine with a standard CompiledStore. However, if you define only one store per file, a powerful optimization path called "Lean transformation" is applied.

One Store per FileMultiple Stores per File
Applicable ConversionsLean transformationCompiledStore
Runtime BaseCompiledLeanStoreCompiledStore
Optimization LevelMaximum (Object / Closure)Standard (Class inheritance)
Fallback RiskLow (Isolated)High (All-or-nothing)

Components​

Geajs automatically categorizes components into 4 Optimization Tiers (ranging from Static HTML to standard classes).

Just like Stores, defining one component per file ensures the compiler can isolate analysis, giving your components the highest chance of reaching top tiers like Static or Tiny Reactive. Placing multiple components in one file increases static analysis complexity, which can cause the compiler to fall back to lower tiers for safety.

Learn More

To learn about the specific requirements and benefits of each component tier, see the Component Optimization Tiers guide.