{"id":13630053,"url":"https://github.com/EMH333/esbuild-svelte","last_synced_at":"2025-04-17T13:31:19.015Z","repository":{"id":38256690,"uuid":"283843824","full_name":"EMH333/esbuild-svelte","owner":"EMH333","description":"An esbuild plugin to compile Svelte components","archived":false,"fork":false,"pushed_at":"2025-04-07T22:19:38.000Z","size":534,"stargazers_count":252,"open_issues_count":12,"forks_count":25,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-08T21:38:17.757Z","etag":null,"topics":["esbuild","javascript","plugin","svelte"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/esbuild-svelte","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/EMH333.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-07-30T18:04:16.000Z","updated_at":"2025-03-28T14:49:35.000Z","dependencies_parsed_at":"2024-03-31T21:29:02.538Z","dependency_job_id":"2054d501-6b76-479e-b1c8-111b16204149","html_url":"https://github.com/EMH333/esbuild-svelte","commit_stats":{"total_commits":228,"total_committers":10,"mean_commits":22.8,"dds":"0.32456140350877194","last_synced_commit":"a6699ebfa5c64fb571307df5a9315b6822f08713"},"previous_names":[],"tags_count":35,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EMH333%2Fesbuild-svelte","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EMH333%2Fesbuild-svelte/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EMH333%2Fesbuild-svelte/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EMH333%2Fesbuild-svelte/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/EMH333","download_url":"https://codeload.github.com/EMH333/esbuild-svelte/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249344782,"owners_count":21254735,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["esbuild","javascript","plugin","svelte"],"created_at":"2024-08-01T22:01:28.610Z","updated_at":"2025-04-17T13:31:19.008Z","avatar_url":"https://github.com/EMH333.png","language":"JavaScript","funding_links":[],"categories":["JavaScript","Plugins"],"sub_categories":[],"readme":"# esbuild-svelte\n\n[![npm version](https://badge.fury.io/js/esbuild-svelte.svg)](https://badge.fury.io/js/esbuild-svelte) [![npm downloads](http://img.shields.io/npm/dm/esbuild-svelte.svg)](https://www.npmjs.org/package/esbuild-svelte) [![CI](https://github.com/EMH333/esbuild-svelte/actions/workflows/ci.yml/badge.svg)](https://github.com/EMH333/esbuild-svelte/actions/workflows/ci.yml)\n\nPlugin to compile svelte components for bundling with esbuild.\n\n## Install\n\nInstall this plugin, [esbuild](https://github.com/evanw/esbuild) and [Svelte](https://github.com/sveltejs/svelte).\n\nA simple build script looks like\n\n```javascript\nimport esbuild from \"esbuild\";\nimport sveltePlugin from \"esbuild-svelte\";\n\nesbuild\n  .build({\n    entryPoints: [\"app.js\"],\n    mainFields: [\"svelte\", \"browser\", \"module\", \"main\"],\n    conditions: [\"svelte\", \"browser\"],\n    bundle: true,\n    outfile: \"out.js\",\n    plugins: [sveltePlugin()],\n    logLevel: \"info\",\n  })\n  .catch(() =\u003e process.exit(1));\n```\n\nThe `example-js` folder of this repository is a great starting off point for a \"complete\" project. You can quickly get started using [degit](https://github.com/Rich-Harris/degit):\n\n```sh\n# Clone the JavaScript example to get started\nnpx degit EMH333/esbuild-svelte/example-js my-svelte-app\n\n# Clone the TypeScript example to get started\nnpx degit EMH333/esbuild-svelte/example-ts my-svelte-app\n```\n\n### CSS Output\n\nBy 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: \"injected\"}})`\n\n### Typescript and Other Svelte Preprocessing\n\nIn 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, you can also look at the `example-ts` folder for a more complete project.\n\n```javascript\nimport esbuild from \"esbuild\";\nimport esbuildSvelte from \"esbuild-svelte\";\nimport sveltePreprocess from \"svelte-preprocess\";\n\nesbuild\n  .build({\n    entryPoints: [\"index.js\"],\n    mainFields: [\"svelte\", \"browser\", \"module\", \"main\"],\n    conditions: [\"svelte\", \"browser\"],\n    bundle: true,\n    outdir: \"./dist\",\n    plugins: [\n      esbuildSvelte({\n        preprocess: sveltePreprocess(),\n      }),\n    ],\n  })\n  .catch(() =\u003e process.exit(1));\n```\n\nTypescript in `.svelte.ts` files is supported natively.\n\n### `svelte` exports condition\n\nIf you are importing a svelte component library, you need to add `\"svelte\"` to `conditions` in esbuild build options. This lets esbuild use the `svelte` property in svelte component's `exports` conditions in `package.json` .\n\n## Advanced\n\nFor 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).\n\nYou can see the full API for this plugin [here](https://github.com/EMH333/esbuild-svelte/blob/main/dist/index.d.ts), which includes support for Svelte's compiler options, preprocessing API, and more.\n\n## Developing\n\nClone, `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`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FEMH333%2Fesbuild-svelte","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FEMH333%2Fesbuild-svelte","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FEMH333%2Fesbuild-svelte/lists"}