jhawthorn / actionview_precompiler

Precompiles ActionView templates at app boot for Rails 6+
MIT License
144 stars 11 forks source link

First stab at unifying JRuby internal AST API with MRIs internal #1

Closed enebo closed 5 years ago

enebo commented 5 years ago

RubyVM one. Mostly this starts to abstract the differences into an ast_parser helper which can be included.

Another future experiment is to see how possible it would be to swap out both of these to using something like Ripper.

jhawthorn commented 5 years ago

Thanks Tom! This looks great 🍻

I'm going to look into following up with wrapping the implementation-specific nodes with a ActionviewPrecompiler::ASTParser::Node class. I'm also interested in supporting ripper or whitequark/parser as a third backend, but I'd love to keep this without dependencies beyond ActionView.

jhawthorn commented 5 years ago

Got a working JRuby test for CI https://github.com/jhawthorn/actionview_precompiler/runs/125774749 🎉

enebo commented 5 years ago

@jhawthorn If ripper works then that is a good way to reduce the dependencies. If it is fast enough then it would be a single back end. My motivation was to see how different the two APIs are...the drift is substantial although I think supportable.

eregon commented 5 years ago

@jhawthorn I'm curious, why do you want to avoid the dependency on whitequark/parser? (given that ActionView itself already has many dependencies) I think the parser gem would provide a robust and easy-to-use API, portable across both Ruby implementations and versions. Currently, RubyVM::AbstractSyntaxTree is in a rather unclear state: https://bugs.ruby-lang.org/issues/14844, and the current code would need yet another backend for supporting other Ruby implementations or older MRI versions (if desired).

eregon commented 5 years ago

ripper would also be a more portable alternative, although with a less convenient API than the parser gem.

jhawthorn commented 5 years ago

👍 I'm open to using ripper.

I originally did write this using parser, and it's unfortunately way too slow for how I'd like to use this.

eregon commented 5 years ago

@jhawthorn Makes sense, thanks for replying.

ioquatix commented 4 years ago

As a ruby core developer who has used RubyVM::AST, ripper and parser, I personally prefer parser, but think that either of those gems is a significantly better option than RubyVM::AST which could change and/or be dropped in any version of Ruby. So, please don't depend on RubyVM:: in production code, we will not shield you from pain if such features are dropped/changed.