Releases: unjs/jiti
v2.1.2
v2.1.1
v2.1.0
Important
To enhance compatibility, jiti >=2.1
enabled interopdefault
using a new Proxy method. If you migrated to 2.0.0
earlier, this might have caused behavior changes. In case of any issues during the upgrade, please report so we can investigate to solve them. ππΌ
π Enhancements
π₯ Performance
- cli: Enable node 22 compile cache (%17 faster) (#312)
π©Ή Fixes
π Refactors
- Deprecate commonjs api (#313)
π¦ Build
- Fix
/register
and/native
subpath types forNode10
module resolution (#304)
β€οΈ Contributors
- Pooya Parsa (@pi0)
- Arya Emami (@aryaemami59)
v2.0.0
π 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')
β€οΈ Thank you!
This release wasn't possible without valuable ecosystem feedback and contributors. With the trust of users with astonishing 60M+ monthly downloads, i hope jiti v2 can help speed up the ecosystem transition to ESM and Typescript.
Changes since v1
π Enhancements
- top-level
await
support (#239) - Native ESM support (#259)
- Add experimental ESM loader support (#266)
- Allow try and other resolve options for
jiti.esmResolve
(#268) - Allow configure
interopDefault
usingJITI_INTEROP_DEFAULT
env (1c080a1) jiti/native
subpath (#289) (#294) (#293)- Handle
data:
imports (#299) - Support opt-in JSX (#200)
- Eval ESM modules with fallback loader (#300)
- Support
import.meta.resolve
(#301)
π¦ Build
π₯ Performance
π©Ή Fixes
- Use distinct cache paths for async mode (6e8ec7a)
- Resolve with ESM conditions in async context (#264)
- cache: Prefer
node_modules/.cache
if exists (832f206) - Use native ESM import for built-ins (54d6b4a)
- Respect
interopDefault
in babel transform (485b4e9) - Split cache based on
interopDefault
(f820a15) - Remove extention from cache path (50b1b3a)
- Properly resolve
.mts
/.cts
with.mjs
/.cjs
imports (a5aefad) - resolve: Make sure
parentURL
is a dir (d224e84) - Handle global
URL
instance mismatch (#298) - Optional access to
Reflect.metadata
for typescript decorators (#165) - Only pass
paths
option to nativerequire.resolve
(50e4280)
π Refactors
- Split option normalization (#172)
- Split logic (#240)
- Remove legacy Node.js syntax polyfills (#260)
- 3rd arg to
createJiti
is optional (60a23e3) - Upgrade cache version to 8 (99224ae)
- Use more clear
fsCache
andmoduleCache
options (#263) - Use ESM imports for babel plugins (22e259f)
- Improve debug logging (463a8a3)
- Rename
importResolve
toesmResolve
(aac88e6) - Improve env handling (ee4489d)
- Use
import
/require
in debug logs (934a5bb) - Improve internal babel types (#271)
- Rename
experimentalBun
option totryNative
(#295) - Make
jiti.esmResolve
consistent withimport.meta.resolve
(#303)
π Documentation
v2.0.0-rc.1
π Enhancements
π Refactors
- Improve internal babel types (#271)
- Always use native impl for
jiti/native
(#293) - Rename
experimentalBun
totryNative
(#295)
π¦ Build
- Fix type resolution issue (#269)
π‘ Chore
- Stricter typechecks (64dda9f)
- Fix build (e78daeb)
- Replace exec logic in test fixtures (#286)
- Add storybook to used by list (#284)
- Update jiti-native (8b76742)
β€οΈ Contributors
- Pooya Parsa (@pi0)
- Norbert De Langen [email protected]
- James Garbutt (@43081j)
- Arya Emami (@aryaemami59)
v2.0.0-beta.3
π Enhancements
- Allow
try
and other resolve options forimport
/esmResolve
(#268) - Allow set
interopDefault
usingJITI_INTEROP_DEFAULT
env (1c080a1)
π₯ Performance
- Use native
createRequire
(69da3c5)
π©Ή Fixes
- cache: Prefer
node_modules/.cache
if exists (832f206) - Use native esm import for built-ins (54d6b4a)
- Respect
interopDefault
in babel transform (485b4e9) - Split cache based on
interopDefault
(f820a15) - Remove ext from cache path (50b1b3a)
- Properly resolve
.mts
/.cts
with.mjs
/.cjs
imports (a5aefad) - resolve: Make sure
parentURL
is a dir (d224e84)
π Refactors
v2.0.0-beta.2
v2.0.0-beta.1
π Enhancements
π©Ή Fixes
- Use distinct cache paths for async mode (6e8ec7a)
π Refactors
- Split option normalization (#172)
- Split logic (#240)
- Remove legacy node syntax polyfills (#260)
- Upgrade cache version to
8
(99224ae)
π Documentation
- Update bundlephobia link (#179)
π€ CI
- Enable nightly channel (bfd4f46)