Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
},
"scripts": {
"build": "tsc && node -e \"require('fs').writeFileSync('dist/index.cjs',require('fs').readFileSync('src/index.cjs','utf8').replaceAll('./index.ts','./index.js'))\"",
"build:wasm": "node --experimental-strip-types scripts/build-wasm.ts",
"build:wasm": "node scripts/node-ts.js scripts/build-wasm.ts",
"typecheck": "tsc --noEmit",
"verify-imports": "node --experimental-strip-types scripts/verify-imports.ts",
"verify-imports": "node scripts/node-ts.js scripts/verify-imports.ts",
"test": "vitest run",
"test:watch": "vitest",
"test:coverage": "vitest run --coverage",
Expand All @@ -42,10 +42,10 @@
"prepack": "npm run build",
"clean": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true});require('fs').rmSync('.tsbuildinfo',{force:true})\"",
"prepare": "npm run build:wasm && npm run build && husky && npm run deps:tree",
"deps:tree": "node --experimental-strip-types scripts/gen-deps.ts",
"deps:tree": "node scripts/node-ts.js scripts/gen-deps.ts",
"release": "commit-and-tag-version",
"release:dry-run": "commit-and-tag-version --dry-run",
"version": "node --experimental-strip-types scripts/sync-native-versions.ts && git add package.json crates/codegraph-core/Cargo.toml"
"version": "node scripts/node-ts.js scripts/sync-native-versions.ts && git add package.json crates/codegraph-core/Cargo.toml"
},
"keywords": [
"codegraph",
Expand Down
24 changes: 24 additions & 0 deletions scripts/node-ts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env node
// node-ts.js — Version-aware TypeScript launcher
// Uses --strip-types on Node 23+ and --experimental-strip-types on Node 22.x.
// Usage: node scripts/node-ts.js <script.ts> [args...]

import { execFileSync } from "node:child_process";

const [major] = process.versions.node.split(".").map(Number);
const flag = major >= 23 ? "--strip-types" : "--experimental-strip-types";
const [script, ...args] = process.argv.slice(2);

if (!script) {
console.error("Usage: node scripts/node-ts.js <script.ts> [args...]");
process.exit(1);
}

try {
execFileSync(process.execPath, [flag, script, ...args], {
stdio: "inherit",
env: process.env,
});
} catch (err) {
process.exit(err.status ?? 1);
}
Loading