From 21d2b207be030f6cd8a1e33783b21c375c0988e5 Mon Sep 17 00:00:00 2001 From: Matteo Collina Date: Fri, 13 Feb 2026 08:53:50 +0000 Subject: [PATCH] docs: document module.register bootstrap usage --- README.md | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 0079b2880..75653766d 100644 --- a/README.md +++ b/README.md @@ -41,11 +41,31 @@ node --import="amaro/strip" file.ts Enabling TypeScript feature transformation: ```bash -node --experimental-transform-types --import="amaro/transform" file.ts +node --enable-source-maps --import="amaro/transform" file.ts ``` -> Note that the "amaro/transform" loader should be used with `--experimental-transform-types` flag, or -> at least with `--enable-source-maps` flag, to preserve the original source maps. +> Note that the `amaro/transform` loader should be used with `--enable-source-maps` +> to preserve accurate source-mapped stack traces. + +#### Programmatic registration with `module.register()` + +If you want TypeScript to "just work" in an existing codebase without passing `--import` every time, create a small bootstrap file and register Amaro once before loading your TS entrypoint. + +```mjs +// bootstrap.mjs +import { register } from "node:module"; + +register("amaro/strip", import.meta.url); +await import("./src/index.ts"); +``` + +Then start your app through the bootstrap file: + +```bash +node --watch ./bootstrap.mjs +``` + +For transform mode, swap `amaro/strip` with `amaro/transform` and run Node with `--enable-source-maps`. #### Type stripping in dependencies