|
|
il y a 1 an | |
|---|---|---|
| .. | ||
| bin | il y a 1 an | |
| dist | il y a 1 an | |
| lib | il y a 1 an | |
| LICENSE | il y a 1 an | |
| README.md | il y a 1 an | |
| package.json | il y a 1 an | |
| register.js | il y a 1 an | |
Runtime Typescript and ESM support for Node.js.
[!IMPORTANT] This is the support branch for jiti v1. Check out jiti/main for the latest version and unjs/jiti#174 for the roadmap.
requireconst jiti = require("jiti")(__filename);
jiti("./path/to/file.ts");
You can also pass options as second argument:
const jiti = require("jiti")(__filename, { debug: true });
jiti index.ts
# or npx jiti index.ts
node -r jiti/register index.ts
Alternatively, you can register jiti as a require hook programmatically:
const jiti = require("jiti")();
const unregister = jiti.register();
debugfalseJITI_DEBUGEnable debug to see which files are transpiled
cachetrueJITI_CACHEUse transpile cache
If set to true will use node_modules/.cache/jiti (if exists) or {TMP_DIR}/node-jiti
esmResolvefalseJITI_ESM_RESOLVEUsing esm resolution algorithm to support import condition.
transformTransform function. See src/babel for more details
sourceMapsfalseJITI_SOURCE_MAPSAdd inline source map to transformed source for better debugging.
interopDefaultfalseReturn the .default export of a module at the top-level.
aliasJITI_ALIASCustom alias map used to resolve ids.
nativeModulesJITI_NATIVE_MODULESList of modules (within node_modules) to always use native require for them.
transformModulesJITI_TRANSFORM_MODULESList of modules (within node_modules) to transform them regardless of syntax.
experimentalBunprocess.versions.bun exists (Bun runtime)JITI_EXPERIMENTAL_BUNEnable experimental native Bun support for transformations.
corepack enablepnpm installpnpm devpnpm jiti ./test/path/to/file.tsMIT. Made with 💖