{"id":"flipbook-labs/module-loader","name":"module-loader","scope":"flipbook-labs","platform":"roblox","description":"Module loader class that bypasses Roblox's require cache","version":"1.0.1","latest":"1.0.1","versions":["0.6.1","0.6.2","0.7.0","0.8.0","0.9.0","0.10.0","0.10.1","0.10.2","0.11.0","0.12.0","0.13.0","1.0.0","1.0.1"],"license":"MIT","licenseRating":"safe","licenseCaveats":[],"licenseVerified":true,"dependencies":{"roblox/jest":{"version":"^3.21.0","alias":"Jest"},"roblox/jest-globals":{"version":"^3.21.0","alias":"JestGlobals"}},"integrity":"b06c358c33bfae21b21ce85b3892f618bcf92a582c097b46c5cb57f02e4ad528","likes":0,"downloads":0,"install":"forest install flipbook-labs/module-loader","url":"https://forest.dev/p/roblox/flipbook-labs/module-loader","files":"https://api.forest.dev/ai/package/roblox/flipbook-labs/module-loader/files","readme":"# ModuleLoader\n\nModuleLoader requires ModuleScripts without Roblox's `require` cache. Change a module, require it again, and the new code runs without restarting the place. Storyteller and Flipbook use it to reload stories. The [API reference](https://flipbook-labs.github.io/module-loader/api/ModuleLoader) covers every function.\n\n## Install\n\nWith Wally:\n\n```toml\n[dependencies]\nModuleLoader = \"flipbook-labs/module-loader@1.0.1\"\n```\n\nWith Lute, add this to `pkg.luau` and run `lute pkg install --vendor`:\n\n```luau\n[\"module-loader\"] = {\n\trev = \"v1.0.1\",\n\tsourceKind = \"github\",\n\tsource = \"https://github.com/flipbook-labs/module-loader\",\n},\n```\n\n## Use\n\nRequire a ModuleScript through a loader instead of `require`:\n\n```luau\nlocal ModuleLoader = require(\"@pkg/ModuleLoader\")\n\nlocal loader = ModuleLoader.createModuleLoader()\nlocal result = loader.require(game:GetService(\"ReplicatedStorage\").Stories.Button)\n```\n\n## Reloading\n\n`loadedModuleChanged` fires when a module loaded through the loader, or any module it requires, has its ancestry or `Source` changed. Clear the loader's cache and require the module again inside the handler:\n\n```luau\nlocal ModuleLoader = require(\"@pkg/ModuleLoader\")\n\nlocal loader = ModuleLoader.createModuleLoader()\nlocal module = game:GetService(\"ReplicatedStorage\").Stories.Button\nlocal result = loader.require(module)\n\nloader.loadedModuleChanged:Connect(function()\n\tloader.clear()\n\tresult = loader.require(module)\nend)\n```\n\n## Contributing\n\nSee [CONTRIBUTING.md](CONTRIBUTING.md).\n\n## License\n\nMIT.\n\nParts of the loader come from [roblox-testservice-watcher](https://github.com/OrbitalOwen/roblox-testservice-watcher) by OrbitalOwen, which is released under the [MIT License](https://github.com/OrbitalOwen/roblox-testservice-watcher/blob/master/LICENSE.md).\n","readmeTruncated":false}