{"id":15956339,"url":"https://github.com/denull/svuelte","last_synced_at":"2025-03-17T15:31:28.554Z","repository":{"id":57375745,"uuid":"184410823","full_name":"denull/svuelte","owner":"denull","description":"A Vue to Svelte component migration tool","archived":false,"fork":false,"pushed_at":"2020-03-11T22:11:18.000Z","size":14,"stargazers_count":51,"open_issues_count":3,"forks_count":5,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-12T09:29:09.872Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/denull.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-05-01T12:09:17.000Z","updated_at":"2024-04-26T08:45:37.000Z","dependencies_parsed_at":"2022-09-13T06:51:50.748Z","dependency_job_id":null,"html_url":"https://github.com/denull/svuelte","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/denull%2Fsvuelte","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/denull%2Fsvuelte/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/denull%2Fsvuelte/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/denull%2Fsvuelte/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/denull","download_url":"https://codeload.github.com/denull/svuelte/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244058214,"owners_count":20391056,"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":[],"created_at":"2024-10-07T13:32:02.079Z","updated_at":"2025-03-17T15:31:28.085Z","avatar_url":"https://github.com/denull.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# svuelte\nThis small script is intended to make transitioning from [Vue](https://vuejs.org/) to [Svelte](https://svelte.dev/) easier. Those frameworks are used in a similar fashion, but conceptually use quite different approaches (Vue is a more traditional one, a library, and Svelte is a \"dissapearing framework\").\n\nBecause of those similarities, it's possible to automate some of the changes. It doesn't mean that this tool will do **everything** for you — but it'll try. Some features of Vue are missing from Svelte; if you use them, you'll need to rewrite some parts of your components manually. In most cases, `svuelte` will point you to such parts.\n\nFor now, this tool only works on SFC (Single File Components) individually, converting `.vue` files to `.svelte`.\n\n## Installation and usage\n\n```\nnpm install -g svuelte\n```\n\nThis will make `svuelte` available globally. Now you can run it:\n\n```\nsvuelte /path/to/some/vue/Component.vue /path/to/converted/svelte/Component.svelte\n```\n\nYou can omit output path, in that case `.svelte` file will be produced in the current directory.\n\n## What svuelte will do\n\n### Convert script tag\n\nSvuelte expects that your Vue component contains JS code with a single `export default` statement, containing a component declaration as a static object:\n```html\n\u003cscript\u003e\nexport default {\n  name: 'AButton',\n  ...\n}\n\u003c/script\u003e\n```\n\nIt will look into this object and convert following fields:\n* **props** will be converted to `export let prop = defaultValue; // type`\n* **data** will be converted to `let field = initialValue;`\n* **computed** will be converted to `$: computedField = (() =\u003e { ... })();`. In case the compute function contains only a single `return` statement, it will become simply `$: computedField = expressionAfterReturn;`\n* **beforeCreated** and **created** will be inlined after all variable declarations, at the top of generated `script` tag\n* **mounted**, **beforeUpdate**, **updated**, **destroyed** hooks will be converted to appropriate Svelte equivalents (**onMount**, **beforeUpdate**, **afterUpdate**, **onDestroy**)\n* **methods** will be converted to function declarations at the bottom of the generated `script` tag\n\nSvuelte will try and remove `this.` from places where it would be bound to the component instance (it's not needed in Svelte, as all component fields available as local variables).\n\nIt will look into arrow functions (`() =\u003e this.x * 2` will become `() =\u003e x * 2`), but won't touch simple function declarations (`function foo() { return this.x; }` will be left unchanged).\n\nHowever, if you instantly bind a function to `this`, this binding will be removed as well as all references to `this` from within that function:\n```javascript\nlet bar = function() {\n  console.log(this.x);\n}.bind(this);\n```\n\nWill become:\n```javascript\nlet bar = function() {\n  console.log(x);\n}\n```\n\n### Convert css sections\n\nAny `style` block with a `scoped` attribute will be left unchanged (in Svelte all styles are scoped by default).\n\nWithin unscoped stylesheets, each rule will be wrapped in a `:global(...)` pseudo-selector.\n\n### Convert template\n\nSvuelte will unwrap the `\u003ctemplate\u003e` tag and put it contents and the bottom of the generated Svelte component.\n\nIt will perform following transformations:\n* Attributes starting with `v-bind:` and `:` will be converted to `attr=\"{boundValue}\"` syntax\n* Attributes starting with `v-on:` and `@` will be converted to `on:event=\"{boundFunction}\"` syntax\n* `v-if`, `v-else-if`, `v-else` and `v-for` directives will be converted to corresponding Svelte blocks (`{#if ...}`, `{:else if ...}`, `{:else}`, `{#each ...}`)\n* `v-html` directive will be converted to `{@html field}` (if element contained any children, they will be discarded)\n* Double-bracket `{{ interpolations }}` will be transformed to `{single-bracket}`\n\n## What svuelte won't do\n\nAs you can see already, Svuelte does not cover all features of Vue. In particular,\n* For now, Svuelte will **silently** ignore all references to special fields and methods available on Vue component instances (they start with a \"$\", like `$set`, `$slots` and so on)\n* Directives `v-text`, `v-show`, `v-slot`, `v-pre`, `v-cloak`, `v-once` are **silently** ignored too (for now). Same applies for \"special attributes\" `key`, `ref` and `is`\n* Vue built-in helper components (like `\u003ccomponent\u003e`, `\u003ckeep-alive\u003e`, `\u003ctransition\u003e`) are not converted and left as-is\n* Except for those mentioned above, none of the component options are supported (including `render`, `watch`, `updated`, `activated`, `deactivated` and so on). Svuelte will report each field it was unable to convert\n* Svuelte does not support validation on component properties, unlike Vue. Because of that, the type of the property will be left only as a comment after its declaration. If your component contained custom validators, they will be discarded and Svuelte will warn you about that\n* Computed fields with setters are not supported for now\n\nAlso Svuelte won't perform any improvements/optimisations on your code (except for the trivial ones, like removing `this`). Some parts are probably will be possible to rewrite in a more elegant way (computed fields, for example).\n\nOnce again, after you run `svuelte`, you'll probably get not working code. But it will hopefully help you to get started.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdenull%2Fsvuelte","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdenull%2Fsvuelte","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdenull%2Fsvuelte/lists"}