Registry / web-framework / esbuild-plugin-svelte

esbuild-plugin-svelte

JSON →
library0.1.1jsnpmunverified

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.

npm install esbuild-plugin-svelte
INSTALL
IMPORT
SIG · ESBUILD-PLUGIN-SVE
E
esbuild-plugin-svelte
web-frameworkjavascriptv0.1.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
✓ import svelte from 'esbuild-plugin-svelte'
✗ import { svelte } from 'esbuild-plugin-svelte'
Default export only; named import will result in undefined.
esbuild.build
✓ import { build } from 'esbuild'
✗ const build = require('esbuild').build
ESM is preferred; CommonJS require works but is not typical for esbuild.
svelte-preprocess
✓ import preprocess from 'svelte-preprocess'
✗ const preprocess = require('svelte-preprocess')
If using preprocessors, install svelte-preprocess separately. ESM import is recommended.

Bundles a Svelte app using esbuild with the svelte plugin, outputting a single JS bundle.

import { build } from 'esbuild'; import svelte from 'esbuild-plugin-svelte'; build({ entryPoints: ['src/main.js'], bundle: true, outfile: 'dist/bundle.js', plugins: [svelte()], }).catch(() => process.exit(1));
Debug
Known issues
breakingThis plugin only supports Svelte 3; Svelte 4 or 5 will not compile.
fix
Use svelte@^3.20. If using Svelte 4+, switch to a compatible plugin (e.g., @j3w1/esbuild-plugin-svelte).
affects: >=0.0.0
gotchaCSS output is disabled by default; if you need separate CSS, set compilerOptions.css to true.
fix
Pass { compilerOptions: { css: true } } to svelte() plugin.
affects: >=0.0.0
breakingRequires esbuild ^0.8; does not work with esbuild 0.9+ due to API changes.
fix
Downgrade esbuild to 0.8.x or use a newer fork of the plugin.
affects: >=0.0.0
deprecatedThis package has not been updated since 2021; consider using maintained forks.
fix
Switch to @j3w1/esbuild-plugin-svelte or @sveltejs/enhanced-img for newer esbuild versions.
affects: >=0.0.0
Errors
Common errors & fixes
Cannot find module 'esbuild-plugin-svelte'
Plugin not installed or missing from package.json.
fix
npm install --save-dev esbuild-plugin-svelte
Dynamic require of "esbuild-plugin-svelte" is not supported
Using CommonJS require in an ESM context.
fix
Use import svelte from 'esbuild-plugin-svelte' instead of require().
TypeError: svelte is not a function
Incorrect import (named import instead of default).
fix
Use import svelte from 'esbuild-plugin-svelte' (no braces).
Upgrade
Version history
0.1.1latest on npm
Audit
Dependencies
esbuildrequiredpeer dependency required for plugin to run
svelterequiredpeer dependency for Svelte compilation
Agent activity
6 hits · last 30 days
node
6
Resources
esbuild-plugin-svelte — npm install esbuild-plugin-svelte · libregistry