starlight
starlight copied to clipboard
Support for dynamically loading MoonScript modules.
Hi, have been able to use moonscript directly, using the MoonScript parser + StarLight parser. But I want to be able to require a module written in MoonScript dynamically without having to compile it to Lua.
Is there a way around this?
This is an interesting challenge; if I understand correctly, the MoonScript parser is written in Lua and therefore could be translated to run in the browser using Starlight. Once in the browser, there's no reason why it couldn't be used to process MoonScript tags before parsing with Starlight.
The job would be made easier if Starlight provided some lifecycle hooks along the way. I'll have play with this and let you know.
Cool, looking forward to it.
This is not that easy, Moonscript uses LPeg which is a binary library, this is the reason Moonscript has a .dll
file in Windows and most likely a .so
file in Linux.
There exists an alternative to LPeg written entirely in Lua called Lulpeg, I don't know how efficient that would be or if it does use functions not available in Starlight or missing some feature Moonscript needs, but checking if it works may be worth the effort.
@Positive07 I was able to achieve compiling Moonscript in a browser. There is a Moonscript compiler JavaScript port, which is currently in use on moonscript.org
The issue here however, is how to dynamically require
a .moon
module within Starlight framework.