{"id":22427,"library":"svelte-preprocess-esbuild","title":"svelte-preprocess-esbuild","description":"A Svelte preprocessor that compiles TypeScript in Svelte files using esbuild. Version 3.0.1 is the latest stable release. It offers faster TypeScript compilation compared to svelte-preprocess's Babel-based TypeScript support, with a subset of esbuild's transform options. It provides both a `typescript` function and a `replace` function for define replacements. Ships TypeScript typings. Peer dependencies: esbuild >=0.14.0 and svelte >=3.5.0. Requires Node >=10. Maintained primarily by lukeed, with stable release cadence.","status":"active","version":"3.0.1","language":"javascript","source_language":"en","source_url":"https://github.com/lukeed/svelte-preprocess-esbuild","tags":["javascript","esbuild","preprocess","typescript","svelte"],"install":[{"cmd":"npm install svelte-preprocess-esbuild","lang":"bash","label":"npm"},{"cmd":"yarn add svelte-preprocess-esbuild","lang":"bash","label":"yarn"},{"cmd":"pnpm add svelte-preprocess-esbuild","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency for TypeScript compilation","package":"esbuild","optional":false},{"reason":"peer dependency for Svelte preprocessing","package":"svelte","optional":false}],"imports":[{"note":"Both ESM and CJS supported; require works but import preferred in modern projects.","wrong":"const typescript = require('svelte-preprocess-esbuild').typescript","symbol":"typescript","correct":"import { typescript } from 'svelte-preprocess-esbuild'"},{"note":"`replace` is a named export, not default.","wrong":"import replace from 'svelte-preprocess-esbuild'","symbol":"replace","correct":"import { replace } from 'svelte-preprocess-esbuild'"},{"note":"Default export is an object containing `typescript` and `replace`; usage discouraged in favor of named imports.","wrong":"import { default } from 'svelte-preprocess-esbuild'","symbol":"sveltePreprocessEsbuild","correct":"import sveltePreprocessEsbuild from 'svelte-preprocess-esbuild'"}],"quickstart":{"code":"// svelte.config.js\nimport preprocess from 'svelte-preprocess';\nimport { typescript } from 'svelte-preprocess-esbuild';\n\nexport default {\n  preprocess: [\n    typescript({\n      target: 'es2020',\n      define: {\n        'process.browser': 'true'\n      }\n    }),\n    preprocess({ typescript: false })\n  ]\n};\n","lang":"typescript","description":"Configures Svelte to use esbuild for TypeScript compilation alongside svelte-preprocess, with example options for target and define."},"warnings":[{"fix":"Add `preprocess({ typescript: false })` after the `typescript` preprocessor from this package.","message":"When using with `svelte-preprocess`, you must set `typescript: false` in `svelte-preprocess` options to avoid double compilation.","severity":"gotcha","affected_versions":"*"},{"fix":"Use the `replace` function separately if you want define replacements only on non-TypeScript scripts.","message":"`options.define` replacements will be applied to ALL script tags, including non-TypeScript ones, when using `typescript` preprocessor.","severity":"gotcha","affected_versions":"*"},{"fix":"Do not pass `minify`; it is always false.","message":"The `minify` option is forced to false internally; setting it has no effect.","severity":"deprecated","affected_versions":"*"},{"fix":"Use named imports: `import { typescript } from 'svelte-preprocess-esbuild'`.","message":"In v3, the default export changed from a function to an object with `typescript` and `replace` properties.","severity":"breaking","affected_versions":"3.x"},{"fix":"Omit `tsconfig` or provide a valid path.","message":"The `tsconfig` option throws if file not found when explicitly provided; default attempts to auto-load but does not throw if missing.","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Install esbuild: `npm install --save-dev esbuild`.","cause":"Missing peer dependency `esbuild`.","error":"Error: Cannot find module 'esbuild'"},{"fix":"Set `typescript: false` in `svelte-preprocess` options.","cause":"Using both `svelte-preprocess-esbuild` and `svelte-preprocess` with its built-in TypeScript support, causing double compilation.","error":"Error: Multiple typescript preprocessors detected"},{"fix":"Use `const { typescript } = require('svelte-preprocess-esbuild')` or `import { typescript } from 'svelte-preprocess-esbuild'`.","cause":"Attempting to use default import as a function after v3 API change.","error":"TypeError: sveltePreprocessEsbuild.typescript is not a function"},{"fix":"Use `typescript` function instead for define replacements.","cause":"Passing `define` option to `replace` function, which does not support it.","error":"error: Unexpected \"define\""}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}