Repository: privatenumber/tsx Branch: master Commit: 938e46c21e2f Files: 127 Total size: 263.6 KB Directory structure: gitextract_cdughvzf/ ├── .editorconfig ├── .github/ │ ├── DISCUSSION_TEMPLATE/ │ │ └── q-a.yml │ ├── ISSUE_TEMPLATE/ │ │ ├── bug-report.yml │ │ └── config.yml │ ├── renovate.json │ └── workflows/ │ ├── lock-threads.yml │ ├── release.yml │ └── test.yml ├── .gitignore ├── .nvmrc ├── .vscode/ │ └── settings.json ├── CONTRIBUTING.md ├── FUNDING.json ├── LICENSE ├── README.md ├── docs/ │ ├── .vitepress/ │ │ ├── config.ts │ │ └── theme/ │ │ ├── components/ │ │ │ ├── AsideSponsors.vue │ │ │ ├── ContactForm.vue │ │ │ ├── ImageLink.vue │ │ │ ├── Marquee.vue │ │ │ └── Sponsors.vue │ │ ├── index.ts │ │ └── styles.css │ ├── compilation.md │ ├── contact.md │ ├── dev-api/ │ │ ├── entry-point.md │ │ ├── index.md │ │ ├── node-cli.md │ │ ├── register-cjs.md │ │ ├── register-esm.md │ │ ├── ts-import.md │ │ └── tsx-require.md │ ├── faq.md │ ├── getting-started.md │ ├── index.md │ ├── learn.md │ ├── node-enhancement.md │ ├── package.json │ ├── postcss.config.js │ ├── scripts/ │ │ └── hash-class-names.js │ ├── shell-scripts.md │ ├── tailwind.config.js │ ├── typescript.md │ ├── vscode.md │ └── watch-mode.md ├── package.json ├── pnpm-workspace.yaml ├── release.config.cjs ├── src/ │ ├── @types/ │ │ ├── es-module-lexer.d.ts │ │ └── module.d.ts │ ├── cjs/ │ │ ├── api/ │ │ │ ├── index.ts │ │ │ ├── module-extensions.ts │ │ │ ├── module-resolve-filename/ │ │ │ │ ├── index.ts │ │ │ │ ├── interop-cjs-exports.ts │ │ │ │ ├── is-from-cjs-lexer.ts │ │ │ │ ├── preserve-query.ts │ │ │ │ ├── resolve-implicit-extensions.ts │ │ │ │ └── resolve-ts-extensions.ts │ │ │ ├── register.ts │ │ │ ├── require.ts │ │ │ └── types.ts │ │ └── index.ts │ ├── cli.ts │ ├── esm/ │ │ ├── api/ │ │ │ ├── index.ts │ │ │ ├── register.ts │ │ │ ├── scoped-import.ts │ │ │ └── ts-import.ts │ │ ├── hook/ │ │ │ ├── index.ts │ │ │ ├── initialize.ts │ │ │ ├── load.ts │ │ │ ├── package-json.ts │ │ │ ├── resolve.ts │ │ │ └── utils.ts │ │ ├── index.ts │ │ └── types.ts │ ├── loader.ts │ ├── patch-repl.ts │ ├── preflight.cts │ ├── remove-argv-flags.ts │ ├── repl.ts │ ├── run.ts │ ├── source-map.ts │ ├── suppress-warnings.cts │ ├── types.ts │ ├── utils/ │ │ ├── debug.ts │ │ ├── es-module-lexer.ts │ │ ├── ipc/ │ │ │ ├── client.ts │ │ │ ├── get-pipe-path.ts │ │ │ └── server.ts │ │ ├── is-windows.ts │ │ ├── map-ts-extensions.ts │ │ ├── node-features.ts │ │ ├── path-utils.ts │ │ ├── read-json-file.ts │ │ ├── sha1.ts │ │ ├── temporary-directory.ts │ │ ├── transform/ │ │ │ ├── apply-transformers.ts │ │ │ ├── cache.ts │ │ │ ├── get-esbuild-options.ts │ │ │ ├── index.ts │ │ │ └── transform-dynamic-import.ts │ │ ├── tsconfig.ts │ │ └── url-search-params-stringify.ts │ └── watch/ │ ├── index.ts │ └── utils.ts ├── tests/ │ ├── fixtures/ │ │ └── test.wasm │ ├── fixtures.ts │ ├── index.ts │ ├── specs/ │ │ ├── api.ts │ │ ├── cli.ts │ │ ├── loaders.ts │ │ ├── repl.ts │ │ ├── smoke.ts │ │ ├── transform.ts │ │ ├── tsconfig.ts │ │ └── watch.ts │ └── utils/ │ ├── coverage-sources-content.ts │ ├── expect-match-in-order.ts │ ├── get-node.ts │ ├── is-process-alive.ts │ ├── is-windows.ts │ ├── node-versions.ts │ ├── package-types.ts │ ├── process-interact.ts │ ├── pty-shell/ │ │ └── index.ts │ └── tsx.ts └── tsconfig.json ================================================ FILE CONTENTS ================================================ ================================================ FILE: .editorconfig ================================================ root = true [*] indent_style = tab end_of_line = lf charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true [*.yml] indent_style = space indent_size = 2 ================================================ FILE: .github/DISCUSSION_TEMPLATE/q-a.yml ================================================ body: - type: markdown attributes: value: | ## 💬 What's your question?
Need some pointers on crafting your question?
1. **Start succinctly:** Jump to the point with a concise question. 2. **Conciseness matters:** Keep it brief yet specific; avoid lengthy explanations. 3. **Include code:** Attach relevant code snippets, configurations, and errors. 4. **Add screenshots:** If applicable, provide screenshots.
- type: textarea id: improvements attributes: label: Question validations: required: true - type: markdown attributes: value: |
> **🚀 Try _Priority Support_!** > > If you're in a pinch, don't hesitate to take advantage of my [_Priority Support_ service](https://github.com/sponsors/privatenumber) where you can ask me questions in an exclusive forum. I'm well equppied to assist you with this project and would be happy to help you out! 🙂 ================================================ FILE: .github/ISSUE_TEMPLATE/bug-report.yml ================================================ name: 🐛 Bug report description: Found a bug? File a report and let's get it fixed! labels: [bug, pending triage] body: - type: markdown attributes: value: | 💁‍♂️ This is a collaborative effort. Please do your best to debug, communicate, and demonstrate the problem. - type: checkboxes attributes: label: Acknowledgements options: - label: I read the documentation and searched existing issues to avoid duplicates required: true - label: I understand this is a **bug tracker** and anything other than a proven bug will be closed required: true - label: I understand this is a free project and relies on community contributions required: true - label: I read and understood the [Contribution guide](https://github.com/privatenumber/tsx/blob/master/CONTRIBUTING.md) required: true - type: markdown attributes: value: | ## 📋 Show us the bug > [!CAUTION] > Without proving the bug is in tsx via *minimal* reproduction, your issue will be closed without response. The minimal reproduction is the core of your issue. This is usually all we read. The first thing we'll do is scrutinize every code, file, and dependency to see how they impact the bug. If you can delete it and still produce the bug, it's not needed. **Starter Template**: [Fork this StackBlitz template](https://stackblitz.com/edit/node-huzszn?file=index.ts) If it's not reproducible on StackBlitz, upload it to a GitHub repository and use GitHub Actions to show the error. Please do your best to _show_ the bug rather than talking about it. This will lead to a speedy resolution. - type: input attributes: label: Minimal reproduction URL placeholder: https://github.com/... validations: required: true - type: markdown attributes: value: | > [!TIP] > **🙋 Need help?** Use [_Priority Support_](https://github.com/sponsors/privatenumber) for debugging help and implementation! - type: markdown attributes: value: | ## 🗒️ Notes > [!IMPORTANT] > Please skip this section and focus on minimizing the reproduction. We only read it _after_ verifying the reproduction above. - type: textarea attributes: label: Problem & expected behavior (under 200 words) value: | Skip this section and let your reproduction do the talking... But if you really need to explain, keep it under 200 words: - What happened - What I expected - Error stack trace - Documentation links - Screenshots - type: markdown attributes: value: | ## 🛠️ Contribute - type: checkboxes attributes: label: Bugs are expected to be fixed by those affected by it options: - label: I'm interested in working on this issue - type: checkboxes attributes: label: Compensating engineering work will speed up resolution and support the project options: - label: I'm willing to offer $10 for financial support - type: markdown attributes: value: | ## 🚀 Need immediate help? Escalate this issue by supporting the project as a [_Priority Patron_](https://github.com/sponsors/privatenumber)! Your concern will receive prompt attention, ensuring faster and more efficient resolution. [→ Become a _Priority Patron_!](https://github.com/sponsors/privatenumber) ================================================ FILE: .github/ISSUE_TEMPLATE/config.yml ================================================ blank_issues_enabled: false contact_links: - name: 💖 [Sponsors only] Feature requests / Help / Questions url: https://github.com/sponsors/privatenumber/ about: Need help ASAP? Get prioritized help for all your questions and issues! - name: 📚 Contribution guide url: https://github.com/privatenumber/tsx/blob/develop/CONTRIBUTING.md about: Learn more about contributing to this project ================================================ FILE: .github/renovate.json ================================================ { "$schema": "https://docs.renovatebot.com/renovate-schema.json", "enabledManagers": ["nvm"] } ================================================ FILE: .github/workflows/lock-threads.yml ================================================ name: Lock threads on: workflow_dispatch: schedule: - cron: "0 0 * * 0" # Every Sunday jobs: lock: runs-on: ubuntu-latest permissions: issues: write pull-requests: write discussions: write steps: - uses: dessant/lock-threads@v5 with: github-token: ${{ github.token }} issue-inactive-days: "91" add-issue-labels: outdated pr-inactive-days: "91" add-pr-labels: outdated discussion-inactive-days: "91" add-discussion-labels: outdated log-output: "true" ================================================ FILE: .github/workflows/release.yml ================================================ name: Release on: push: branches: [master, develop] permissions: contents: write jobs: release: name: Release if: ( github.repository_owner == 'pvtnbr' && github.ref_name =='develop' ) || ( github.repository_owner == 'privatenumber' && github.ref_name =='master' ) runs-on: ubuntu-latest timeout-minutes: 10 steps: - name: Checkout uses: actions/checkout@v4 with: token: ${{ secrets.GH_TOKEN }} - name: Use Node.js uses: actions/setup-node@v4 with: node-version-file: .nvmrc - name: Setup pnpm uses: pnpm/action-setup@v4 with: run_install: true - name: Lint run: pnpm lint - name: Prerelease to GitHub if: github.repository_owner == 'pvtnbr' run: | git remote add public https://github.com/$(echo $GITHUB_REPOSITORY | sed "s/^pvtnbr/privatenumber/") git fetch public master 'refs/tags/*:refs/tags/*' git push --force --tags origin refs/remotes/public/master:refs/heads/master jq ' .publishConfig.registry = "https://npm.pkg.github.com" | .name = ("@" + env.GITHUB_REPOSITORY_OWNER + "/" + .name) | .repository = env.GITHUB_REPOSITORY | .release.branches = [ "master", { name: "develop", prerelease: "rc", channel: "latest" } ] ' package.json > _package.json mv _package.json package.json - name: Release env: GH_TOKEN: ${{ secrets.GH_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }} run: pnpm dlx semantic-release@24 ================================================ FILE: .github/workflows/test.yml ================================================ name: Test on: push: branches: [master, develop] pull_request: jobs: test: name: Test runs-on: ${{ matrix.os }} strategy: matrix: os: [ubuntu-latest, windows-latest] timeout-minutes: 10 steps: - name: Checkout uses: actions/checkout@v4 - name: Use Node.js uses: actions/setup-node@v4 with: node-version-file: .nvmrc - name: Authenticate GitHub registry run: npm set "//npm.pkg.github.com:_authToken=${{ secrets.GH_TOKEN }}" - name: Setup pnpm uses: pnpm/action-setup@v4 - name: Get pnpm store directory shell: bash run: echo "PNPM_STORE=$(pnpm store path --silent)" >> $GITHUB_ENV - name: Restore pnpm cache id: pnpm-cache uses: actions/cache@v3 with: path: ${{ env.PNPM_STORE }} key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }} restore-keys: ${{ runner.os }}-pnpm- - name: Install dependencies run: pnpm install - name: Save pnpm cache if: steps.pnpm-cache.outputs.cache-hit != 'true' uses: actions/cache/save@v3 with: path: ${{ env.PNPM_STORE }} key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }} - name: Get Node.js cache directory shell: bash run: echo "NVE_CACHE=$(node -p 'require("cachedir")("nve")')" >> $GITHUB_ENV - name: Cache Node.js versions uses: actions/cache@v3 with: path: ${{ env.NVE_CACHE }} key: ${{ runner.os }}-nodejs-${{ hashFiles('.nvmrc') }}-${{ hashFiles('tests/utils/node-versions.ts') }} restore-keys: ${{ runner.os }}-nodejs- - name: Test run: pnpm test - name: Type check if: ${{ matrix.os == 'ubuntu-latest' }} run: pnpm type-check - name: Lint if: ${{ matrix.os == 'ubuntu-latest' }} run: pnpm lint ================================================ FILE: .gitignore ================================================ # macOS .DS_Store # Logs logs *.log npm-debug.log* yarn-debug.log* yarn-error.log* lerna-debug.log* # Dependency directories node_modules # Output of 'npm pack' *.tgz # dotenv environment variables file .env .env.test # Cache .eslintcache # Distribution dist # Link config link.config.json # Vitepress docs/.vitepress/cache ================================================ FILE: .nvmrc ================================================ 20.19.3 ================================================ FILE: .vscode/settings.json ================================================ { "typescript.tsdk": "node_modules/typescript/lib" } ================================================ FILE: CONTRIBUTING.md ================================================ # Contribution guide Welcome! We're excited you're interested in contributing. To ensure a smooth and productive collaboration, follow these guidelines. ## Goals of tsx 1. Enhance Node.js with TypeScript support 2. Improve ESM ↔ CommonJS interoperability as the ecosystem migrates to ESM 3. Support the [active LTS versions of Node.js](https://endoflife.date/nodejs) ## Issues & Discussions > [!IMPORTANT] > Please be polite, respectful, and considerate of people's time and effort. > > This is an open source project relying on community contributions. ### Opening a new Issue > [!IMPORTANT] > The Issues tab is a bug & feature tracker. Not a place for debugging support. To keep threads concise and easy to follow for collaborators, please participate constructively and follow the guidelines. #### Minimal reproduction required Provide a clear, minimal example of the issue. This helps contributors identify genuine bugs efficiently. #### Check the documentation Review the project documentation for known behaviors or caveats to avoid unnecessary issues. ### Commenting on an existing Issue #### ⭐️ Issue objectives Issues serve as a platform for **contributors** to: 1. Verify bugs 2. Diagnose the causes 3. Brainstorm solutions 4. Implement fix #### ✅ Be constructive Aim to contribute to the solution with research & PRs (tests + solutions). The goal is to land an improvement in _tsx_ for everyone to benefit. Be concise to save people's time. #### ❌ Avoid detractive comments Keep comments constructive towards fixing the issue. These types of comments will be hidden or deleted: - Comments that pollute the thread (e.g. "updates?", "me too", "also happening in ...") - Discussing workarounds that can't land in _tsx_ - Off-topic comments After an issue is confirmed by the provided reproduction, the thread may sometimes be locked to direct further conversation & action to PRs. > [!TIP] > **⚡️ Get issues addressed faster!** > > Sponsors can prioritize issues. By helping fund development, you can ensure your needs are addressed quickly! > > [Sponsor now →](https://github.com/sponsors/privatenumber) ## Pull requests #### Open an Issue first Ensure there’s an existing issue related to your PR to facilitate alignment and prevent wasted work. #### Include tests Add minimal tests verifying your changes to maintain behavior and reliability. ## Development ### Initial setup After cloning the repo, use [nvm](https://nvm.sh) (optional) to set the expected Node.js version, and [pnpm](https://pnpm.io) to install dependencies: ```bash nvm i # Install or use Node.js version pnpm i # Install dependencies ``` ### Building Build the source code with: ```bash pnpm build # Compiles to `dist` ``` > [!TIP] > Temporarily disable minification by removing `--minify` in `package.json#scripts.build` for easier debugging. ### Linting and type-checking Ensure code quality with: ```bash pnpm lint # ESLint pnpm type-check # TypeScript type checking ``` ### Testing Run automated tests with: ```bash pnpm test # Regular test CI=1 pnpm test # CI environments ``` ### Manual testing #### Local testing Use the absolute path to run `./dist/cli.mjs`: ```sh /tsx/dist/cli.mjs ``` #### Collaborative testing Use [`git-publish`](https://github.com/privatenumber/git-publish) to publish your changes to your GitHub fork. It can be shared with others and installed from for testing. ## Giving back _tsx_ has outgrown its "hobby project" status to become a tool used and loved by many. While it made it far without sponsorship, funding will accelerate further development by making it easier for devs to choose tsx over other paid work. If tsx has helped you, help tsx back! ❤️ Any amount makes a difference. [Sponsor now →](https://github.com/sponsors/privatenumber) ================================================ FILE: FUNDING.json ================================================ { "drips": { "ethereum": { "ownedBy": "0xB9C2F7C3BB7734c37d2949B98A90bAea2fd59E21" } } } ================================================ FILE: LICENSE ================================================ MIT License Copyright (c) Hiroki Osame Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: README.md ================================================


tsx

TypeScript Execute (tsx): The easiest way to run TypeScript in Node.js

Documentation    |    Getting started →


Already a sponsor? Join the discussion in the Development repo!

## Sponsors

================================================ FILE: docs/.vitepress/config.ts ================================================ import { defineConfig } from 'vitepress'; const title = 'tsx'; const description = 'tsx (TypeScript Execute) - The easiest way to run TypeScript in Node.js'; export default defineConfig({ lang: 'en-US', title, description, lastUpdated: true, cleanUrls: true, ignoreDeadLinks: true, metaChunk: true, head: [ ['link', { rel: 'icon', type: 'image/svg+xml', href: '/logo-mini.svg', }], ['meta', { property: 'og:title', content: title, }], ['meta', { property: 'og:type', content: 'website', }], ['meta', { property: 'og:image', content: 'https://tsx.is/social.png', }], ['meta', { property: 'og:url', content: 'https://tsx.is', }], ['meta', { property: 'og:description', content: description, }], ['meta', { property: 'og:site_name', content: title, }], ['meta', { name: 'twitter:card', content: 'summary_large_image', }], ['meta', { name: 'twitter:site', content: '@tsx_is', }], ['script', { src: 'https://beamanalytics.b-cdn.net/beam.min.js', 'data-token': 'ee893e1d-7484-4fb3-85b7-78c58b3d9c9e', async: '', }], ], themeConfig: { siteTitle: false, logo: { light: '/logo-light.svg', dark: '/logo-dark.svg', alt: 'tsx', }, outline: 'deep', editLink: { pattern: 'https://github.com/privatenumber/tsx/edit/master/docs/:path', text: 'Propose changes to this page', }, nav: [ { text: 'User guide', link: '/', activeMatch: '^(?!\/dev-api\/).*', }, { text: 'Developer API', link: '/dev-api/', activeMatch: '/dev-api/', }, ], sidebar: { '/': [ { text: 'Introduction', items: [ { text: 'About tsx', link: '/', }, { text: 'Getting started', link: '/getting-started', }, ], }, { text: 'Usage', items: [ { text: 'Node.js enhancement', link: '/node-enhancement', }, { text: 'Watch mode', link: '/watch-mode', }, ], }, { text: 'Integration', items: [ { text: 'TypeScript', link: '/typescript', }, { text: 'Compilation', link: '/compilation', }, { text: 'Shell scripts', link: '/shell-scripts', }, { text: 'VSCode debugging', link: '/vscode', }, ] }, { text: 'Support', items: [ { text: 'FAQ', link: '/faq', docFooterText: 'Frequently Asked Questions', }, { text: 'Learning resources', link: '/learn', }, { text: 'Help center (Sponsors only)', link: 'https://github.com/pvtnbr/tsx/discussions', }, { text: 'Become a Sponsor', link: 'https://github.com/sponsors/privatenumber/sponsorships?tier_id=416984', }, ], }, ], '/dev-api/': [ { text: 'About the Developer API', link: '/dev-api/', }, { text: 'Automatic registration', items: [ { text: 'Node.js CLI', link: '/dev-api/node-cli' }, { text: 'Entry-point', link: '/dev-api/entry-point' }, ], }, { text: 'Scoped TS loading', items: [ { text: 'tsImport()', link: '/dev-api/ts-import' }, { text: 'tsx.require()', link: '/dev-api/tsx-require' }, ], }, { text: 'Register API', items: [ { text: 'CommonJS', link: '/dev-api/register-cjs' }, { text: 'ESM', link: '/dev-api/register-esm' }, ], }, ], }, socialLinks: [ { icon: 'github', link: 'https://github.com/privatenumber/tsx', }, { icon: 'x', link: 'https://x.com/tsx_is', }, { icon: { svg: '' }, link: '/contact' } ], search: { provider: 'local', }, carbonAds: { code: 'CW7DEKJY', placement: 'tsxis', }, }, }); ================================================ FILE: docs/.vitepress/theme/components/AsideSponsors.vue ================================================ ================================================ FILE: docs/.vitepress/theme/components/ContactForm.vue ================================================