phoenix-ru / fervid

All-in-One Vue compiler written in Rust
https://phoenix-ru.github.io/fervid/
Apache License 2.0
371 stars 9 forks source link

feat: initialize node.js binding #2

Closed cijiugechu closed 1 year ago

phoenix-ru commented 1 year ago

Hi @cijiugechu, thanks for your PR!

It does look promising, there's only one thing I'd like to change: as NAPI-rs usually relies on @scoped package, I'd probably do the @fervid prefix instead of fervid-.

I will take a closer look this weekend, much appreciated.

phoenix-ru commented 1 year ago

Checked and merged the PR. Wow. Thanks, amazing work :fire:

Couldn't leash my curiosity on the bench script and actually ran it. Quite satisfied with the results, to say the least:

  @vue/compiler-sfc:
    1 769 ops/s, ±1.21%    | slowest, 87.45% slower

  @fervid/napi:
    14 099 ops/s, ±0.47%   | fastest

Just small notes to anyone reading this thread somehow

The current implementation is already 8x faster than the reference, all while being more robust than the original because it operates on actual JS syntax trees instead of string + regex (which caused lots of bugs if you look at the tickets).

14K ops/sec is just a beginning, but a very solid one. The current raw performance is 18K, and there's still plenty of room for optimizations. Pull Requests are welcome!

phoenix-ru commented 1 year ago

@cijiugechu By the way, if you want to be featured in the authors field of Cargo.toml (here https://github.com/phoenix-ru/fervid/blob/master/crates/fervid_napi/Cargo.toml), you can write your name here, I'll add it. Of course, if you want to.

cijiugechu commented 1 year ago

@cijiugechu By the way, if you want to be featured in the authors field of Cargo.toml (here https://github.com/phoenix-ru/fervid/blob/master/crates/fervid_napi/Cargo.toml), you can write your name here, I'll add it. Of course, if you want to.

Yes, I'd love to😄