<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: :icarus.gk</title>
    <description>The latest articles on DEV Community by :icarus.gk (@icarusgk).</description>
    <link>https://dev.to/icarusgk</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F609772%2Fdefd2ecd-3288-419d-bbce-838a06672342.png</url>
      <title>DEV Community: :icarus.gk</title>
      <link>https://dev.to/icarusgk</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/icarusgk"/>
    <language>en</language>
    <item>
      <title>All we know about Vue 3 Vapor Mode</title>
      <dc:creator>:icarus.gk</dc:creator>
      <pubDate>Thu, 28 Sep 2023 18:25:04 +0000</pubDate>
      <link>https://dev.to/icarusgk/all-we-know-about-vue-3-vapor-mode-3nfa</link>
      <guid>https://dev.to/icarusgk/all-we-know-about-vue-3-vapor-mode-3nfa</guid>
      <description>&lt;h2&gt;
  
  
  What is Vapor Mode? 🧐
&lt;/h2&gt;

&lt;p&gt;Vapor Mode is a new and alternative compilation strategy inspired by &lt;a href="https://www.solidjs.com/" rel="noopener noreferrer"&gt;Solid.js&lt;/a&gt;. It aims to enhance your apps' performance by compiling your code into a more efficient JavaScript output.&lt;/p&gt;

&lt;p&gt;When used at the app level, you can drop the Virtual DOM completely, thus reducing your app's bundle size.&lt;/p&gt;

&lt;h3&gt;
  
  
  ✅ &lt;strong&gt;Benefits&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;More performant&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Uses less memory&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Requires less runtime support code.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Solid.js has a very very similar reactivity system to Vue, they both use Proxies in their Reactive system with read-based auto-tracking. This is why Vue can implement a similar compilation strategy as Solid.js does.&lt;/p&gt;

&lt;h3&gt;
  
  
  How does Vapor Mode work? 🤔
&lt;/h3&gt;

&lt;p&gt;Given the same &lt;code&gt;.vue&lt;/code&gt; Single File Component, Vapor mode will be able to compile it to a more performant JavaScript output.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnyf8tvsvaeuv68tgip60.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnyf8tvsvaeuv68tgip60.png" alt="Vue Vapor Compilation Explanation"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To optimize the best performance, Vapor mode will only support a subset of Vue features, these being the new Composition API and &lt;code&gt;.vue&lt;/code&gt; SFC's with &lt;code&gt;&amp;lt;script setup&amp;gt;&lt;/code&gt;, Vue 3's new default way of writing apps. Read More on &lt;a href="https://blog.vuejs.org/posts/2022-year-in-review" rel="noopener noreferrer"&gt;Vue's Year in Review&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What's the current approach?
&lt;/h2&gt;

&lt;p&gt;Currently, Vue takes a hybrid VDOM/Compiler approach. The compiler takes the SFC's template, analyzes it and feeds a to the Virtual DOM.&lt;/p&gt;

&lt;p&gt;This &lt;a href="https://vuejs.org/guide/extras/rendering-mechanism.html#compiler-informed-virtual-dom" rel="noopener noreferrer"&gt;Compiler-Informed Virtual DOM&lt;/a&gt; approach allows Vue to &lt;a href="https://twitter.com/icarusgkx/status/1693620200543862852?s=20" rel="noopener noreferrer"&gt;perform better&lt;/a&gt; than V-DOM-less tools like Svelte 4 when performing DOM operations by a small margin.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8dyospuwvicwlmg5fpzm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8dyospuwvicwlmg5fpzm.png" alt="Shows how Vue outperforms Svelte and React"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How can I use Vapor Mode?
&lt;/h2&gt;

&lt;h3&gt;
  
  
  At the Component level.
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;You'll be able to enable it using the&lt;/strong&gt; &lt;code&gt;.vapor&lt;/code&gt; filename postfix.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0ip94h35s3h6sgcazmy8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0ip94h35s3h6sgcazmy8.png" alt="Showing how you can enable Vapor mode by adding .vapor before .vue"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The end goal is to freely mix Vapor and non-Vapor components in the same app.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5e1xx8rs83hit3wztgdj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5e1xx8rs83hit3wztgdj.png" alt="DOM tree with vDOM and Vapor components"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;📝 * NOTE&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Initially, Vapor Mode may begin with a vapor-only tree integrated into the vDOM, and then improve the interoperability between them from there on.&lt;/p&gt;

&lt;h3&gt;
  
  
  At the App level.
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fymn3kjll22v72iauv5hj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fymn3kjll22v72iauv5hj.png" alt="You can opt-in at the app level by marking you root App.vue with App.vapor.vue instead"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;An app compiled this way will be able to drop the Virtual DOM runtime completely and will only include &lt;a href="https://github.com/vuejs/core/tree/main/packages/reactivity" rel="noopener noreferrer"&gt;&lt;code&gt;@vue/reactivity&lt;/code&gt;&lt;/a&gt; and the vapor mode runtime helpers which are &lt;strong&gt;extremely&lt;/strong&gt; lightweight. An app written this way will have a &lt;strong&gt;baseline&lt;/strong&gt; size of ~6kb, compared to the current ~50kb of a baseline Vue 3 app with vDOM. That's an &lt;strong&gt;88%&lt;/strong&gt; reduction! 🤯&lt;/p&gt;

