{"id":15021379,"url":"https://github.com/gtsop/babel-jest-boost","last_synced_at":"2025-10-28T16:31:24.426Z","repository":{"id":236532913,"uuid":"792794602","full_name":"gtsop/babel-jest-boost","owner":"gtsop","description":"🐠 🃏 🚀 - Faster tests, using Babel","archived":false,"fork":false,"pushed_at":"2024-11-12T18:15:30.000Z","size":463,"stargazers_count":13,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-01T16:35:58.235Z","etag":null,"topics":["babel","babel-jest","babel-plugin","barrel-files","javascript","jest","performance"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@gtsopanoglou/babel-jest-boost","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gtsop.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":"2024-04-27T15:47:14.000Z","updated_at":"2025-01-08T12:24:02.000Z","dependencies_parsed_at":"2024-08-19T09:17:14.255Z","dependency_job_id":null,"html_url":"https://github.com/gtsop/babel-jest-boost","commit_stats":null,"previous_names":["gtsop/babel-jest-boost"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gtsop%2Fbabel-jest-boost","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gtsop%2Fbabel-jest-boost/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gtsop%2Fbabel-jest-boost/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gtsop%2Fbabel-jest-boost/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gtsop","download_url":"https://codeload.github.com/gtsop/babel-jest-boost/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238680771,"owners_count":19512636,"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":["babel","babel-jest","babel-plugin","barrel-files","javascript","jest","performance"],"created_at":"2024-09-24T19:56:30.965Z","updated_at":"2025-10-28T16:31:18.981Z","avatar_url":"https://github.com/gtsop.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1\u003e\n  \u003cp align=\"center\"\u003e🐠 🃏 🚀\u003c/p\u003e\n  \u003cbr/\u003e\n  \u003cp align=\"center\"\u003eBabel Jest Boost\u003c/p\u003e\n\u003c/h1\u003e\n\u003cp align=\"center\"\u003eFaster tests, using Babel\u003c/p\u003e\n\n## Overview\n\n`babel-jest-boost` is a Babel plugin that makes your tests run faster by solving the [problem of unecessary imports from barrel files](https://github.com/jestjs/jest/issues/11234). It does that by re-writing your import statements (only for tests) to skip intermediate re-exports, thus bypassing barrel files.\n\n## Usage\n\n### Step 1: Install the package\n\n```bash\nnpm install -D @gtsopanoglou/babel-jest-boost\n```\n\n### Step 2: Use the `babel-jest-boost` plugin in your jest config\n\n#### Method 1\n\nThe simplest way to use this plugin is by replacing the `babel-jest` transformer with the `@gtsopanoglou/babel-jest-boost/transformer` in your jest config:\n\n\u003cdetails\u003e\n  \u003csummary\u003ejest.config.js\u003c/summary\u003e\n  \n```diff\n\"transform\": {\n-  \"\\\\.[jt]sx?$\": \"babel-jest\"\n+  \"\\\\.[jt]sx?$\": \"@gtsopanoglou/babel-jest-boost/transformer\"\n}\n```\n\u003c/details\u003e\n\n\n#### Method 2\n\nYou may use `babel-jest-boost` as a regular babel plugin. It needs access to your jest config (`moduleNameMapper` and `modulePaths` in particular). To help you do that we export a `jestConfig` object. Again an example from an ejected CRA:\n\n\u003cdetails\u003e\n  \u003csummary\u003ejest.config.js\u003c/summary\u003e\n  \n```javascript\n\"transform\": {\n  \"^.+\\\\.(js|jsx|mjs|cjs|ts|tsx)$\": \"\u003crootDir\u003e/config/jest/babelTransform.js\",\n},\n```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003econfig/jest/babelTransform.js\u003c/summary\u003e\n  \n```diff\nconst babelJest = require('babel-jest')\n+const { jestConfig }  = require('@gtsopanoglou/babel-jest-boost/config')\n\nconst hasJsxRuntime = (() =\u003e {\n  if (process.env.DISABLE_NEW_JSX_TRANSFORM === 'true') {\n    return false\n  }\n\n  try {\n    require.resolve('react/jsx-runtime')\n    return true\n  } catch (e) {\n    return false\n  }\n})()\n\nmodule.exports = babelJest.createTransformer({\n  presets: [\n    [\n      require.resolve('babel-preset-react-app'),\n      {\n        runtime: hasJsxRuntime ? 'automatic' : 'classic'\n      }\n    ]\n  ],\n+ plugins: [\n+   [\n+     require.resolve('@gtsopanoglou/babel-jest-boost'),\n+     {\n+        jestConfig,\n+        // babel-jest-boost plugin options\n+     }\n+  ]\n+ ],\n  babelrc: false,\n  configFile: false\n})\n```\n\u003c/details\u003e\n\n### Step 3: Run your tests, prevent breakages\n\nSince `babel-jest-boost` modifies the transpiled code, you will need to clear jest's cache before each run (just for this integration phase) to ensure you see non-cached results:\n\n```bash\njest --clearCache \u0026\u0026 jest # or whatever you testing command is\n```\n\nIt is likely that some tests will now break. The breakage may be caused by some implicit dependency in your code that you're not aware of, or some bug within `babel-jest-boost`.\nEither way, you are not going to fix them right now. In order to avoid this problem you have two tools: `importIgnorePatterns` plugin option and the `no-boost`/`no-boost-next` directives.\n\n### 4. Re-iterate until your tests are green again.\n\n### 5. Done\n\nOnce your tests are green, you are done. You can now keep running your tests as usual without having to clear your cache.\n\n# Plugin options\n\n### `importIgnorePatterns` **[array\\\u003cstring\\\u003e]**\n\nArray of strings/regexes, import paths matching these regexes will prevent `babel-jest-boost` from rewritting them. For instance, assuming this tree:\n\n```bash\n.\n├── lib\n│   ├── lib.js     # export function libFunc () {}\n│   └── index.js   # export * from './lib.js'\n└── code.js        # import { libFunc } from './lib';\n```\n\nIn this scenario, `importIgnorePatterns` will be matched against the only import statement in this tree, `import { libFunc } from './lib'`, so if you wish to exclude imports to `./lib` from being re-written, you can use:\n\n```javascript\n{ importIgnorePatterns: ['./lib'] }\n```\n\nThis is intended to help you defer refactoring some barrels or modules that are causing trouble or breaking your tests when you integrate this plugin.\n\n### `ignoreNodeModules` **[boolean]**\n\nSet this flag to true if you want to completely ignore all node\\_modules imports from being re-written. Default is false.\n\n## Plugin directives\n\n### `no-boost`\n\nYou can ommit transforming all imports/mocks within a file by adding this comment at the top\n\n```javascript\n// @babel-jest-boost no-boost\nimport { libFunc } from './lib';\n```\n\n### `no-boost-next`\n\nYou can ommit specific imports/mocks within a file by adding this comment right above the code to be ommited\n```javascript\n// @babel-jest-boost no-boost-next\nimport { libFunc } from './lib';\n```\n\n## ROADMAP\n- 0.1.22 Expose debugging options to the user (like printing which imports are being rewritten, or the transpiled output of a particular file).\n- 0.1.23 Expose a jest reporter to print a high-level overview of what the plugin did within the run (and potientialy report barel file statistics)\n- 0.1.24 Performance testing: Fork some open-source codebases, integrate `babel-jest-boost` and test to measure the performance increase. Do this in the CI/CD pipeline\n- 0.1.25 Figure out automatic changelog, version increase, github release, npm publish actions\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgtsop%2Fbabel-jest-boost","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgtsop%2Fbabel-jest-boost","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgtsop%2Fbabel-jest-boost/lists"}