starlight icon indicating copy to clipboard operation
starlight copied to clipboard

Support for dynamically loading MoonScript modules.

Open darmie opened this issue 8 years ago • 4 comments

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?

darmie avatar Apr 14 '16 08:04 darmie

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.

paulcuth avatar Apr 18 '16 07:04 paulcuth

Cool, looking forward to it.

darmie avatar Apr 18 '16 07:04 darmie

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.

pablomayobre avatar Oct 09 '16 05:10 pablomayobre

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

darmie avatar Aug 08 '17 02:08 darmie