1.21.0 • Published 6 months ago

jiti v1.21.0

Weekly downloads
366,808
License
MIT
Repository
github
Last release
6 months ago

jiti

npm version npm downloads bundle License

Runtime Typescript and ESM support for Node.js.

!IMPORTANT This is the support branch for jiti v1. Check out jiti/main for the latest version and unjs/jiti#174 for the roadmap.

Features

  • Seamless typescript and ESM syntax support
  • Seamless interoperability between ESM and CommonJS
  • Synchronous API to replace require
  • Super slim and zero dependency
  • Smart syntax detection to avoid extra transforms
  • CommonJS cache integration
  • Filesystem transpile hard cache
  • V8 compile cache
  • Custom resolve alias

Usage

Programmatic

const jiti = require("jiti")(__filename);

jiti("./path/to/file.ts");

You can also pass options as second argument:

const jiti = require("jiti")(__filename, { debug: true });

CLI

jiti index.ts
# or npx jiti index.ts

Register require hook

node -r jiti/register index.ts

Alternatively, you can register jiti as a require hook programmatically:

const jiti = require("jiti")();
const unregister = jiti.register();

Options

debug

  • Type: Boolean
  • Default: false
  • Environment Variable: JITI_DEBUG

Enable debug to see which files are transpiled

cache

  • Type: Boolean | String
  • Default: true
  • Environment Variable: JITI_CACHE

Use transpile cache

If set to true will use node_modules/.cache/jiti (if exists) or {TMP_DIR}/node-jiti

esmResolve

  • Type: Boolean | String
  • Default: false
  • Environment Variable: JITI_ESM_RESOLVE

Using esm resolution algorithm to support import condition.

transform

  • Type: Function
  • Default: Babel (lazy loaded)

Transform function. See src/babel for more details

sourceMaps

  • Type: Boolean
  • Default false
  • Environment Variable: JITI_SOURCE_MAPS

Add inline source map to transformed source for better debugging.

interopDefault

  • Type: Boolean
  • Default: false

Return the .default export of a module at the top-level.

alias

  • Type: Object
  • Default: -
  • Environment Variable: JITI_ALIAS

Custom alias map used to resolve ids.

nativeModules

  • Type: Array
  • Default: 'typescript`
  • Environment Variable: JITI_NATIVE_MODULES

List of modules (within node_modules) to always use native require for them.

transformModules

  • Type: Array
  • Default: []
  • Environment Variable: JITI_TRANSFORM_MODULES

List of modules (within node_modules) to transform them regardless of syntax.

experimentalBun

  • Type: Boolean
  • Default: Enabled if process.versions.bun exists (Bun runtime)
  • Environment Variable: JITI_EXPERIMENTAL_BUN

Enable experimental native Bun support for transformations.

Development

  • Clone this repository
  • Enable Corepack using corepack enable
  • Install dependencies using pnpm install
  • Run pnpm dev
  • Run pnpm jiti ./test/path/to/file.ts

License

MIT. Made with 💖

postcss-loadergraphql-config@violetx/build@graphql-codegen/cli@nuxt/deploynuxt-compactnuxt2amos-vercel-builder2amos-vercel-builder3shattercms@danifoldi/nitropack@dddstylesystems/cli@paescuj/unbuildlit-tailwind-poc-2tailwindcssgganbusklif-ui-kitsklif-apinuxt3@everything-registry/sub-chunk-1962@314oner_npm/universal-components-librarysphereuip149-tablesklif-uimachinebeemrcaps@bergold/react-email-dev@albawid/albawidapp5758-tea-ibc@anonybit-modules/videoreconstruction@cetiak/cetiak@bigwin5758/5758-tea-ibc@bismilah15/kintilidin15@beccablaster7/emin@bee-icons/qwik@breadev/vite@brc-dd/lunaria-core@bronya.js/api-construct@bronya.js/core@bty/vite-plugin-file-mock@axxy/nuxt@ayi0910/tahu-bulat@baghoez/djarum12@clean-js/api-gen@davidrockefeller/pixelpioneer@datalink/core@d2js/utils@cuiller/cli@danizean/cyberzone@danitama/rusfer@dayatukir/swaptea@cramzzzberry/almost-material-plugin@dovca/nuxt-utils@docus/app-edge@docus/core@docus/windicss-edge@docus/windicss-edge-edge@docus/windicss-module@docus/nuxt3-docs@docus/windicss@docusaurus/utils@docus/app@digitalrakesh/jsui@dite/core@dword-design/eslint-config@dword-design/babel-config@dword-design/base-config-nuxt@dword-design/base@dword-design/eslint-plugin-import-alias@dword-design/express-mount-files@dword-design/nuxt-kit@dword-design/stylelint-config@dtwo/kit@dtwo/kit-edge@dtwo/schema@dtwo/schema-edge@dtwo/telemetry@dtwo/utils@dtwo/utils-edge@ext-js/core@enirisdev/angular-google-charts@fabioni/vercel-builder-fix@girhan/moko@formkit/cli@gqlb/cli@genesislcap/build-kit@genesislcap/buildkit@farnabaz/storybook@hebilicious/nitro@hebilicious/unstable-nitro@hixt/kit@hixt/nitro@hixt/schema@haysquare/svelte-multiselect@haysquare/svelte-multi-select@firestead/kit@firstday/firstdayteh@frontline-hq/tailwind-dynamic-components@frontline-hq/tdc@genapi/core
1.21.0

6 months ago

1.20.0

8 months ago

1.19.0

10 months ago

1.19.3

9 months ago

1.19.2

9 months ago

1.19.1

10 months ago

1.18.1

1 year ago

1.18.0

1 year ago

1.16.2

1 year ago

1.18.2

1 year ago

1.17.2

1 year ago

1.17.1

1 year ago

1.17.0

1 year ago

1.16.1

1 year ago

1.16.0

2 years ago

1.15.0

2 years ago

1.14.0

2 years ago

1.12.10

2 years ago

1.12.15

2 years ago

1.12.12

2 years ago

1.12.11

2 years ago

1.12.14

2 years ago

1.12.13

2 years ago

1.13.0

2 years ago

1.12.9

3 years ago

1.12.8

3 years ago

1.12.7

3 years ago

1.12.6

3 years ago

1.12.5

3 years ago

1.12.4

3 years ago

1.12.3

3 years ago

1.12.2

3 years ago

1.12.1

3 years ago

1.12.0

3 years ago

1.11.0

3 years ago

1.10.1

3 years ago

1.10.0

3 years ago

1.9.2

3 years ago

1.9.1

3 years ago

1.9.0

3 years ago

1.8.0

3 years ago

1.7.0

3 years ago

1.6.4

3 years ago

1.6.3

3 years ago

1.6.2

3 years ago

1.6.1

3 years ago

1.6.0

3 years ago

1.5.0

3 years ago

1.4.0

3 years ago

1.3.0

3 years ago

1.2.1

3 years ago

1.2.0

3 years ago

1.1.0

3 years ago

1.0.0

3 years ago

0.1.20

3 years ago

0.1.19

3 years ago

0.1.18

3 years ago

0.1.17

3 years ago

0.1.16

3 years ago

0.1.15

3 years ago

0.1.14

3 years ago

0.1.13

3 years ago

0.1.12

4 years ago

0.1.10

4 years ago

0.1.11

4 years ago

0.1.9

4 years ago

0.1.8

4 years ago

0.1.7

4 years ago

0.1.6

4 years ago

0.1.5

4 years ago

0.1.4

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago

0.0.0

4 years ago