Show HN: Nub – A Bun-like all-in-one toolkit for Node.js (github.com)
Colin here, creator of Nub. I’ve had the general shape of this in mind for years. Nub runs your code with stock `node`, augmented with a `--require` preload hook[0] that adds a transpiler (oxc-powered, packaged as a Node-API add-on), registers a module resolution hook[1], and injects polyfills as needed for APIs like `Worker`, `Temporal`, etc. All purely additive, your code ultimately runs using Node’s actual engine & stdlib implementations.
[0] https://nodejs.org/api/cli.html#-require-module
[1] https://nodejs.org/api/module.html#moduleregisterhooksoption...
32 comments
[ 0.48 ms ] story [ 36.6 ms ] thread0 issues, ridiculously fast.
(When I was investigating this it was very early in Node’s `--import` story, but there were several edge cases with the more common ESM-to-CJS approaches that I wanted to address. Most were probably exceedingly niche concerns, but I’d expect top-level await to affect a meaningful subset of users.)
I’m wondering how that works. Deno has very complicated import resolution, so building my own import resolver to be compatible with it is a bit of a pain. (This is for a custom lint-like tool.)
https://github.com/unjs/jiti
It would add an extra dependency though
For reference, the main author of Nub is Colin McDonnell who created Zod and even worked at Bun at some point.
https://github.com/nodejs/typescript/issues/51#issuecomment-...
One suggestion, for package management you should just wrap pnpm, my desire to move to anything else is nil.
It feels like this is missing something or using a nonnative library as a supplemental addition.