Runtime typescript and ESM support for Node.js (CommonJS)
- Stable typescript and esm syntax support
- Provide sync interface to replace require
- Super slim and zero dependency
- Syntax detect to avoid extra transform
- CommonJS cache integration
const jiti = require('jiti')(__filename)
jiti('./path/to/file.ts')
+
Much more stable thanks to babel+
Less low level operations+
Typescript support-
Slower-
No source-map support at the moment
+
Smaller install size (~1M vs ~11M with same plugins)+
Configured out of the box+
Smart syntax detect to avoid unnecessary trnaspilation+
Does not ignoresnode_modules
. ESM everywhere yay!+
Embeddable
+
No native dependency+
More stable thanks to babel-
Slower+
Embeddable
+
Support both esm and typescript/
No typechecking support / Faster+
Smart syntax detect to avoid unnecessary transpilation
- It is not (yet) landed as a stable feature
- No typescript support
- Limitted to
.mjs
files with different executation context (no__filename
,require
, etc)
Meanwhile it would be much better making an optimized bundle to deploy to production or as npm package, using bundler setup and watching is frustrating during project development that's where jiti
(or similar tools like ts-node
) would be more convenient.
Note: However currently only babel transform is supported, configurable transform support is i
6DAF
n the roadmap so using esbuild
or other solutions would be possible.
- Clone Repo
- Run
yarn
- Run
yarn build
- Run
yarn dev
- Run
node ./test/jiti.js
- Basic working
- Syntax detect and fallback to CJS require
- Improve project build system
- Sourcemap support
- File system cache
- Add tests
- Configurable transform (esbuild)
MIT. Made with 💖