{"id":18817830,"url":"https://github.com/vitorluizc/ts-jest-resolver","last_synced_at":"2025-05-07T10:11:53.090Z","repository":{"id":48352235,"uuid":"350124044","full_name":"VitorLuizC/ts-jest-resolver","owner":"VitorLuizC","description":"A resolver for jest that uses the same strategy as TS when resolving files with JavaScript extensions (\".js\", \".jsx\", \".cjs\" and \".mjs\"). It works pretty well with ts-jest or babel with @babel/preset-typescript.","archived":false,"fork":false,"pushed_at":"2023-03-20T03:18:58.000Z","size":450,"stargazers_count":60,"open_issues_count":1,"forks_count":5,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-22T18:57:08.513Z","etag":null,"topics":["jest","jest-resolver","ts-jest","ts-jest-resolver","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/VitorLuizC.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-03-21T21:29:50.000Z","updated_at":"2024-08-17T08:17:36.000Z","dependencies_parsed_at":"2024-06-18T15:21:11.458Z","dependency_job_id":"0f14fe94-7f15-4b49-95c5-5f9b6e547525","html_url":"https://github.com/VitorLuizC/ts-jest-resolver","commit_stats":{"total_commits":33,"total_committers":2,"mean_commits":16.5,"dds":"0.030303030303030276","last_synced_commit":"e35fcd388f6503b5bcb701a216a4beb2df1e1f7e"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":"VitorLuizC/typescript-library-boilerplate","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VitorLuizC%2Fts-jest-resolver","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VitorLuizC%2Fts-jest-resolver/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VitorLuizC%2Fts-jest-resolver/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VitorLuizC%2Fts-jest-resolver/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/VitorLuizC","download_url":"https://codeload.github.com/VitorLuizC/ts-jest-resolver/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":231439030,"owners_count":18376836,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["jest","jest-resolver","ts-jest","ts-jest-resolver","typescript"],"created_at":"2024-11-08T00:13:36.387Z","updated_at":"2024-12-27T05:05:30.325Z","avatar_url":"https://github.com/VitorLuizC.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ts-jest-resolver\n\n[![Build Status](https://travis-ci.org/VitorLuizC/ts-jest-resolver.svg?branch=master)](https://travis-ci.org/VitorLuizC/ts-jest-resolver)\n[![License](https://badgen.net/github/license/VitorLuizC/ts-jest-resolver)](./LICENSE)\n\nA resolver for [`jest`](https://jestjs.io/) that uses the same strategy as TS when resolving files with JavaScript extensions (\".js\", \".jsx\", \".cjs\" and \".mjs\"). It works pretty well with [`ts-jest`](https://kulshekhar.github.io/ts-jest/) or [`babel`](https://babeljs.io/) with [`@babel/preset-typescript`](https://babeljs.io/docs/en/babel-preset-typescript).\n\n- 📦 Distributions in ESM and CommonJS.\n  - Supports both Node.js ESM (import/export) and CommonJS (require/module.exports).\n- ⚡ Lightweight:\n  - It's bundled using rollup.js.\n- 🔋 Bateries included:\n  - It just depends on `jest-resolver` types.\n- ✅ Safe:\n  - Made with ESLint, TypeScript as strict as possible.\n  - Unit tests with Jest.\n  - Like `ts-jest`, `ts-jest-resolver` [uses itself as jest's resolver](https://github.com/VitorLuizC/ts-jest-resolver/commit/a2cc8f6482250380c2c735bf8827eb64082d5ef6).\n\n## Usage\n\nThis library is published in the NPM registry and can be installed using any compatible package manager.\n\n```sh\nnpm install ts-jest-resolver --save\n\n# For Yarn, use the command below.\nyarn add ts-jest-resolver\n```\n\nAfter installation, you can set `\"ts-jest-resolver\"` as jest's resolver.\n\n```js\n// jest.config.js\n\nmodule.exports = {\n  preset: \"ts-jest\",\n  resolver: \"ts-jest-resolver\",\n};\n```\n\n## How it works\n\nIt changes module's extension to resolve in the same way as TypeScript.\n\n### How it works with \".js\" and \".jsx\" extensions\n\nWhen importing from path with JavaScript extension (\".js\" or \".jsx\"):\n\n```js\nimport EventEmitter from './EventEmitter.js';\n```\n\n1. It tries to resolve to a path with \".tsx\";\n\n   ```js\n   import EventEmitter from './EventEmitter.tsx';\n   ```\n\n2. If no file was found, it tries to resolve to a path with \".ts\";\n\n   ```js\n   import EventEmitter from './EventEmitter.ts';\n   ```\n\n3. If no file was found, it resolves to original path (with \".js\" or \".jsx\").\n\n   ```js\n   import EventEmitter from './EventEmitter.js';\n   ```\n\n### How it works with \".mjs\" and \".cjs\" extensions\n\nWhen importing from path with ES or CommonJS modules (\".mjs\" and \".cjs\" respectively):\n\nEx.\n```ts\nimport parse, { Tokenizer } from './parser.mjs'\nimport { discoverPath } from './getFiles.cjs';\n```\n\n1. It tries to resolve to paths with \".mts\" and \".cts\".\n\n   Ex.\n\n   ```ts\n   import parse, { Tokenizer } from './parser.mts'\n   import { discoverPath } from './getFiles.cts';\n   ```\n\n2. If no files were found, it resolves to original paths (with \".mjs\" and \".cjs\").\n\n   Ex.\n\n   ```ts\n   import parse, { Tokenizer } from './parser.mjs'\n   import { discoverPath } from './getFiles.cjs';\n   ```\n\n\n\n## License\n\nReleased under [MIT License](./LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvitorluizc%2Fts-jest-resolver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvitorluizc%2Fts-jest-resolver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvitorluizc%2Fts-jest-resolver/lists"}