10 comments

  • colinmcd 2 hours ago
    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...

    • eyelidlessness 12 minutes ago
      I’m surprised to see this using a `--require` hook (rather than `--import`). Maybe something’s changed significantly since I was looking into building some similar functionality… but it makes me wonder about nuances in nub’s ESM support.

      (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.)

    • awaseem 58 minutes ago
      I saw this on twitter and loved it, such a good move on your part Colin. Hope the project picks up tons of steam!
  • ivanjermakov 48 minutes ago
    Respect for embracing existing tech instead of rewriting a worse version of it. Wonder where we would be today if all alternative-building effort went to Node instead (with proper leadership).
    • hungryhobbit 13 minutes ago
      Fundamentally you can't fix a lot of things with this approach.

      Simple example: Node is the only serious OSS software I know of that has no way to document its config (in the config file itself). It's moronic! The Node people just adopted JSON without a thought, and then refused to consider any alternatives (even "JSON with comments").

      When an organization digs into bad decisions, the only way to fix them is to start something new. The entire JS ecosystem will never have documentation on its config as long as everyone keeps building on top of Node.

      (And there are many other issues like this in the Node ecosystem; the utter absurdity of not being able to document config is just my personal pet peeve.)

  • skybrian 11 minutes ago
    > TypeScript-friendly resolution: extensionless imports, tsconfig.json#paths

    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.)

  • gorjusborg 1 hour ago
    Very smart. You can't lose all your customers for vibe-coding a migration to Rust if you are already written in Rust ;)
    • Zambyte 58 minutes ago
      They'll get bought out by OpenAI and convert the project to Zig
  • ssalbdivad 2 hours ago
    Just merged a PR migrating our entire monorepo to nub.

    0 issues, ridiculously fast.

    • daavin 1 hour ago
      You merged a PR migrating a shared monorepo using this within an hour of it being posted?
      • colinmcd 18 minutes ago
        It entered public beta last week, but just getting on HN now.
  • montroser 23 minutes ago
    Nice. Can we get `nub --compile` up in there like Bun has?
    • colinmcd 19 minutes ago
      Coming very soon!
  • kandros 42 minutes ago
    Love the idea, learning a lot of interesting things about node hooks by reading docs and some code
  • sgarrity 1 hour ago
    I didn't even click on the link. I just came to give the author a hat-tip on the project name. Well played.
    • colinmcd 1 hour ago
      Thanks :) Highly recommend clicking the link too!
  • bookernath 1 hour ago
    Nice, I think this fills a niche. Does it work on cloudflare workers?
    • colinmcd 1 hour ago
      Cloudflare Workers is a different runtime and has its own toolchain around it. Nub could theoretically support it when executing files (spawn `wrangler dev` instead of `node` if wrangler.toml is detected or something) but really I'm focused on making the Node.js experience as good as possible.

      The other pieces of the toolkit could absolutely be used: package manager, script runner, package runner. Works with anything that implements the Node module resolution algorithm (actually Yarn PnP also works out of the box...).

  • GL26 1 hour ago
    nice ! does this work on docker containers ?
    • colinmcd 1 hour ago
      Yep, full support on macOS, Linux, Windows. No official image yet (I'll start on this now) but you can get started with something like this.

        FROM node:26-slim
        RUN npm i -g @nubjs/nub
      
      Works with any Node version down to 18.19 but recommend 22.15+ for best performance (that's when synchronous registerHooks was introduced[0])

      [0] https://nodejs.org/api/module.html#moduleregisterhooksoption...