JaimeGensler / thyseus

An archetypal Entity Component System, built entirely in Typescript
MIT License
74 stars 3 forks source link

[HELP] Possibility to share system/components #54

Closed linonetwo closed 1 year ago

linonetwo commented 1 year ago

What do you need help with?

Since thyseus is a "compiled" ecs framework (@thyseus/rollup-plugin-thyseus), I wonder if it is possible to share a single system/component as an ESM file (to load in the browser) or a cjs file (to load in server side). Or does each game need to "compile from source"?

Usecase is for modding, I want my player can write some system/component/data too, and I hot reload the world with user-provided JS files (in a sandbox so I can just eval them).

Target Environment

Browser, Node, Bun

JaimeGensler commented 1 year ago

Yep, this should be possible! The main thing is that any code that @struct classes and systems are seen by the transformer at some point as TS, and that the @struct output is reflected in the type emit. There are package authors using Thyseus that release structs you can import and use - these are just already compiled

linonetwo commented 1 year ago

Thanks, I will try write all my systems as core mod, and load async via network to try if this works, thanks.