I am developing a private npm package using ECS. I am also using tsup to bundle my code with the following config: tsup config
I am using an index.ts file to export each module like so: index.ts file
Because I am also using ECS, I am declaring an array of components and systems to be included into the world. This is in another file ecsDefs.ts, which is also exported through an index.ts: World definitions
Because of this my dist folder has two different instances of classes (one for the module export and another in the World module), which completely breaks my non-ECS static classes when communicating with ECS classes.
Has anyone ran into the same issue before? What did you try to solve this? Please let me know if you need additional information.
I tried isolating the problem by creating a separate ECS system outside the package. Once I import and update static properties (also from outside the package) everything works fine. Once I add that system to the package and try to set a static property of it, the code outside knows about the property (probably because it's a different instance), but the system doesn't.
I also tried exposing static classes (prototype) to the window and do a declare global. But it's not reliable.