Registry / web-framework / svelte-preprocess-esbuild

svelte-preprocess-esbuild

JSON →
library3.0.1jsnpmunverified

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.

npm install svelte-preprocess-esbuild
INSTALL
IMPORT
SIG · SVELTE-PREPROCESS-
S
svelte-preprocess-esbuild
web-frameworkjavascriptv3.0.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

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

typescript
import { typescript } from 'svelte-preprocess-esbuild'
const typescript = require('svelte-preprocess-esbuild').typescript
Both ESM and CJS supported; require works but import preferred in modern projects.
replace
import { replace } from 'svelte-preprocess-esbuild'
import replace from 'svelte-preprocess-esbuild'
`replace` is a named export, not default.
sveltePreprocessEsbuild
import sveltePreprocessEsbuild from 'svelte-preprocess-esbuild'
import { default } from 'svelte-preprocess-esbuild'
Default export is an object containing `typescript` and `replace`; usage discouraged in favor of named imports.

Configures Svelte to use esbuild for TypeScript compilation alongside svelte-preprocess, with example options for target and define.

// svelte.config.js import preprocess from 'svelte-preprocess'; import { typescript } from 'svelte-preprocess-esbuild'; export default { preprocess: [ typescript({ target: 'es2020', define: { 'process.browser': 'true' } }), preprocess({ typescript: false }) ] };
Debug
Known issues
gotchaWhen using with `svelte-preprocess`, you must set `typescript: false` in `svelte-preprocess` options to avoid double compilation.
fix
Add `preprocess({ typescript: false })` after the `typescript` preprocessor from this package.
affects: *
gotcha`options.define` replacements will be applied to ALL script tags, including non-TypeScript ones, when using `typescript` preprocessor.
fix
Use the `replace` function separately if you want define replacements only on non-TypeScript scripts.
affects: *
deprecatedThe `minify` option is forced to false internally; setting it has no effect.
fix
Do not pass `minify`; it is always false.
affects: *
breakingIn v3, the default export changed from a function to an object with `typescript` and `replace` properties.
fix
Use named imports: `import { typescript } from 'svelte-preprocess-esbuild'`.
affects: 3.x
gotchaThe `tsconfig` option throws if file not found when explicitly provided; default attempts to auto-load but does not throw if missing.
fix
Omit `tsconfig` or provide a valid path.
affects: *
Errors
Common errors & fixes
Error: Cannot find module 'esbuild'
Missing peer dependency `esbuild`.
fix
Install esbuild: `npm install --save-dev esbuild`.
Error: Multiple typescript preprocessors detected
Using both `svelte-preprocess-esbuild` and `svelte-preprocess` with its built-in TypeScript support, causing double compilation.
fix
Set `typescript: false` in `svelte-preprocess` options.
TypeError: sveltePreprocessEsbuild.typescript is not a function
Attempting to use default import as a function after v3 API change.
fix
Use `const { typescript } = require('svelte-preprocess-esbuild')` or `import { typescript } from 'svelte-preprocess-esbuild'`.
error: Unexpected "define"
Passing `define` option to `replace` function, which does not support it.
fix
Use `typescript` function instead for define replacements.
Upgrade
Version history
3.0.1latest on npm
Audit
Dependencies
esbuildrequiredpeer dependency for TypeScript compilation
svelterequiredpeer dependency for Svelte preprocessing
Agent activity
7 hits · last 30 days
node
6
Resources
svelte-preprocess-esbuild — npm install svelte-preprocess-esbuild · libregistry