PaulBernier / castl

JavaScript to Lua compiler with runtime library.
GNU Lesser General Public License v3.0
372 stars 33 forks source link

Bundling runtime #26

Closed DoctorRyner closed 4 years ago

DoctorRyner commented 4 years ago

Is it possible to bundle runtime into the output file and to not carry around it with a project?

PaulBernier commented 4 years ago

Hi @DoctorRyner, there is currently no option to bundle the runtime into the output file. I haven't followed Lua ecosystem for a while and I don't know if there exists bundling tools similar to what one can find for JavaScript. This project seems interesting in that regard: https://luapower.com/bundle where you could put the output file as the "main" module and the runtime as a regular module. Admittedly I just skimmed through that tool doc and I am not sure if that would fit your need.

DoctorRyner commented 4 years ago

Thanks. I compiled PureScript to JavaScript and JavaScript to Lua using cast. It works great but for some reason, it's somehow complicated to import the whole runtime to use it for scripting in Warcraft 3 Reforged

DoctorRyner commented 4 years ago

Solved it using

http://siffiejoe.github.io/lua-amalg/

PaulBernier commented 4 years ago

Thanks for sharing that link, that's useful.

DoctorRyner commented 4 years ago

Yeah, it should be possible to do something like amalg.lua -o castl.lua ... and distribute it with a single file or even bundle this all into output. But I couldn't make it work with W3 Reforged because they do not support require() natively and community made require() stubs can't deal with a complex modules chaining like in castl :c

DoctorRyner commented 4 years ago

Do you think it's possible to rewrite castl without using require in theory? I mean, how time-consuming that would be?

PaulBernier commented 4 years ago

Isn't exactly what amalg.lua is supposed to do by flattening all the runtime in a single file? I don't think it makes sense to "rewrite" manually castl in a single file without require, and it would also be unmaintainable. That why you need to use a bundling tool.

DoctorRyner commented 4 years ago

Isn't exactly what amalg.lua is supposed to do by flattening all the runtime in a single file?

Yes, it does but it still uses require() and Blizzard doesn't support it, so I can't use it, custom require()s that some people write can't deal with a complex module import chaining like in castl