Jump to content




reqpack: Package all your requirements into a single file without any installers


  • You cannot reply to this topic
9 replies to this topic

#1 Admicos

  • Members
  • 207 posts
  • LocationTurkey

Posted 01 June 2018 - 10:19 PM

reqpack allows you to package all your requirements (require() calls) into a single file

NOTE

I made this in about an hour out of a random idea i had, so this might not be very reliable, YMMV.


USAGE

reqpack <filename>


CONFIGURATION

Create the configuration file using reqpack --extract-conf. All options should be pretty self explanatory


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

wget (latest): https://gitlab.com/a.../v3/reqpack.lua

wget (v2): https://gitlab.com/a.../v2/reqpack.lua

wget (v1): https://gitlab.com/a.../v1/reqpack.lua


packman: admicos/reqpack


Edited by Admicos, 10 June 2018 - 01:12 PM.


#2 Janne

  • Members
  • 4 posts

Posted 02 June 2018 - 03: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.

#3 InDieTasten

  • Members
  • 357 posts
  • LocationGermany

Posted 02 June 2018 - 10: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?

#4 Admicos

  • Members
  • 207 posts
  • LocationTurkey

Posted 02 June 2018 - 11:26 PM

View PostInDieTasten, on 02 June 2018 - 10:10 PM, said:

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.

#5 Admicos

  • Members
  • 207 posts
  • LocationTurkey

Posted 03 June 2018 - 01:07 PM

View PostJanne, on 02 June 2018 - 03:32 PM, said:

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.

#6 apemanzilla

  • Members
  • 1,421 posts

Posted 03 June 2018 - 06: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 by apemanzilla, 03 June 2018 - 06:29 PM.


#7 SquidDev

    Frickin' laser beams | Resident Necromancer

  • Members
  • 1,427 posts
  • LocationDoes anyone put something serious here?

Posted 03 June 2018 - 06:31 PM

View Postapemanzilla, on 03 June 2018 - 06:29 PM, said:

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).

#8 apemanzilla

  • Members
  • 1,421 posts

Posted 03 June 2018 - 06:33 PM

View PostSquidDev, on 03 June 2018 - 06:31 PM, said:

View Postapemanzilla, on 03 June 2018 - 06:29 PM, said:

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.

#9 Admicos

  • Members
  • 207 posts
  • LocationTurkey

Posted 07 June 2018 - 12: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 by Admicos, 07 June 2018 - 12:44 PM.


#10 Admicos

  • Members
  • 207 posts
  • LocationTurkey

Posted 10 June 2018 - 01: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






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users