275 posts
Location
Turkey
Posted 01 June 2018 - 11:19 PM
reqpack allows you to package all your requirements (require() calls) into a single file
NOTE[indent=1]I made this in about an hour out of a random idea i had, so this might not be very reliable, YMMV.[/indent]
USAGE[indent=1]
reqpack <filename>[/indent]
CONFIGURATION[indent=1]Create the configuration file using
reqpack –extract-conf. All options should be pretty self explanatory[/indent]
LIMITATIONS- Dynamic requires (calling require with anything but a single string) need use_require_if_not_found and cannot be packed
- Probably more i can't remember right now
DOWNLOAD[indent=1]
wget (latest): https://gitlab.com/a.../v3/reqpack.lua[/indent]
[indent=1]
wget (v2): https://gitlab.com/a.../v2/reqpack.lua[/indent]
[indent=1]
wget (v1): https://gitlab.com/a.../v1/reqpack.lua[/indent]
[indent=1]
packman: admicos/reqpack[/indent]
Edited on 10 June 2018 - 12:12 PM
4 posts
Posted 02 June 2018 - 04:32 PM
So, I just tested this and noticed that you replace every require call with a custom one(__require__). Earlier I've been using lua squish(does not work well on windows) which extracts the code from each files and puts it in the package.preload table, leaving the require calls as is. Really neat what you've done, but personally I'd prefer it if package.preload was used.
355 posts
Location
Germany
Posted 02 June 2018 - 11:10 PM
I just skimmed through the code. As far as I can tell, require() is not really like a function. It's more like a preprocessor directive (like #pragma once #include "filepath" from C/C++), right?
275 posts
Location
Turkey
Posted 03 June 2018 - 12:26 AM
I just skimmed through the code. As far as I can tell, require() is not really like a function. It's more like a preprocessor directive (like #pragma once #include "filepath" from C/C++), right?
Yes. But I kept the require syntax same so you could run your programs before packing.
275 posts
Location
Turkey
Posted 03 June 2018 - 02:07 PM
So, I just tested this and noticed that you replace every require call with a custom one(__require__). Earlier I've been using lua squish(does not work well on windows) which extracts the code from each files and puts it in the package.preload table, leaving the require calls as is. Really neat what you've done, but personally I'd prefer it if package.preload was used.
(Sorry for the late response, didn't see your post until now)
Doing it like I did
should allow programs to run on older cc versions that don't support require. But the way lua squish does it looks neat as well. I might put an option or something for that sometime.
1610 posts
Posted 03 June 2018 - 07:29 PM
crunch, my bundler uses
package.loaders, so
require can be used as normal for both internal and external modules. Using
package.preload seems potentially dangerous, as they might be loaded in the wrong order.
/shamelessplug
Edited on 03 June 2018 - 05:29 PM
1426 posts
Location
Does anyone put something serious here?
Posted 03 June 2018 - 07:31 PM
Using package.preload seems potentially dangerous, as they might be loaded in the wrong order.
package.preload doesn't cause anything to be evaluated - you just provide a function which can be evaluated to return the module when needed. Dumping into
package.loaded however could cause issues with things loading in the incorrect order (especially if you lazy-load packages).
1610 posts
Posted 03 June 2018 - 07:33 PM
Using package.preload seems potentially dangerous, as they might be loaded in the wrong order.
package.preload doesn't cause anything to be evaluated - you just provide a function which can be evaluated to return the module when needed. Dumping into
package.loaded however could cause issues with things loading in the incorrect order (especially if you lazy-load packages).
Ah, my bad - I got
package.loaded and
package.preload mixed.
275 posts
Location
Turkey
Posted 07 June 2018 - 01:43 PM
reqpack v2:- Compatibility with OC and Lua CLI (no dependencies)
- package.preload support
wget https://gitlab.com/admicos/reqpack/raw/v2/reqpack.lua
Edited on 07 June 2018 - 11:44 AM
275 posts
Location
Turkey
Posted 10 June 2018 - 02:06 PM
reqpack v3:- Ignoring (ignore requires you don't want packed)
- Setting the full package path (instead of appending to the system path)
wget https://gitlab.com/admicos/reqpack/raw/v3/reqpack.lua