diff --git a/rtmc.lua b/rtmc.lua index 101c5e4..8e0e4db 100644 --- a/rtmc.lua +++ b/rtmc.lua @@ -3,6 +3,8 @@ local __DEFAULT_IMPORT = require local require = function(path) if __BUNDLER_FILES[path] then return __BUNDLER_FILES[path]() + elseif __BUNDLER_FILES[path .. ".lua"] then + return __BUNDLER_FILES[path .. ".lua"]() else return __DEFAULT_IMPORT(path) end diff --git a/x.py b/x.py index 928aba2..57936c0 100755 --- a/x.py +++ b/x.py @@ -39,17 +39,23 @@ def minimise(buf: str) -> str: # hasher.update(bytes(buf, "utf-8")); # return hasher.hexdigest(); +REQ_HEADER="""local __BUNDLER_FILES = {} +local __DEFAULT_IMPORT = require +local require = function(path) + if __BUNDLER_FILES[path] then + return __BUNDLER_FILES[path]() + elseif __BUNDLER_FILES[path .. ".lua"] then + return __BUNDLER_FILES[path .. ".lua"]() + else + return __DEFAULT_IMPORT(path) + end +end +""" + + def main(): buf = "" - buf += "local __BUNDLER_FILES = {}\n"; - buf += "local __DEFAULT_IMPORT = require\n"; - buf += "local require = function(path)\n"; - buf += " if __BUNDLER_FILES[path] then\n"; - buf += " return __BUNDLER_FILES[path]()\n"; - buf += " else\n"; - buf += " return __DEFAULT_IMPORT(path)\n"; - buf += " end\n"; - buf += "end\n"; + buf += REQ_HEADER; # buf += "local __UPDATE_HASH = __BUNDLER_REPLACE_HASH__\n"; for file in FILES: print(f"=== FILE: {file}");