Open pdesaulniers opened 4 years ago
I think it would be nice if we could use a command-line argument to bundle multiple tl scripts as a single Lua file. TypeScript supports this by using the --outFile argument.
That would be a cool feature, but would probably accelerate to the desire of some sort of source maps, because the line numbers in the tracebacks when running tl code would not match the input anymore (so this is a feature request that triggers another feature request :) ). Still, a patch would be welcome!
If this feature gets implemented, then tl's source code could be split into multiple files. This would probably make the code a bit easier to browse.
I'm still a bit on the fence for that tbh, but it's a thought to consider for sure!
Just my 2¢: I think bundling should be handled by a separate utility.
Mapping .tl
files one-to-one onto .lua
files fits the textbook definition of a compiler and seems to align well with the Unix philosophy.
Bundling doesn't particularly sound like something that needs to be integrated into the compiler, or really even something that needs to be Teal-exclusive.
I think the use case is valid, but perhaps that use case could be addressed by a separate utility under the teal-language
family: that way the compiler can be kept minimal.
@jirutka would love to see luapak eventually convert .tl files to .lua in that same step! :) Do you think os.execute
to run tl gen
would suffice or would a stable programmatic API would make more sense?
A stable programmatic API would be better. :)
I have recently added 3rd-party plugin support to a tool of mine that can bundle multiple Lua modules into one Lua file. Apparently, those plugins can also be used to transpile files in a Lua dialect on-the-fly during amalgamation. As a proof-of-concept, I have added plugins for moonscript, fennel, and teal.
AFAICS, a similar approach could be used with luapak -- maybe even with the same plugins.
Regarding stable API: I've only used tl.gen()
, its result.syntax_errors
return value, and the fields of the individual syntax errors (see here).
Regarding stable API: I've only used tl.gen(), its result.syntax_errors return value, and the fields of the individual syntax errors (see here).
@siffiejoe that should be fine!
I think it would be nice if we could use a command-line argument to bundle multiple tl scripts as a single Lua file. TypeScript supports this by using the
--outFile
argument.Right now, tl's source code is contained inside a single .tl file. If this feature gets implemented, then tl's source code could be split into multiple files. This would probably make the code a bit easier to browse.