Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
51 lines
1.1 KiB
Plaintext
51 lines
1.1 KiB
Plaintext
# esbuild-register
|
|
|
|
[](https://npm.im/esbuild-register) [](https://npm.im/esbuild-register)
|
|
|
|
## Install
|
|
|
|
```bash
|
|
npm i esbuild esbuild-register -D
|
|
# Or Yarn
|
|
yarn add esbuild esbuild-register --dev
|
|
# Or pnpm
|
|
pnpm add esbuild esbuild-register -D
|
|
```
|
|
|
|
## Usage
|
|
|
|
```bash
|
|
node -r esbuild-register file.ts
|
|
```
|
|
|
|
It will use `jsxFactory`, `jsxFragmentFactory` and `target` options from your `tsconfig.json`
|
|
|
|
### Experimental loader support
|
|
|
|
When using in a project with `type: "module"` in `package.json`, you need the `--loader` flag to load TypeScript files:
|
|
|
|
```bash
|
|
node --loader esbuild-register/loader -r esbuild-register ./file.ts
|
|
```
|
|
|
|
## Programmatic Usage
|
|
|
|
```ts
|
|
const { register } = require('esbuild-register/dist/node')
|
|
|
|
const { unregister } = register({
|
|
// ...options
|
|
})
|
|
|
|
// Unregister the require hook if you don't need it anymore
|
|
unregister()
|
|
```
|
|
|
|
## Sponsors
|
|
|
|
[](https://github.com/sponsors/egoist)
|
|
|
|
## License
|
|
|
|
MIT © [EGOIST](https://egoist.dev)
|