bone.recipes



JS cheat sheet

Bundling

When to bundle:

When not to bundle:

By "callable script" in the above lists, I mean something that's exported via the "bin" field in the project's package.json and which is installable via npm link or npm i -g.

Seeing progress in execSync in realtime

By default, execSync only shows its work when it's done. But you can encourage it to display updates in realtime like this:

import { execSync } from "node:child_process"
execSync(`...`, { stdio: "inherit" })

Adding path aliases for imports

In package.json:

{
  "imports": {
    "#root/*": "./*",
    "#foo/*": "./path/to/foo/*",
    "#bar/*": "./some/other/path/to/bar/*"
  }
}

Then in some deep file:

import { something } from "#root/some/path"