- Tue May 05, 2015 7:22 am
#16549
One immediate point to note from this is that there are two methods of saving compiled Lua to flash
- the first is to use node.compile() on the lua file
- the second is to use loadfile() to load it, then use string.dump()to convert it in-RAM to a serialised load format and then write this back to the file system.
It is well worth noting that these do
not generate the same output. Basically, option (1) strips out all line and variable information, that the runtime error system uses to report line numbers, etc. and the second doesn't. What this means is that (1) is typically 60% the size of [2], but that any runtime errors are extremely limited.
So my recommendation is to use (1) if you have stable production code that you want to run in as low a RAM footprint as possible and (2) if you are still debugging, but want to avoid compilation overhead as any errors will be reported just the same as with load-and-go lua source.
Please see my
Developer FAQ for Q&A on nodeMCU Lua before asking a question here that's already been answered. This and the other official documentation should be your first reference for developing Lua Apps