aleclarsoniv
Joined 13 years ago
Joined 13 years ago
If anyone has any feedback on the design, I'd be interested in hearing it. Or if you have questions about design choices, I can answer them. Thanks for reading!
[1]: https://github.com/aleclarson/dough
P.S. If you can cope with jQuery in a medium/large app, good for you. But it's not my cup of tea.
In my case, building an RPC library with REST semantics, it's important to me to not place any restrictions on how developers pass their data to the backend. So removing that arbitrary flattening requirement is a big win. The json-qs specification does it in a way that balances readability and compactness.
I've found it helps a lot when writing a library that takes advantage of compile-time code generation. In the future, I think it could be cool to try and integrate jumpgen with bundlers, like Vite or Rollup, so your file generator can be used as a bundler plugin. Currently, jumpgen “generators” only have a programmatic API, but jumpgen will have a CLI as well, if you think that could be useful. Mostly though, jumpgen is intended as a “white label” library that is contained by your own CLI, if you have one.
# Motivation
Code generation can be useful for many tasks. I'm using code generation in my own libraries, pg-nano[1] and alien-rpc (in development). In pg-nano, I'm generating TypeScript functions that mirror Postgres functions (aka UDFs). In alien-rpc, I'm generating runtime metadata for RPC-style API routing.
I could not find a library that simplifies the task of writing a code generator, so I made jumpgen.
# What It Does
It's designed to handle the burdens of implementing a “watch mode” for your generators. It also returns an event emitter, especially useful for logging. Your generator is free to work in relative paths, since jumpgen handles path resolution according to a user-provided root directory.
It tracks which files your generator has read into memory and which directories your generator has listed. When those files/directories are changed or have files added/removed, your generator will rerun automatically (if watch mode is enabled). This even works with globs!
I've also included a "dedent" helper function so you can indent any template literal without that excess indentation carrying over into the emitted files.
# Feedback Wanted
If this sounds interesting to you, I'd love to hear any comments or criticisms about the API, the readme, or whatever else. Thanks!
Currently developing:
* radashi <https://github.com/radashi-org/radashi>
* pg-nano <https://github.com/pg-nano/pg-nano>
* alien-rpc <https://github.com/alloc/alien-rpc>
Currently maintaining:
* jumpgen <https://github.com/alloc/jumpgen>
* alien-dom <https://github.com/alloc/alien-dom>
Previously maintained:
* vite (core team from v0 til v4)
* immer (co-author)
* react-spring (co-author)