&lt;h3&gt;
  
  
  Key points
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;It is an optional feature that won't affect existing codebases.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you decide to upgrade your Vue version to one that includes Vapor Mode, this won't introduce any breaking changes related to Vapor Mode.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Vapor mode will be able to inter-operate with vDOM components.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;So if you want to use any library that uses Virtual DOM like Vuetify, Vapor mode will still be able to support it.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Vapor Mode Stages&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;While still in development we have some news on it:&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Stage 1: Runtime for Core Features&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;All the Vapor runtime helpers are introduced, these helpers are basically the code that helps out the generative code. This stage is pretty much done.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;❇️ Goals&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Support core directives (&lt;code&gt;v-on, v-if, v-for, etc...&lt;/code&gt;) and the component tree.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Verify performance assumptions.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Hydration compatibility with existing SSR output.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Stage 2: Compiler for Core Features&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;The main focus here is to make sure that we can take a Vue template or JSX and turn it into something the runtime can handle.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;❇️ Goals&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Shared code generation IR (Intermediate Representation)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;JSX AST / Template AST - IR - Vapor Mode code&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Why an Intermediate Representation?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The compilation process for Vapor Mode eliminates the need for manual render function creation due to the absence of a virtual DOM. However, some users require the extensive flexibility of JavaScript. In such cases, it's possible to compile JSX into Vapor code.&lt;/p&gt;

&lt;p&gt;Both templates and JSX undergo a transformation into the same &lt;strong&gt;Intermediate Representation&lt;/strong&gt;, which ultimately compiles into Vapor code.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjab1j15bnwqkf0mhk96k.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjab1j15bnwqkf0mhk96k.png" alt="Graphic demonstrating the IR"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Stage 3: Integration&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Vue aims to make Vapor seamlessly embeddable into your existing applications, without requiring any modifications to your current setup. You have the flexibility to opt-in at the component level, enabling you to gradually introduce it to a subset of your application or specifically to performance-critical areas.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;❇️ Goals&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Tooling support for standalone Vapor apps&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Running Vapor components inside existing apps&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Running vDOM components inside Vapor&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Stage 4: Feature Parity&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;In its initial release, Vapor Mode will provide only the essential core features while some of the more auxiliary features like &lt;code&gt;&amp;lt;Transition /&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;KeepAlive /&amp;gt;&lt;/code&gt; , &lt;code&gt;&amp;lt;Teleport /&amp;gt;&lt;/code&gt;, &lt;code&gt;Suspense&lt;/code&gt; will be implemented after the Vue team has sorted out all of the previous goals.&lt;/p&gt;

&lt;h2&gt;
  
  
  In Summary
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Vapor Mode is a new performance-oriented compilation strategy&lt;/strong&gt; being developed by Vue.js&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;It will use the same template&lt;/strong&gt; (assuming you're using the Composition API and &lt;code&gt;&amp;lt;script setup&amp;gt;&lt;/code&gt; and produce a more performant output.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;It will be incrementally adoptable&lt;/strong&gt; - You will be able to choose to enable Vapor Mode either for individual components or for the entire app.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;The end goal is to freely mix Vapor and non-Vapor components&lt;/strong&gt; within the same app without issues, however, Vapor Mode may begin with a vapor-only tree integrated into the vDOM, and then improve the interoperability between them from there on.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Thank you for reading this blog!&lt;/strong&gt; 😄
&lt;/h3&gt;

&lt;p&gt;If you would like to see more new Vue 3-related content, follow me here and on Twitter as.&lt;/p&gt;

&lt;h3&gt;
  
  
  Content used for this blog
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://blog.vuejs.org/posts/2022-year-in-review" rel="noopener noreferrer"&gt;&lt;strong&gt;The Vue Point - 2022 Year in Review&lt;/strong&gt;&lt;/a&gt;&lt;br&gt;&lt;br&gt;
Jan 1, 2023&lt;/p&gt;

&lt;p&gt;&lt;a href="https://youtu.be/OrT0tHGXyqE&amp;amp;t=1250" rel="noopener noreferrer"&gt;&lt;strong&gt;Vue: What to Expect in 2023 by Evan You&lt;/strong&gt;&lt;/a&gt; - Vue.js Nation 2023&lt;br&gt;&lt;br&gt;
Feb 1, 2023&lt;/p&gt;

&lt;p&gt;&lt;a href="https://youtu.be/I5mGNB-4f0o&amp;amp;t=1219" rel="noopener noreferrer"&gt;&lt;strong&gt;State of Vuenion 2023&lt;/strong&gt;&lt;/a&gt; - Vuejs Amsterdam 2023&lt;br&gt;&lt;br&gt;
Mar 1, 2023&lt;/p&gt;

&lt;p&gt;&lt;a href="https://youtu.be/BqHzQcFwk0I&amp;amp;t=899" rel="noopener noreferrer"&gt;&lt;strong&gt;Vue Mastermind Evan You answers Vue devs' questions&lt;/strong&gt;&lt;/a&gt; - &lt;a href="https://vuemastery.com/" rel="noopener noreferrer"&gt;Vue Mastery&lt;/a&gt;&lt;br&gt;&lt;br&gt;
Jun 22, 2023&lt;/p&gt;

&lt;p&gt;&lt;a href="https://youtu.be/y-hN5Q_lb9A&amp;amp;t=1328" rel="noopener noreferrer"&gt;&lt;strong&gt;State of Vuenion 2023&lt;/strong&gt;&lt;/a&gt; VueConf US 2023&lt;br&gt;&lt;br&gt;
Jul 11, 2023&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>vue</category>
      <category>react</category>
    </item>
  </channel>
</rss>
