This commit is contained in:
Gvidas Juknevičius 2024-08-25 22:03:37 +03:00
parent b7ad80b226
commit 4f0509d30e
Signed by: MCorange
GPG Key ID: 12B1346D720B7FBB
2 changed files with 17 additions and 9 deletions

View File

@ -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

24
x.py
View File

@ -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}");