{"id":25409,"library":"esbuild-plugin-svelte","title":"esbuild-plugin-svelte","description":"An esbuild plugin to compile Svelte components during bundling. At version 0.1.1, it integrates Svelte 3 with esbuild, handling .svelte files and generating CSS as separate output. It supports preprocessors and compiler options via svelte.config.js. Compared to alternatives like rollup-plugin-svelte, this plugin is lightweight and designed for esbuild's speed. It is best suited for projects already using esbuild and needing Svelte support. Note that it only supports Svelte 3 and esbuild ^0.8. CSS handling defaults to false (esbuild manages CSS) unless overridden.","status":"active","version":"0.1.1","language":"javascript","source_language":"en","source_url":"https://github.com/yagebu/esbuild-plugin-svelte","tags":["javascript","esbuild","svelte","plugin","typescript"],"install":[{"cmd":"npm install esbuild-plugin-svelte","lang":"bash","label":"npm"},{"cmd":"yarn add esbuild-plugin-svelte","lang":"bash","label":"yarn"},{"cmd":"pnpm add esbuild-plugin-svelte","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency required for plugin to run","package":"esbuild","optional":false},{"reason":"peer dependency for Svelte compilation","package":"svelte","optional":false}],"imports":[{"note":"Default export only; named import will result in undefined.","wrong":"import { svelte } from 'esbuild-plugin-svelte'","symbol":"default","correct":"import svelte from 'esbuild-plugin-svelte'"},{"note":"ESM is preferred; CommonJS require works but is not typical for esbuild.","wrong":"const build = require('esbuild').build","symbol":"esbuild.build","correct":"import { build } from 'esbuild'"},{"note":"If using preprocessors, install svelte-preprocess separately. ESM import is recommended.","wrong":"const preprocess = require('svelte-preprocess')","symbol":"svelte-preprocess","correct":"import preprocess from 'svelte-preprocess'"}],"quickstart":{"code":"import { build } from 'esbuild';\nimport svelte from 'esbuild-plugin-svelte';\n\nbuild({\n  entryPoints: ['src/main.js'],\n  bundle: true,\n  outfile: 'dist/bundle.js',\n  plugins: [svelte()],\n}).catch(() => process.exit(1));","lang":"javascript","description":"Bundles a Svelte app using esbuild with the svelte plugin, outputting a single JS bundle."},"warnings":[{"fix":"Use svelte@^3.20. If using Svelte 4+, switch to a compatible plugin (e.g., @j3w1/esbuild-plugin-svelte).","message":"This plugin only supports Svelte 3; Svelte 4 or 5 will not compile.","severity":"breaking","affected_versions":">=0.0.0"},{"fix":"Pass { compilerOptions: { css: true } } to svelte() plugin.","message":"CSS output is disabled by default; if you need separate CSS, set compilerOptions.css to true.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Downgrade esbuild to 0.8.x or use a newer fork of the plugin.","message":"Requires esbuild ^0.8; does not work with esbuild 0.9+ due to API changes.","severity":"breaking","affected_versions":">=0.0.0"},{"fix":"Switch to @j3w1/esbuild-plugin-svelte or @sveltejs/enhanced-img for newer esbuild versions.","message":"This package has not been updated since 2021; consider using maintained forks.","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":"npm install --save-dev esbuild-plugin-svelte","cause":"Plugin not installed or missing from package.json.","error":"Cannot find module 'esbuild-plugin-svelte'"},{"fix":"Use import svelte from 'esbuild-plugin-svelte' instead of require().","cause":"Using CommonJS require in an ESM context.","error":"Dynamic require of \"esbuild-plugin-svelte\" is not supported"},{"fix":"Use import svelte from 'esbuild-plugin-svelte' (no braces).","cause":"Incorrect import (named import instead of default).","error":"TypeError: svelte is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}