jiti
2.7.0 · 5 May 2026MIT267.2M / weekRepositoryHomepagenpmAtom feed
2.7.0 is the newest release of 2.x.
Summary· from the note as AI read it
Migration neededRead before upgrading: 7 changes to make.
Before you upgrade
- Switch to the createJiti named export instead of the default export
- Check how jiti is imported; package exports changed
- Ensure a modern Node.js version; legacy syntax polyfills are goneTo check
- Rename cache options to fsCache and moduleCache
- Rename importResolve calls to esmResolve
- Rename the experimentalBun option to tryNative
- Check esmResolve results; now behaves like import.meta.resolve
New
- Native ESM
- jiti v2 now natively supports ESM import and resolution with new API
await jiti.import(id)andjiti.esmResolve(id). This allows top-levelawaitand native+faster importing of ES-only modules with increased compatibility - JSX Support
- You can now directly import
.jsx/.tsxfiles with jiti! See examples with nano-js, preact, React and Vue. This feature is opt-in for now (usingjsx: trueorJITI_JSX=true). Jiti is considering a smarter lib detection for wider support before enabling JSX support by de - Dual format package exports
In short
7 breaking23 new2 faster14 fixed10 internal
- Breaking
Use new
createJitinamed export : - Breaking
Overhaul package exports
- BreakingTo check
Remove legacy Node.js syntax polyfills
- Breaking
Use more clear
fsCacheandmoduleCacheoptions - Breaking
Rename
importResolvetoesmResolve - Breaking
Rename
experimentalBunoption totryNative - Breaking
Make
jiti.esmResolveconsistent withimport.meta.resolve
Release note
Highlights
Native ESM
jiti v2 now natively supports ESM import and resolution with new API await jiti.import(id) and jiti.esmResolve(id). This allows top-level await and native+faster importing of ES-only modules with increased compatibility
JSX Support
You can now directly import .jsx/.tsx files with jiti! See examples with nano-js, preact, React and Vue. This feature is opt-in for now (using jsx: true or JITI_JSX=true). Jiti is considering a smarter lib detection for wider support before enabling JSX support by default.
Dual format package exports
jiti package exports are now in a dual (ESM/CJS) format for better importing of jiti in ESM contexts.
jiti/native
As native ESM and Typescript support is being increased across runtimes, a new export in jiti allows easing up the transition by giving the same API of jiti but instead only depending on runtime import.meta.resolve and dynamic import() support. This is possible by making an alias for jiti to jiti/native.
ESM Loader
You can globally register jiti using Node.js global hooks (experimental).
CLI:
# Instead of `npx jiti index.ts` node --import jiti/register index.ts
Programmatic:
import "jiti/register";
// or
await import("jiti/register");Better inspection
You can inspect what jiti internals using debug option or JITI_DEBUG=1 environment variable. The output is now more readable and with colors to easily find slow imports.
jiti will also use node_modules/.cache/jiti directory instead of temp dir (if node_modules exists) to store caches for easier local inspections.
Migration
Upgrade jiti dependency to ^2.0.0 in package.json
Use new createJiti named export :
ESM:
--- import createJiti from "jiti"
+++ import { createJiti } from "jiti"
const jiti = createJiti(import.meta.url)CommonJS:
--- const createJiti = require("jiti")
+++ const { createJiti } = require("jiti")
const jiti = createJiti(__filename)Migrate from CommonJS to ESM API: (highly recommended!)
Importing modules:
--- const mood = jiti('mod')
+++ const mood = await jiti.import('mod')Resolving modules:
--- const path = jiti.resolve('mod')
+++ const path = jiti.esmResolve('mod')Changes since v1
Enhancements
top-level
awaitsupportNative ESM support
Add experimental ESM loader support
Allow try and other resolve options for
jiti.esmResolveAllow configure
interopDefaultusingJITI_INTEROP_DEFAULTenvjiti/nativesubpathHandle
data:importsSupport opt-in JSX
Eval ESM modules with fallback loader
Support
import.meta.resolve
Performance
Reduce overhead of jiti sub-instances
Use native
createRequire
Fixes
Use distinct cache paths for async mode
Resolve with ESM conditions in async context
cache: Prefer
node_modules/.cacheif existsUse native ESM import for built-ins
Respect
interopDefaultin babel transformSplit cache based on
interopDefaultRemove extention from cache path
Properly resolve
.mts/.ctswith.mjs/.cjsimportsresolve: Make sure
parentURLis a dirHandle global
URLinstance mismatchOptional access to
Reflect.metadatafor typescript decoratorsOnly pass
pathsoption to nativerequire.resolve
A whole project to check? Paste its package.json in the dependency check: every deprecated, outdated or vulnerable dependency, with what to upgrade to. Free, no account.