{"id":16985892,"url":"https://github.com/sharpobject/reload","last_synced_at":"2026-04-12T23:43:51.384Z","repository":{"id":139890925,"uuid":"278883246","full_name":"sharpobject/reload","owner":"sharpobject","description":"hot reloading for live coding in Lua","archived":false,"fork":false,"pushed_at":"2020-08-23T23:22:43.000Z","size":29,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-22T01:42:06.634Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sharpobject.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-07-11T14:57:39.000Z","updated_at":"2022-10-14T23:14:50.000Z","dependencies_parsed_at":null,"dependency_job_id":"0e226aec-4c46-407d-8d1f-c4acd0c372e8","html_url":"https://github.com/sharpobject/reload","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sharpobject/reload","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sharpobject%2Freload","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sharpobject%2Freload/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sharpobject%2Freload/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sharpobject%2Freload/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sharpobject","download_url":"https://codeload.github.com/sharpobject/reload/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sharpobject%2Freload/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266495944,"owners_count":23938629,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-14T02:44:22.361Z","updated_at":"2025-10-18T08:21:11.417Z","avatar_url":"https://github.com/sharpobject.png","language":"Lua","funding_links":[],"categories":[],"sub_categories":[],"readme":"reload\n========================\nreload is a a library to enable live coding in love2d.\n\nWhile running your game, you can save a change to a lua file and see the change take effect in the game immediately.\n\nHow to use\n-------------------------------\n\nRequire it!\n```lua\nlocal reload = require\"reload\"\n```\n\nIf you want a module to be hot-reloaded, use `reload` instead of `require` to import it:\n```lua\n-- the entire body of main.lua:\nlocal reload = require\"reload\"\nreload.setup()\n-- I'd like to live code \"real_main\"!\nreload\"real_main\"\n\n-- in real_main.lua:\n-- In this example, I don't want to live-code kikito's tween library\nlocal tween = require\"tween\"\n-- But I do want to live-code my own classes.\nreload\"drawcontainer\"\nreload\"customer\"\nreload\"button\"\nreload\"animation\"\n```\n\nAt some point before `love.run` happens, please call `reload.setup()`.\nIf you are not defining your own `love.run`, you can do this as soon as you first `require\"reload\"`\nlike in the example above.\nIf you are defining your own love.run, you can call `reload.setup()` right after assigning `love.run`. Thanks.\n\nIn love.update, please call `reload.update()`\n```lua\nfunction love.update(dt)\n  reload.update()\n  -- do other stuff to update your game ok\nend\n```\n\nWhat does it do lmao\n----------------------\n\nWhen you call `reload.update()`, reload will stat at most 1 file loaded using reload\nto see if it's been updated.\nIf it's been updated, and it currently contains valid lua code,\nit will unload the module from `package.loaded` and load it again using `require`.\nThen, if we take the old return value of the module as `old` and the new one as `new`,\nif `old.to_replace` is a table and `new.to_replace` is a table, for every pair `k,v in pairs(old.to_replace)`,\nevery instance of `v` in the entire program will be replaced with `new.to_replace[k]`.\nThen, if `old` is a table or a function and `new` is a table or a function, all instances\nof `old` in the entire program will be replaced with `new`.\n\nWhen replacing things with other things, reload will begin looking at `debug.getregistry()` and\nthe metatables of nil, numbers, booleans, strings, functions, and coroutines\nand do a BFS of the object graph. reload traverses the graph by following these things:\n- metatables\n- keys in tables\n- values in tables\n- arguments and local variables in stacks other than the main stack\n- varargs in stacks other than the main stack\n- upvalues of functions\n\nThe above list is also the list of the places where reload will replace things.\nBecause reload cannot replace values on the main stack, `reload.setup()` attempts to ensure\nthat nothing important ends up on the main stack by wrapping `love.run` in a coroutine.\nreload hopes that that coroutine will be reachable to the BFS like so: `debug.getregistry()`\nholds a reference to the table of globals, which holds a reference to `love`, which holds a\nreference to `love.run`, which holds a reference to that coroutine as an upvalue.\n\nreload will not reload dependencies of a module it is reloading.\nIf you save a change to the dependency then save a change to the module,\nit should reload both of them in the right order during separate calls to `reload.update()`.\n\nI mainly use this to hot-reload classes by writing modules that return the class object.\n\nLimitations\n----------------------\nReplacing all occurrences of a thing with another thing is an approach frought with peril:\n\n- If you set mymodule.to_replace.house_width = 5, then change it to mymodule.to_replace.house_width = 10 and save,\n  then reload will attempt to replace all occurrences of 5 in your entire program with 10, even ones that aren't related\n  to the width of houses.\n- reload cannot replace functions that are currently executing. Normally you'll only run into this limitation if you are using coroutines.\n- If you replace an old version of a class with a new version of the class,\n  and you add some code to the constructor that sets a new property,\n  and you add some code to a method that uses the new property, you should be sure to handle the case\n  where the new property has not been set because the object was\n  created using the old constructor but has the new method.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsharpobject%2Freload","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsharpobject%2Freload","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsharpobject%2Freload/lists"}