All Projects → EMH333 → esbuild-svelte

EMH333 / esbuild-svelte

Licence: MIT License
An esbuild plugin to compile Svelte components

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects
Svelte
593 projects
HTML
75241 projects

Projects that are alternatives of or similar to esbuild-svelte

sapper-typescript-esbuild-template
Sapper template with ESBuild and TypeScript
Stars: ✭ 18 (-88.96%)
Mutual labels:  svelte, esbuild
svelte-spinkit
A collection of loading indicators animated with CSS for Svelte
Stars: ✭ 27 (-83.44%)
Mutual labels:  svelte
svelte-style-directive
A custom Svelte preprocessor to add support for style directive.
Stars: ✭ 19 (-88.34%)
Mutual labels:  svelte
programmingtil-svelte
No description or website provided.
Stars: ✭ 59 (-63.8%)
Mutual labels:  svelte
rescript-react-boilerplate
An opinionated app shell for ReScript & React progressive web apps
Stars: ✭ 62 (-61.96%)
Mutual labels:  esbuild
plate-app
🍛 What's on your Plate?
Stars: ✭ 49 (-69.94%)
Mutual labels:  svelte
svelte-hamburgers
Custom Hamburger Icons in Svelte with ease
Stars: ✭ 27 (-83.44%)
Mutual labels:  svelte
DeLorean
Time-traveling debugger for Svelte applications
Stars: ✭ 58 (-64.42%)
Mutual labels:  svelte
EddieHubCommunity.github.io
Information about our community
Stars: ✭ 88 (-46.01%)
Mutual labels:  svelte
svelte-flat-ui
Flat UI Independent JS Components + English Docs =
Stars: ✭ 45 (-72.39%)
Mutual labels:  svelte
p5-svelte
Easily add p5 sketches to a Svelte project 🍛 🌱
Stars: ✭ 94 (-42.33%)
Mutual labels:  svelte
dotto.x
A tiny state manager for React, Svelte, Vue and vanilla JS
Stars: ✭ 104 (-36.2%)
Mutual labels:  svelte
routify-ts
Use Typescript in Routify Starter Template.
Stars: ✭ 21 (-87.12%)
Mutual labels:  svelte
svelvg
Convert SVG files into Svelte components with TypeScript definitions
Stars: ✭ 19 (-88.34%)
Mutual labels:  svelte
web
🧗 Timely climbing/bouldering gym slot info
Stars: ✭ 18 (-88.96%)
Mutual labels:  svelte
clui
A command system with extra steps
Stars: ✭ 18 (-88.96%)
Mutual labels:  svelte
agnosticui
AgnosticUI is a set of UI primitives that start their lives in clean HTML and CSS. These standards compliant components are then copied to our framework implementations in: React, Vue 3, Angular, and Svelte.
Stars: ✭ 326 (+100%)
Mutual labels:  svelte
svelte-headlessui
Unofficial Svelte port of Headless UI components
Stars: ✭ 564 (+246.01%)
Mutual labels:  svelte
micro-svelte-compiler
Micro Svelte compiler (naive clone)
Stars: ✭ 56 (-65.64%)
Mutual labels:  svelte
awesome-svelte-kit
Curated resources on building sites with SvelteKit - A server-less-first answer to "the Next.js experience" by the Svelte community
Stars: ✭ 55 (-66.26%)
Mutual labels:  svelte

esbuild-svelte

npm version npm downloads CI

Plugin to compile svelte components for bundling with esbuild.

Install

Install both this plugin and esbuild (esbuild must be above 0.9.6).

A simple build script looks like

import esbuild from "esbuild";
import sveltePlugin from "esbuild-svelte";

esbuild
  .build({
    entryPoints: ["app.js"],
    mainFields: ["svelte", "browser", "module", "main"],
    bundle: true,
    outfile: "out.js",
    plugins: [sveltePlugin()],
    logLevel: "info",
  })
  .catch(() => process.exit(1));

The example folder of this repository is a great starting off point for a "complete" project.

CSS Output

By default, esbuild-svelte emits external css files from Svelte for esbuild to process. If this isn't desired, use a configuration that turns off external css output and instead includes it in the javascript output. For example: sveltePlugin({compilerOptions: {css: true}})

Typescript and Other Svelte Preprocessing

In order to support Typescript and other languages that require preprocessing before being fed into the Svelte compiler, simply add the preprocessor to the preprocess option (which accepts both a single preprocessor or an array of them). The example script below is a great place to start.

import esbuild from "esbuild";
import esbuildSvelte from "esbuild-svelte";
import sveltePreprocess from "svelte-preprocess";

esbuild
  .build({
    entryPoints: ["index.js"],
    mainFields: ["svelte", "browser", "module", "main"],
    bundle: true,
    outdir: "./dist",
    plugins: [
      esbuildSvelte({
        preprocess: sveltePreprocess(),
      }),
    ],
  })
  .catch(() => process.exit(1));

Advanced

For incremental or watch build modes, esbuild-svelte will automatically cache files if they haven't changed. This allows esbuild to skip the Svelte compiler for those files altogether, saving time. Setting cache: false will disable this file level cache if an issue arises (please report).

You can see the full API for this plugin here, which includes support for Svelte's compiler options, preprocessing API, and more.

Developing

Clone, npm install, npm link and it's good to go! Releases are automated (with the right permissions), just by running npm version patch|minor|major.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].