Live updating scripts #502
Replies: 2 comments 8 replies
-
I'm trying to understand why imports are problematic, because at least the way Repl sets up modules, it shouldn't be necessary to reload anything but the current module - since the global environment should only contain builtins and be frozen as part of luaL_sandbox, each individual module gets their own global table that other modules can't reference. As such GETIMPORT would only reference the global table. Maybe you can expand on the larger example? If you do need to patch imports then the sequence you outlined seems reasonable. There's no dedicated list of protos, and for each proto there's currently no way to identify imports in a special way either, so you need a full heap scan effectively. |
Beta Was this translation helpful? Give feedback.
-
Hi, any proposal how to implement live-reloading after you shipped your product? or an already implemented solution with source code and hints how to use it? |
Beta Was this translation helpful? Give feedback.
-
Hi! I'm trying to find a (nice) way to implement live updating of scripts. By live updating I mean patching (global) functions as the program is running. With Lua/LuaJIT this has worked nicely because everything is dynamic by nature. Luau implements caching for globals using imports, which is a very nice performance optimization but at the same time it rubs against live workflows.
So far my best attempt is the following:
I have a rough prototype of this and it seems to be working, but of course there are downsides: it requires access to Luau internal headers and efficiently implementing the bytecode scan and especially step 2 (finding all protos) can be tricky.
Some questions:
Of course easy way to work around the issue is to disable imports by setting optimization level to 0 or disabling the safe-env feature, but the performance penalty would be severe.
Beta Was this translation helpful? Give feedback.
All reactions