
Security News
CVE Volume Surges Past 48,000 in 2025 as WordPress Plugin Ecosystem Drives Growth
CVE disclosures hit a record 48,185 in 2025, driven largely by vulnerabilities in third-party WordPress plugins.
svelte-preprocess-esbuild
Advanced tools
A Svelte Preprocessor to compile TypeScript via
esbuild!
$ npm install svelte-preprocess-esbuild esbuild --save-dev
Note:
esbuildis a peer dependency!
You can use svelte-preprocess-esbuild alongside svelte-preprocess!
Example: rollup.config.js
An example rollup.config.js, that uses this plugin alongside svelte-preprocess.
Important: When using
svelte-preprocess(autopreprocessor), you must passfalseto itstypescriptoption. Otherwise, your TypeScript<script>s will be compiled twice!
Please note that this is not a complete Rollup configuration!
Refer to rollup-plugin-svelte for more documentation.
// rollup.config.js
import svelte from 'rollup-plugin-svelte';
import { typescript } from 'svelte-preprocess-esbuild';
import preprocess from 'svelte-preprocess';
export default {
// ...
plugins: [
// ...
svelte({
preprocess: [
typescript({
target: 'es2020',
define: {
'process.browser': 'true'
}
}),
// avoid double compile
preprocess({ typescript: false }),
],
compilerOptions: {
// ...
}
})
]
}
Example: svelte.config.js
// svelte.config.js
const { typescript } = require('svelte-preprocess-esbuild');
const preprocess = require('svelte-preprocess');
module.exports = {
preprocess: [
typescript({
// ...
}),
preprocess({
// avoid double
typescript: false
})
],
compilerOptions: {
//
}
}
Returns: PreprocessorGroup
Invoke esbuild on all <script> tags within your template that match any of the following:
lang="ts" attributelang="typescript" attributetype="application/typescript" attributetype="text/typescript" attributetype="application/ts" attributetype="text/ts" attributesrc="" attribute that ends with .ts extensionAdditionally, whenever options.define is given a value, all <script> tags will be subject to replacements, including non-TypeScript contents!
Type: Object
Required: false
A limited subset of esbuild.TransformOptions is supported. These values are forced (for compatbility and/or reliability): minify, loader, format, and errorLimit.
Please see the exported Options interface for the full detail.
Below is the only option that this plugin adds:
Type: string
Default: tsconfig.json
Load a TypeScript configuration file. When found, is passed to esbuild as its tsconfigRaw option.
When a value is given, an error will be thrown if the file cannot be found and/or parsed correctly.
By default, attempts to autoload tsconfig.json, but will not throw if it's missing.
Returns: PreprocessorGroup
Invoke esbuild on all non-TypeScript <script>s, applying any static string replacements.
Note: This preprocessor will ignore TypeScript contents!
If you are using any TypeScript at all, you should be using thetypescriptpreprocessor withoptions.defineinstead.
Type: Object
Your dictionary of key-value replacement pairs, where keys are replaced by their values.
Important: All values must be stringified!
// rollup.config.js
import svelte from 'rollup-plugin-svelte';
import { replace } from 'svelte-preprocess-esbuild';
export default {
// ...
plugins: [
// ...
svelte({
preprocess: [
replace({
'process.browser': JSON.stringify(true),
'process.env.BASEURL': JSON.stringify('https://foobar.com/'),
})
]
})
]
}
MIT © Luke Edwards
FAQs
A Svelte Preprocessor to compile TypeScript via esbuild
We found that svelte-preprocess-esbuild demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
CVE disclosures hit a record 48,185 in 2025, driven largely by vulnerabilities in third-party WordPress plugins.

Security News
Socket CEO Feross Aboukhadijeh joins Insecure Agents to discuss CVE remediation and why supply chain attacks require a different security approach.

Security News
Tailwind Labs laid off 75% of its engineering team after revenue dropped 80%, as LLMs redirect traffic away from documentation where developers discover paid products.