{"id":25827,"library":"karma-esbuild-next","title":"karma-esbuild-next","description":"An esbuild preprocessor for the Karma test runner, forked from karma-esbuild. It leverages esbuild for fast compilation and readable output, supporting custom esbuild configurations, plugin integration, and single-bundle mode to merge test files into one bundle. Current version 1.1.0 requires esbuild >=0.17.0. Compared to alternatives like karma-webpack or karma-rollup, it offers significantly faster build times due to esbuild's speed, while maintaining compatibility with Karma's standard preprocessor interface.","status":"active","version":"1.1.0","language":"javascript","source_language":"en","source_url":"https://github.com/alexandernst/karma-esbuild-next","tags":["javascript","karma-plugin","karma-preprocessor","esbuild"],"install":[{"cmd":"npm install karma-esbuild-next","lang":"bash","label":"npm"},{"cmd":"yarn add karma-esbuild-next","lang":"bash","label":"yarn"},{"cmd":"pnpm add karma-esbuild-next","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency: esbuild is required for compilation","package":"esbuild","optional":false}],"imports":[{"note":"Install the package, then configure in karma.conf.js","wrong":"npm install --save-dev karma-esbuild","symbol":"karma-esbuild-next","correct":"npm install --save-dev karma-esbuild-next"},{"note":"The preprocessor name is 'esbuild', not the package name","wrong":"preprocessors: { \"test/**/*.test.js\": [\"karma-esbuild-next\"] }","symbol":"config.set({ preprocessors: { \"test/**/*.test.js\": [\"esbuild\"] } })","correct":"preprocessors: { \"test/**/*.test.js\": [\"esbuild\"] }"},{"note":"Use 'singleBundle' for bundling test files; 'bundle' is an esbuild option but not directly supported","wrong":"config.set({ esbuild: { bundle: true } })","symbol":"esbuild config block","correct":"config.set({ esbuild: { define: {}, plugins: [], singleBundle: true } })"}],"quickstart":{"code":"// karma.conf.js\nmodule.exports = function (config) {\n  config.set({\n    frameworks: ['mocha'],\n    files: ['test/**/*.test.js'],\n    preprocessors: {\n      'test/**/*.test.js': ['esbuild']\n    },\n    plugins: [\n      'karma-esbuild-next'\n    ],\n    esbuild: {\n      define: {\n        'process.env.NODE_ENV': JSON.stringify('test')\n      },\n      singleBundle: true\n    },\n    browsers: ['ChromeHeadless'],\n    singleRun: true\n  });\n};","lang":"javascript","description":"Configure Karma to use esbuild preprocessor with Mocha, a define variable, and single bundle mode."},"warnings":[{"fix":"Use 'esbuild' in preprocessors array, not 'karma-esbuild-next'","message":"Preprocessor name must be 'esbuild', not the package name","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Update esbuild to version 0.17.0 or later","message":"Requires esbuild >=0.17.0; older versions may fail","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Set singleBundle: false if you need separate bundles per test file","message":"singleBundle defaults to true; all test files are bundled into one. This can cause issues if tests rely on separate scopes for globals.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Switch to karma-esbuild-next","message":"The original karma-esbuild package is unmaintained; this fork is the recommended alternative","severity":"deprecated","affected_versions":">=0.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Ensure you have added 'karma-esbuild-next' to plugins array in karma.conf.js","cause":"Missing 'esbuild' in preprocessors array incorrectly, or plugin not installed","error":"Error: No provider for \"framework:esbuild\"! (Resolving: esbuild)"},{"fix":"Run 'npm install --save-dev karma-esbuild-next'","cause":"Package not installed or not listed in package.json devDependencies","error":"Error: Cannot find module 'karma-esbuild-next'"},{"fix":"Use 'singleBundle' instead of 'bundle' for Karma-specific bundling","cause":"Using esbuild 'bundle' option inside esbuild config block in karma.conf.js","error":"Error: esbuild: Unexpected option: bundle"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}