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
7 changes: 7 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ jobs:
run: pnpm install
- name: Build
run: pnpm --filter="@oxc-node/cli" build
- name: Test global install
run: |
npm install -g ./packages/cli
cd /tmp
which oxnode
oxnode --version
oxnode --help
- name: Upload artifact
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
Expand Down
24 changes: 24 additions & 0 deletions packages/cli/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# `@oxc-node/cli`

CLI tool for `oxc-node`.

## Features

- Run a script with oxc transformer and oxc-resolver
- Support run TypeScript without any configuration
- Support ESM and CJS
- Support source map

## Installation

Install globally, you can use it replace `node` command anywhere.

```bash
npm install @oxc-node/cli -g
```

## Usage

```bash
oxnode ./path/to/index.ts
```
1 change: 1 addition & 0 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"registry": "https://registry.npmjs.org/",
"access": "public"
},
"homepage": "https://github.com/oxc-project/oxc-node/tree/main/packages/cli",
"repository": {
"type": "git",
"url": "git+https://github.com/oxc-project/oxc-node.git"
Expand Down
7 changes: 4 additions & 3 deletions packages/cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,17 @@ class MainCommand extends Command {
if (this.nodeHelp) {
this.args.push(`--help `)
}
const args = this.args.length ? ` ${this.args.join(' ')}` : ''
const args = this.args.length ? `${this.args.join(' ')}` : ''
const register = import.meta.resolve('@oxc-node/core/register')
if (!args.length) {
execSync(`node --enable-source-maps --import @oxc-node/core/register`, {
execSync(`node --enable-source-maps --import ${register}`, {
env: process.env,
cwd: process.cwd(),
stdio: `inherit`,
})
return
}
const cp = exec(`node --enable-source-maps --import @oxc-node/core/register ${args}`, {
const cp = exec(`node --enable-source-maps --import ${register} ${args}`, {
env: process.env,
cwd: process.cwd(),
})
Expand Down