CoolFace
Apppublic

AK-21/Graphite-Industrial-Intelligence

sourceHugging Faceupdated 3mo agoView on Hugging Face
0likes
README.md165 linesDownload Raw Back to jiti
1# jiti2 3[![npm version][npm-version-src]][npm-version-href]4[![npm downloads][npm-downloads-src]][npm-downloads-href]5[![bundle][bundle-src]][bundle-href]6[![License][license-src]][license-href]7 8Runtime Typescript and ESM support for Node.js.9 10> [!IMPORTANT]11> This is the support branch for jiti v1. Check out [jiti/main](https://github.com/unjs/jiti/tree/main) for the latest version and [unjs/jiti#174](https://github.com/unjs/jiti/issues/174) for the roadmap.12 13## Features14 15- Seamless typescript and ESM syntax support16- Seamless interoperability between ESM and CommonJS17- Synchronous API to replace `require`18- Super slim and zero dependency19- Smart syntax detection to avoid extra transforms20- CommonJS cache integration21- Filesystem transpile hard cache22- V8 compile cache23- Custom resolve alias24 25## Usage26 27### Programmatic28 29```js30const jiti = require("jiti")(__filename);31 32jiti("./path/to/file.ts");33```34 35You can also pass options as second argument:36 37```js38const jiti = require("jiti")(__filename, { debug: true });39```40 41### CLI42 43```bash44jiti index.ts45# or npx jiti index.ts46```47 48### Register require hook49 50```bash51node -r jiti/register index.ts52```53 54Alternatively, you can register `jiti` as a require hook programmatically:55 56```js57const jiti = require("jiti")();58const unregister = jiti.register();59```60 61## Options62 63### `debug`64 65- Type: Boolean66- Default: `false`67- Environment Variable: `JITI_DEBUG`68 69Enable debug to see which files are transpiled70 71### `cache`72 73- Type: Boolean | String74- Default: `true`75- Environment Variable: `JITI_CACHE`76 77Use transpile cache78 79If set to `true` will use `node_modules/.cache/jiti` (if exists) or `{TMP_DIR}/node-jiti`80 81### `esmResolve`82 83- Type: Boolean | String84- Default: `false`85- Environment Variable: `JITI_ESM_RESOLVE`86 87Using esm resolution algorithm to support `import` condition.88 89### `transform`90 91- Type: Function92- Default: Babel (lazy loaded)93 94Transform function. See [src/babel](./src/babel.ts) for more details95 96### `sourceMaps`97 98- Type: Boolean99- Default `false`100- Environment Variable: `JITI_SOURCE_MAPS`101 102Add inline source map to transformed source for better debugging.103 104### `interopDefault`105 106- Type: Boolean107- Default: `false`108 109Return the `.default` export of a module at the top-level.110 111### `alias`112 113- Type: Object114- Default: -115- Environment Variable: `JITI_ALIAS`116 117Custom alias map used to resolve ids.118 119### `nativeModules`120 121- Type: Array122- Default: ['typescript`]123- Environment Variable: `JITI_NATIVE_MODULES`124 125List of modules (within `node_modules`) to always use native require for them.126 127### `transformModules`128 129- Type: Array130- Default: []131- Environment Variable: `JITI_TRANSFORM_MODULES`132 133List of modules (within `node_modules`) to transform them regardless of syntax.134 135### `experimentalBun`136 137- Type: Boolean138- Default: Enabled if `process.versions.bun` exists (Bun runtime)139- Environment Variable: `JITI_EXPERIMENTAL_BUN`140 141Enable experimental native Bun support for transformations.142 143## Development144 145- Clone this repository146- Enable [Corepack](https://github.com/nodejs/corepack) using `corepack enable`147- Install dependencies using `pnpm install`148- Run `pnpm dev`149- Run `pnpm jiti ./test/path/to/file.ts`150 151## License152 153MIT. Made with ๐Ÿ’–154 155<!-- Badged -->156 157[npm-version-src]: https://img.shields.io/npm/v/jiti?style=flat&colorA=18181B&colorB=F0DB4F158[npm-version-href]: https://npmjs.com/package/jiti159[npm-downloads-src]: https://img.shields.io/npm/dm/jiti?style=flat&colorA=18181B&colorB=F0DB4F160[npm-downloads-href]: https://npmjs.com/package/jiti161[bundle-src]: https://img.shields.io/bundlephobia/minzip/jiti?style=flat&colorA=18181B&colorB=F0DB4F162[bundle-href]: https://bundlephobia.com/result?p=h3163[license-src]: https://img.shields.io/github/license/unjs/jiti.svg?style=flat&colorA=18181B&colorB=F0DB4F164[license-href]: https://github.com/unjs/jiti/blob/main/LICENSE165