8000 GitHub - danielroe/unjs-jiti: Runtime Typescript and ESM support for Node.js (CommonJS)
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
forked from unjs/jiti

Runtime Typescript and ESM support for Node.js (CommonJS)

Notifications You must be signed in to change notification settings

danielroe/unjs-jiti

 
 

Repository files navigation

jiti

Runtime typescript and ESM support for Node.js (CommonJS)

version downloads size

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

  • + 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 ignores node_modules. ESM everywhere yay!
  • + Embeddable
  • + 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 i 6DAF n 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 💖

About

Runtime Typescript and ESM support for Node.js (CommonJS)

Resources

Code of conduct

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Languages

  • TypeScript 64.8%
  • JavaScript 35.2%
0