rojo-rbx / rojo

Rojo enables Roblox developers to use professional-grade software engineering tools
https://rojo.space
Mozilla Public License 2.0
921 stars 174 forks source link

Rojo Hot-Reloading #559

Open LPGhatguy opened 2 years ago

LPGhatguy commented 2 years ago

Today, some Rojo users connect the Rojo studio plugin from running playtest DataModels. For some projects, this works out of the box, and in conjunction with a hot reloading library, delivers an unrivaled edit-debug loop.

However, if an instance that is fully managed by Rojo is also mutated at runtime, this can cause funny side effects.

We should support a couple features that will make hot reloading in Rojo much better:

MayGo commented 1 year ago

I think I need this also. Trying to implement some kind of hot reloading using rojo and roblox-ts. I am using @rbxts/net for events and if I run game (Play Solo) and connect to rojo. Those events will be removed as those files are generated runtime in the filesystem.

@LPGhatguy Perhaps you know any "hack" to cope with such problems?

LPGhatguy commented 1 year ago

You can connect to a running DataModel with Rojo. That's the best way to do hot reloading today.

MayGo commented 1 year ago

thanks, doing that. Just confirming what steps I am doing:

Do you know if there Is a way to prevent last step?

In rojo config I have:

       "ReplicatedStorage": {
            "$className": "ReplicatedStorage",
            "rbxts_include": {
                "$path": "../../include",
                "node_modules": {
                    "$path": "../../node_modules/@rbxts"
                }
            }
            ...
      }
      ...

Would ignoreUnknownInstances help?

LPGhatguy commented 1 year ago

Right, ignoreUnknownInstances can help here.

When talking about instances, I recommend using Roblox's naming convention, ie ReplicatedStorage.rbxts_include.node_modules, to distinguish instances from file paths. @rbxts/net isn't generating files, it's making instances at runtime. That is definitely a case where the current hot reloading approach with Rojo is not great.

MayGo commented 1 year ago

Thanks. Do you know if there is a Roblox-TS and Rojo open-source project that has working hot reloading? I have hot reloading, but It works only one time. I think I need to watch entire ReplicatedStorage and ServerScriptService and do stuff by name instead. But if there already is some working sources, then don't need to debug that needlessly.