Skip to content

Releases: unjs/jiti

v2.1.2

03 Oct 14:34
@pi0 pi0
Compare
Choose a tag to compare

compare changes

🌊 Types

  • Use local NodeModule type (718bea2)

v2.1.1

03 Oct 07:49
@pi0 pi0
Compare
Choose a tag to compare

compare changes

  • types: Add standalone types for node require (#316)
  • Update babel to 7.25.7

v2.1.0

30 Sep 14:27
@pi0 pi0
Compare
Choose a tag to compare

compare changes

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

  • Enable interopDefault by default (#310)
  • Support import.meta.dirname and import.meta.filename (#308)

πŸ”₯ Performance

  • cli: Enable node 22 compile cache (%17 faster) (#312)

🩹 Fixes

  • Make TransformOptions type strict to allow auto-complete (#305)
  • Properly handle tsx (#311)

πŸ’… Refactors

  • Deprecate commonjs api (#313)

πŸ“¦ Build

  • Fix /register and /native subpath types for Node10 module resolution (#304)

❀️ Contributors

v2.0.0

25 Sep 18:22
@pi0 pi0
Compare
Choose a tag to compare

🌟 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.

image

⬆️ 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

compare changes

πŸš€ 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 using JITI_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

  • Overhaul package exports (#262)
  • Fix type resolution issue (#269)

πŸ”₯ Performance

  • Reduce overhead of jiti sub-instances (#265)
  • Use native createRequire (69da3c5)

🩹 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 native require.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 and moduleCache options (#263)
  • Use ESM imports for babel plugins (22e259f)
  • Improve debug logging (463a8a3)
  • Rename importResolve to esmResolve (aac88e6)
  • Improve env handling (ee4489d)
  • Use import/require in debug logs (934a5bb)
  • Improve internal babel types (#271)
  • Rename experimentalBun option to tryNative (#295)
  • Make jiti.esmResolve consistent with import.meta.resolve (#303)

πŸ“– Documentation

  • Update bundlephobia link (#179)
  • Add example for inline JITI_ALIAS (a53715a)

v2.0.0-rc.1

19 Sep 11:26
@pi0 pi0
Compare
Choose a tag to compare

compare changes

πŸš€ Enhancements

  • jiti/native export (#289)
  • Improve jiti/native compatibility with node and deno (#294)

πŸ’… Refactors

  • Improve internal babel types (#271)
  • Always use native impl for jiti/native (#293)
  • Rename experimentalBun to tryNative (#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

v2.0.0-beta.3

02 Jul 10:54
@pi0 pi0
Compare
Choose a tag to compare

compare changes

πŸš€ Enhancements

  • Allow try and other resolve options for import/esmResolve (#268)
  • Allow set interopDefault using JITI_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

  • Improve debug logging (463a8a3)
  • Rename importResolve to esmResolve (aac88e6)
  • Improve env handling (ee4489d)
  • Use import/require in debug logs (934a5bb)

v2.0.0-beta.2

01 Jul 19:48
@pi0 pi0
Compare
Choose a tag to compare

compare changes

πŸš€ Enhancements

  • Add experimental esm loader support (#266)

πŸ”₯ Performance

  • Reduce overhead of sub jiti instances (#265)

🩹 Fixes

  • Resolve with esm conditions in async context (#264)

πŸ’… Refactors

  • Use more clear fsCache and moduleCache options (#263)
  • Use esm imports for babel plugins (22e259f)

πŸ“¦ Build

πŸ€– CI

  • Enable loader test (#267)

❀️ Contributors

  • Pooya Parsa (@pi0)

v2.0.0-beta.1

28 Jun 15:17
@pi0 pi0
Compare
Choose a tag to compare

compare changes

πŸš€ Enhancements

  • Basic top-level await support (#239)
  • Native esm support (#259)

🩹 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

❀️ Contributors

v1.21.6

10 Jun 15:00
@pi0 pi0
Compare
Choose a tag to compare

compare changes

🩹 Fixes

  • Use internal cached modules only if loaded (#247)

v1.21.5

10 Jun 14:33
@pi0 pi0
Compare
Choose a tag to compare

compare changes

🩹 Fixes

From 1.21.4

  • Avoid node: protocol for node 14 compatibility (5d877de)
  • Update deps (5e11181)