-
Notifications
You must be signed in to change notification settings - Fork 66
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
Precompilation? #130
Comments
It's not something we've thought about. I haven't checked in detail, but I would guess about half of Moo's source code deals with compilation. The other half is used at runtime. Would 1–2K be small enough? (Of course, this is in addition to the tokenizer RegExp itself.) Sent with GitHawk |
Yes, I think it would. I was also thinking that once I generated a new JS file, I could tweak some things by hand, like removing features I don't need. |
Would Tree-Shaking assist here? |
@bd82 I don't think so, because I want to find a way to have some things (like building the RegExp) happen before runtime. It would be great if there was some way to just save the lexer in a separate JS file after generation. |
Just for fun, here's a Gist which provides a silly (albeit working) approach to compiling a Moo lexer. It's silly because it extracts the Some stats:
|
Thanks @tjvr, that's pretty nifty! I agree the code would probably not be clean enough to merge, but I really like the idea of separate runtime structures. |
Hi @Tvjr! I'm considering using Moo to build a template engine, and wondered if you considered moving the runtime structure outside of the main |
Also, I've recently been digging into the source code. Could you explain what |
@nathan thanks! I seem to remember once running a benchmark that showed that |
@chocolateboy did your thumbs down mean you didn't approve of |
Benchmarks at the time showed that it was slightly faster. It's certainly possible that's changed. |
I'd love to use Moo for a library I'm building, but it needs to be extremely lightweight (even more than 4KB minzipped).
Is there a possibility of adding an option to precompile, a step which would basically
moo.compile
a grammar and then output a generated, more lightweight JS file that could be tweaked and customized?The text was updated successfully, but these errors were encountered: