Package Exports
- jiti
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (jiti) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
jiti
Runtime typescript and ESM support for Node.js (CommonJS)
Features
- 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
Usage
const jiti = require('jiti')(__filename)
jiti('./path/to/file.ts')
Compared to Alternatives
standard-things/esm
+
Much more stable thanks to babel+
Less low level operations+
Typescript support-
Slower-
No source-map support at the moment
babel-register
+
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
esbuild
+
No native dependency+
More stable thanks to babel-
Slower+
Embeddable
ts-node
+
Support both esm and typescript/
No typechecking support / Faster+
Smart syntax detect to avoid unnecessary transpilation
Native ESM Support (MJS)
- It is not (yet) landed as a stable feature
- No typescript support
- Limitted to
.mjs
files with different executation context (no__filename
,require
, etc)
Bundlers (rollup
, webpack
, snowpack
, 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 in the roadmap so using esbuild
or other solutions would be possible.
Development
- Clone Repo
- Run
yarn
- Run
yarn build
- Run
yarn dev
- Run
node ./test/jiti.js
Roadmap
- Basic working
- Syntax detect and fallback to CJS require
- Improve project build system
- Sourcemap support
- File system cache
- Add tests
- Configurable transform (esbuild)
License
MIT. Made with 💖