source: frontend/node_modules/jiti/README.md

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 3.8 KB
Line 
1# jiti
2
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## Features
14
15- Seamless typescript and ESM syntax support
16- Seamless interoperability between ESM and CommonJS
17- Synchronous API to replace `require`
18- Super slim and zero dependency
19- Smart syntax detection to avoid extra transforms
20- CommonJS cache integration
21- Filesystem transpile hard cache
22- V8 compile cache
23- Custom resolve alias
24
25## Usage
26
27### Programmatic
28
29```js
30const jiti = require("jiti")(__filename);
31
32jiti("./path/to/file.ts");
33```
34
35You can also pass options as second argument:
36
37```js
38const jiti = require("jiti")(__filename, { debug: true });
39```
40
41### CLI
42
43```bash
44jiti index.ts
45# or npx jiti index.ts
46```
47
48### Register require hook
49
50```bash
51node -r jiti/register index.ts
52```
53
54Alternatively, you can register `jiti` as a require hook programmatically:
55
56```js
57const jiti = require("jiti")();
58const unregister = jiti.register();
59```
60
61## Options
62
63### `debug`
64
65- Type: Boolean
66- Default: `false`
67- Environment Variable: `JITI_DEBUG`
68
69Enable debug to see which files are transpiled
70
71### `cache`
72
73- Type: Boolean | String
74- Default: `true`
75- Environment Variable: `JITI_CACHE`
76
77Use transpile cache
78
79If set to `true` will use `node_modules/.cache/jiti` (if exists) or `{TMP_DIR}/node-jiti`
80
81### `esmResolve`
82
83- Type: Boolean | String
84- Default: `false`
85- Environment Variable: `JITI_ESM_RESOLVE`
86
87Using esm resolution algorithm to support `import` condition.
88
89### `transform`
90
91- Type: Function
92- Default: Babel (lazy loaded)
93
94Transform function. See [src/babel](./src/babel.ts) for more details
95
96### `sourceMaps`
97
98- Type: Boolean
99- 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: Boolean
107- Default: `false`
108
109Return the `.default` export of a module at the top-level.
110
111### `alias`
112
113- Type: Object
114- Default: -
115- Environment Variable: `JITI_ALIAS`
116
117Custom alias map used to resolve ids.
118
119### `nativeModules`
120
121- Type: Array
122- 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: Array
130- 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: Boolean
138- 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## Development
144
145- Clone this repository
146- 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## License
152
153MIT. Made with 💖
154
155<!-- Badged -->
156
157[npm-version-src]: https://img.shields.io/npm/v/jiti?style=flat&colorA=18181B&colorB=F0DB4F
158[npm-version-href]: https://npmjs.com/package/jiti
159[npm-downloads-src]: https://img.shields.io/npm/dm/jiti?style=flat&colorA=18181B&colorB=F0DB4F
160[npm-downloads-href]: https://npmjs.com/package/jiti
161[bundle-src]: https://img.shields.io/bundlephobia/minzip/jiti?style=flat&colorA=18181B&colorB=F0DB4F
162[bundle-href]: https://bundlephobia.com/result?p=h3
163[license-src]: https://img.shields.io/github/license/unjs/jiti.svg?style=flat&colorA=18181B&colorB=F0DB4F
164[license-href]: https://github.com/unjs/jiti/blob/main/LICENSE
Note: See TracBrowser for help on using the repository browser.