Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add some way to bundle multiple .tl scripts as one Lua file? #67

Open
pdesaulniers opened this issue Mar 10, 2020 · 7 comments
Open

Add some way to bundle multiple .tl scripts as one Lua file? #67

pdesaulniers opened this issue Mar 10, 2020 · 7 comments
Labels
feature request New feature or request

Comments

@pdesaulniers
Copy link
Member

pdesaulniers commented Mar 10, 2020

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.

@pdesaulniers pdesaulniers changed the title Add some way to bundle multiple .tl scripts as one file? Add some way to bundle multiple .tl scripts as one Lua file? Mar 10, 2020
@hishamhm hishamhm added the feature request New feature or request label Mar 13, 2020
@hishamhm
Copy link
Member

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!

@ashn-dot-dev
Copy link

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
Copy link

jirutka commented Mar 28, 2020

This can be achieved using luapak merge.

@hishamhm
Copy link
Member

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

@jirutka
Copy link

jirutka commented Mar 30, 2020

A stable programmatic API would be better. :)

@siffiejoe
Copy link

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

@hishamhm
Copy link
Member

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants