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

Runtime only? #530

Closed
rkyoku opened this issue Feb 12, 2018 · 8 comments
Closed

Runtime only? #530

rkyoku opened this issue Feb 12, 2018 · 8 comments

Comments

@rkyoku
Copy link

rkyoku commented Feb 12, 2018

Hi there,

Checking Twig-like isomorphic template engines, and found twig.js

It seemed to finally compile (when specifying every argument, especially the --pattern argument).

But then I wondered: where is the runtime library? Since the compiled templates seem to refer to a twig() function, it seems I need a runtime of some kind.

But even just the twig.core.js file weighs around 50kB.

What file(s) am I supposed to include to render a precompiled template?

Thanks a lot,

@mortenson
Copy link
Contributor

I'm working on this, for what it's worth. Hoping to have a PR soon.

@mortenson
Copy link
Contributor

mortenson commented Apr 28, 2018

@dave-irvine I've been working on this in my fork, on the no-compiler branch: https://github.com/mortenson/twig.js/tree/no-compiler

It splits parsing/compiling+loading methods into different files, and creates a new bundle (twig.production.min.js) that's about 28k smaller than twig.min.js, and seems to work. Tests are also passing.

Is this something that you would want me to add new test coverage for and submit a PR? The restructuring required to accomplish this was intensive so I want to make sure this is a direction you'd be interesting in going.

@dave-irvine
Copy link
Contributor

@mortenson my role here is now mostly that of glorified PR accepter and build publisher :) if what you have works, and you've added tests for it, as long as you will be happy to support it to some degree if it turns out to break something existing, I don't have a problem putting it in.

Try @'img some of the more active members and see if they have input. @willrowe @olets (I'm on mobile so no autocomplete on names)

@willrowe
Copy link
Collaborator

This is an interesting idea. It would be great to have an example of how this could be used, I'm especially interested in how the pre-compiled templates would be delivered to the parser.

@mortenson
Copy link
Contributor

@willrowe I wrote some in the README, and the test coverage shows an example as well. A quick way to see this working is to set up a Webpack project with twig-loader, mark Twig as external, and include twig.production.min.js from the PR in your HTML. Things should just work normally, with a smaller payload for the client.

@willrowe
Copy link
Collaborator

willrowe commented May 1, 2018

Thanks, I'll take a look over this when I get a chance.

@olets
Copy link
Member

olets commented May 1, 2018

Sounds neat! I think willrowe's in a better position than me to evaluate this one

@willrowe
Copy link
Collaborator

If the project is eventually moved towards more modern ES modules, that should resolve this issue.

@willrowe willrowe closed this as not planned Won't fix, can't repro, duplicate, stale Jul 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants