feat(cli): launch dsh source through the tsx ESM hook

Node 26.0.0 removed --experimental-transform-types, so the native
source-launch chain cannot start anywhere on that line, and strip-only
mode rejects the vendored syntax (parameter properties, decorators,
runtime enums/namespaces). Switch bin/dsh, the root dsh/demo:tui/
demo:web scripts, and the Code Mode TUI overlay to node --import
tsx/esm: one launch vector across the whole engines range, ~0.4s faster
than the full tsx default (the CJS hook stays off; the graph is
ESM-only).

Delete scripts/tspath-loader.ts and apps/cli/src/tsconfig-paths-loader.ts:
tsx owns both transformation and tsconfig paths projection. Add
dsh-source-launch-smoke to the node-compat gates so the 22.19/26 matrix
executes the real launch vector; no CI job did, which is how the Node 26
breakage shipped silently.

Supersedes the native-TypeScript-source-launch Agent Note (new note
records the profiling evidence and rejected alternatives).
This commit is contained in:
kingwl
2026-07-29 13:15:24 +08:00
parent 6ff2c53661
commit aebf9c863b
18 changed files with 148 additions and 429 deletions

17
bin/dsh
View File

@@ -1,7 +1,7 @@
#!/bin/sh
# dsh launcher: runs the apps/cli `dsh` bin FROM SOURCE through Node's native
# TypeScript transform, so a symlink from anywhere (e.g. ~/.local/bin/dsh)
# always executes the current working tree without a build step.
# dsh launcher: runs the apps/cli `dsh` bin FROM SOURCE through the tsx ESM
# hook, so a symlink from anywhere (e.g. ~/.local/bin/dsh) always executes the
# current working tree without a build step.
set -eu
# Resolve symlink chains without readlink -f (not on every macOS).
@@ -15,8 +15,11 @@ while [ -L "$script" ]; do
done
root=$(CDPATH='' cd -- "$(dirname -- "$script")/.." && pwd)
# The preloader projects this checkout's tsconfig paths into Node resolution;
# TypeScript transformation itself remains Node-owned (no tsx/esbuild hook).
exec node --experimental-transform-types \
--import "$root/scripts/tspath-loader.ts" \
# The ESM-only tsx hook transforms TypeScript and projects this checkout's
# tsconfig paths into Node resolution (the CJS hook stays off: the graph is
# ESM-only and the CJS resolver costs ~0.4s of startup). Absolute paths keep
# both the hook and the tsconfig anchored to this checkout when the launcher
# runs from any cwd, where bare `tsx/esm` would not resolve.
TSX_TSCONFIG_PATH="$root/tsconfig.json" \
exec node --import "$root/node_modules/tsx/dist/esm/index.mjs" \
"$root/apps/cli/src/bin.ts" "$@"