{"id":22489271,"url":"https://github.com/tbjgolden/xnr","last_synced_at":"2025-04-15T19:42:21.797Z","repository":{"id":37576541,"uuid":"502331338","full_name":"tbjgolden/xnr","owner":"tbjgolden","description":"A fast, zero-config TypeScript runner for easy reliable script execution.","archived":false,"fork":false,"pushed_at":"2024-12-03T12:48:58.000Z","size":1267,"stargazers_count":22,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-29T00:23:38.875Z","etag":null,"topics":["cjs","commonjs","esm","modules","node","run","runner","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tbjgolden.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-06-11T11:38:19.000Z","updated_at":"2024-12-03T12:49:00.000Z","dependencies_parsed_at":"2023-11-22T14:43:30.826Z","dependency_job_id":"56002cb1-2d20-4fa7-afdd-46931d8f7154","html_url":"https://github.com/tbjgolden/xnr","commit_stats":{"total_commits":160,"total_committers":3,"mean_commits":"53.333333333333336","dds":"0.36250000000000004","last_synced_commit":"aea7364e07ac2843500a122483ab4e3b1be4e1b1"},"previous_names":[],"tags_count":25,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tbjgolden%2Fxnr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tbjgolden%2Fxnr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tbjgolden%2Fxnr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tbjgolden%2Fxnr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tbjgolden","download_url":"https://codeload.github.com/tbjgolden/xnr/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248728893,"owners_count":21152316,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cjs","commonjs","esm","modules","node","run","runner","typescript"],"created_at":"2024-12-06T17:19:33.020Z","updated_at":"2025-04-15T19:42:21.776Z","avatar_url":"https://github.com/tbjgolden.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# xnr\n\n![banner](banner.svg)\n\n![npm](https://img.shields.io/npm/v/xnr)\n![npm type definitions](https://img.shields.io/npm/types/xnr)\n![license](https://img.shields.io/npm/l/xnr)\n[![install size](https://packagephobia.com/badge?p=xnr)](https://packagephobia.com/result?p=xnr)\n\nEasily, quickly, and reliably run a TypeScript Node.js script from the CLI with zero configuration.\n_Blazingly fast 🚀_\n\n```sh\nnpx xnr any-file.{ts,tsx,cts,mts,js,jsx,cjs,mjs}\n```\n\nIdeal for **utility scripts**, **quick debugging** and **CI pipelines**\n\n## Key Features\n\n- **Zero configuration**: Run your TypeScript files directly without needing a `tsconfig` file or\n  any additional setup. Ideal for quick scripts or CI tasks\n- **Supports multiple file types**: Easily run any combination of TypeScript, JavaScript, JSON and\n  JSX files\n- **Lightweight**: Very quick to install at just ~400kB\n- **Flexible and familiar**: Tolerant to different file extensions, but otherwise follows Node\n  conventions\n- **Optimised for Speed**: Faster install+execution time than `xnr`\n- **Focused Scope**: Single goal: run TypeScript code quickly and reliably\n- **Supports Windows**\n\n## Getting Started\n\n### Installation\n\nWhile you can use `xnr` directly with `npx`, you can also install it for frequent use:\n\n```sh\nnpm install --save-dev xnr\n```\n\n### Running a Script\n\nSimply use `npx` to run your TypeScript or JavaScript file:\n\n```sh\nnpx xnr file.ts\n```\n\nFor running dev scripts in your package.json:\n\n```json\n{\n  \"scripts\": {\n    \"run\": \"xnr run.ts\"\n  }\n}\n```\n\n## Caveats and Scope\n\n- Only supports dynamic imports or requires with static strings (e.g. `require(\"./file.ts\")` will\n  work but `require(someVar)` will not)\n- Requires Node.js 16.14 or higher (for full ES module support)\n\n## CLI\n\nCLI docs can be viewed at any time by running `xnr --help`.\n\n## API\n\n`xnr` also provides an API with a few more options than the CLI:\n\n```ts\n// Runs a file with auto-transpilation of it and its dependencies, as required.\nconst run: (filePathOrConfig: string | RunConfig) =\u003e Promise\u003cnumber\u003e;\n\n// Converts all local source code starting from an entry file into a directly runnable directory of Node.js compatible code.\nconst build: ({\n  filePath,\n  outputDirectory,\n}: {\n  filePath: string;\n  outputDirectory: string;\n}) =\u003e Promise\u003cOutput\u003e;\n\n// Converts all local source code starting from an entry file into a runnable array of Node.js compatible file contents.\nconst transpile: ({ filePath }: { filePath: string }) =\u003e Promise\u003cOutput\u003e;\n\n// Transforms an input code string into a Node-friendly ECMAScript Module (ESM) code string. Unlike the others here, it doesn't rewrite imports.\nconst transform: ({ code, filePath }: { code: string; filePath?: string }) =\u003e Promise\u003cstring\u003e;\n```\n\nA complete list of exports can be viewed on\n[`npmjs.com`](https://www.npmjs.com/package/xnr?activeTab=code) (navigate to\n/xnr/dist/lib/index.d.ts)\n\n## Jest transformer\n\nAdd these lines to your jest config to get easy TS transforms:\n\n```json\n{\n  // ...\n  \"extensionsToTreatAsEsm\": [\".ts\"],\n  \"transform\": {\n    \"\\\\.ts$\": \"\u003crootDir\u003e/node_modules/xnr/dist/jest.js\"\n  }\n  // ...\n}\n```\n\n## Key benchmarks\n\n| runner   | run single file | run small project | install size | install time |\n| -------- | --------------: | ----------------: | -----------: | -----------: |\n| xnr      |          `93`ms |           `102`ms |      `0.4`MB |   very quick |\n| tsx      |         `142`ms |           `146`ms |     `29.7`MB |         slow |\n| swc-node |         `232`ms |           `235`ms |     `62.0`MB |    very slow |\n| ts-node  |         `661`ms |           `659`ms |      `6.7`MB |        quick |\n\nIn general, you can expect best-in-class install + run time.\n\n## Contributing\n\nFeel free to open issues if you encounter bugs or have suggestions for new features.\n\n## Licence\n\nApache-2.0\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftbjgolden%2Fxnr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftbjgolden%2Fxnr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftbjgolden%2Fxnr/lists"}