Meteor + Svelte

Really excited to play around with svelte over the holidays. Going to be fun to try something really different!

4 Likes

I thought this article interview with Rich Harris is interesting.

For migrating existing projects using Blaze, it would be really helpful to allow co-existence with Blaze by providing an alternative file ending.

And after reading almost everything on https://svelte.technology, the concept feels very natural for an experienced Blaze user as me, so Iā€™d like to give it a try on some of the slow Blaze templates in an existing project.

3 Likes

I completely agree that this would be useful. The problem is that Meteor doesnā€™t allow file extensions to be registered by more than one build plugin, so if we would add .svelte to make it compatible with Blaze, we would have to remove .html from the list of supported extensions. On the one hand, people already using this plugin would have to rename their files. But on the other hand, the benefits might be worth the change.

Iā€™m no expert of the Meteor build system, but maybe it would just help to divide the extension in two parts:

  • svelte:compiler, which contains the core components to use Svelte in a Meteor project with .svelte files,
  • svelte:html-components to provide the file binding to .html.

Furthermore, itā€™ll need something to integrate Svelte components into existing Blaze templates (and maybe vice versa). I donā€™t know, if thereā€™s already some kind of API in Meteor to integrate the different technologies for templates and components (I didnā€™t find one on https://docs.meteor.com).

1 Like

Honestly I donā€™t think there is any benefit to migrating existing Blaze apps to Svelte - I would be surprised if it was faster or better in a meaningful way.

Honestly, modern front-end frameworks are way more than fast enough (even more so when they are PWA-ready):


Source of vue-hacker-news.

@klaussner Soā€¦does svelte solve meteors long standing problem of incremental loading? Can we simply download a single 5kb index.html on initial load or do we still have to bear with a megabytes worth of letā€™s-dump-all-code-into-one-huge-file.js?

Btw, Funny how svelte templating syntax is similar to blaze:grin:

According to https://svelte.technology/blog/frameworks-without-the-framework/ Svelte is faster than the other tested options (React, Vue, ā€¦). Blaze is not tested in https://github.com/krausest/js-framework-benchmark, but AFAIK is less performant.

I personally find Svelte nearer to Blaze than Vue.

Furthermore, it provides the ability to incrementally load the templates/components, when needed. With Blaze, the templates for the whole application are loaded during startup.

Right thatā€™s why I said ā€œmeaningfulā€ way - I would be surprised if switching to Svelte was the best way to make your app faster, compared to some other possible improvement. Iā€™m sure it does great on benchmarks, thatā€™s the whole point.

BTW Blaze does just fine with loading templates incrementally, itā€™s just that Meteorā€™s build system doesnā€™t support loading any files incrementally at the moment.

Svelte is just a compiler that generates JavaScript files. How these files are bundled and delivered to the browser is entirely up to the build tool.

Soā€¦are there any benefits in swapping blaze for svelte if I use standard meteor build tool?

Probably very few unless you just like the idea of trying new things.

1 Like

++ UPDATE ++

Project organization

Thanks to @zimme, we now have a GitHub organization (https://github.com/meteor-svelte) where the build plugin, additional packages, and examples are hosted. All Svelte packages are released under the svelte organization on Atmosphere (https://atmospherejs.com/svelte).

Tracker integration

You can use the svelte:tracker package to easily pass reactive data from Minimongo, ReactiveVars, and other data sources to your Svelte components.

Using Svelte and Blaze

The svelte:compiler package compiles both .html and .svelte files. If you want to use Svelte and Blaze simultaneously, you can use svelte:compiler-no-html instead. In this case, all your components have to use the .svelte extension.

7 Likes

Is there an example app I can check out?


There you go @sashko, unless you already found them.

2 Likes

Hello and sorry for resurrection !

Svelte 3 is the new hot thing, it basically looks awesome. It looks like ViewModel so it is clean, super clean from any boilerplate.
Has anyone tried to integrate it in the Meteor stack? I see that this package has been updated 4 months ago, I see in package.json it is now compatible with svelte 3+

Can anyone tell me about their developer experience using Svelte on Meteor ?
Has anyone an open source repo that use this stack?

Hopefully so !

3 Likes

You should definitely check this. Also this thread.

Hi, I normally use meteor and blaze. Iā€™ve been working with svelte lately, the similarity between them and the compatibility with meteor are really good. Now Iā€™m thinking of using svelte in my new projects and Iā€™m working on it. You can also find what I did while working with meteor and svelte here.

3 Likes

Looks like Svelte is really gaining momentum!