Modules
Modules group components, relations, systems and observers behind one import entry point.
A module is a registration/lifecycle unit. Entities are not “inside” modules and disabling a module does not erase component data.
Declaring modules
Section titled “Declaring modules”ECS_MODULE_DECLARE(physics, { float gravity;});struct Physics { static void import(float gravity);};Define in one implementation unit:
ECS_MODULE_DEFINE(physics);
void physics_import(const physics_props_t *props) { (void)props;
ECS_COMPONENT_REGISTER(Position); ECS_COMPONENT_REGISTER(Velocity);
ecs_system({ .name = "Move", .phase = EcsOnUpdate, .callback = Move, });}void Physics::import(float gravity) { (void)gravity;
ecs::component<Position>(); ecs::component<Velocity>();
ecs::system("Move") .phase(EcsOnUpdate) .each([](Position &, const Velocity &) {});}Import:
ecs_module_id_t Physics = ECS_MODULE_IMPORT(physics, { .gravity = 9.81f,});auto physics = ecs::import<Physics>(9.81f);Modules in C++
Section titled “Modules in C++”The generated module declarations can be consumed from C++ and SIECS also provides typed import/module wrappers.
The important semantic rule is the same: importing establishes registrations in the active world.
Idempotence
Section titled “Idempotence”Importing the same module again returns the existing module registration rather than duplicating systems and observers.
The first import configuration is the one used for the module initialization.
This makes it safe for modules to depend on/import other modules without every caller coordinating a single central registration location.
Captured registrations
Section titled “Captured registrations”While a module import is active, SIECS records systems and observers registered through the public API as belonging to that module.
Components and relations remain globally registered types.
Nested module import is supported: after a nested import completes, registrations resume being captured by the parent import.
Enable and disable
Section titled “Enable and disable”ecs_module_disable(Physics);ecs_module_enable(Physics);physics.disable();physics.enable();Disabling a module disables captured systems and observers.
It does not:
- unregister components;
- remove components from entities;
- destroy entities;
- remove relation definitions.
This makes module toggling suitable for optional features and editor/runtime feature activation.
Dynamic module loading
Section titled “Dynamic module loading”SIECS exposes ecs_module_load(path) for platform-supported dynamic module
loading.
Dynamic loading is a deployment feature and should keep the same registration contracts as statically linked module imports.
A dynamically loaded module must be compatible with the runtime ABI and the application’s component/relationship expectations.
Module dependencies and ordering
Section titled “Module dependencies and ordering”A module may import another module before registering its own systems.
System execution order is still defined by phases, data dependencies and
explicit system .after relationships—not by module import order alone.
Do not use module import order as a substitute for scheduler dependencies.
Feature swapping
Section titled “Feature swapping”Because modules can be enabled/disabled while component types and entity data remain intact, applications can implement optional execution features without rebuilding the whole ECS schema.
For mutually exclusive implementations, keep shared data contracts in stable components/resources and toggle the systems/observers that implement behavior.
Module overhead
Section titled “Module overhead”Module capture happens during registration.
Normal query iteration does not pay a per-entity “which module owns this?” check.
Enable/disable cost is proportional to the captured registrations that must be toggled.
Module properties
Section titled “Module properties”Module property structs are import-time configuration.
They are not automatically stored as a persistent ECS resource.
If systems need the configuration every frame, copy/store it into:
- a resource;
- component data;
- module-owned user data;
according to the desired visibility and scheduling semantics.
The first successful idempotent import owns the initialization configuration.
Empty modules
Section titled “Empty modules”A module can have no meaningful properties and still provide a registration boundary.
This is useful for feature packs such as:
InputRenderingDebugToolsGameplayRulesThe module still captures its systems/observers for enable/disable.
Dynamic module lifecycle
Section titled “Dynamic module lifecycle”A loaded module library must remain valid while callbacks/types originating from it are registered and used.
Do not unload code that still owns system/observer callback function pointers.
Treat dynamic module loading as application-level plugin lifecycle, not only an ECS registration call.
Module composition
Section titled “Module composition”A high-level module can import lower-level modules:
Game├── Physics├── Rendering└── AIIdempotent import prevents duplicates if another module also depends on Physics.
Keep dependency direction acyclic at the module design level to avoid confusing initialization relationships even if import calls themselves are guarded.
Modules and tests
Section titled “Modules and tests”Modules make tests easier when a subsystem can be imported into a fresh world.
A test can:
- initialize world;
- import module;
- create minimal entities/resources;
- run one phase/system;
- inspect result;
- finalize.
Avoid modules that require unrelated global application initialization when a smaller explicit resource/dependency would suffice.

