关于Vue3的最新进展

1,632 阅读5分钟

从去年到现在,距离Vue3发布RFC的时间已经有八个月了,距离Vue3 beta版的发布也已经过了两个多月了。很多小伙伴可能已经开始疑问,到底Vue3什么时候发布release版本,在七月的第一天,尤大给出了回答。以下是部分原文:

Many of our users have been asking this question: when will Vue 3 be ready? We have refrained from giving a definitive answer because predicting software delivery time is hardly ever accurate. As a non-profit-driven project, we wanted to focus on writing good software instead of hitting deadlines. However, it's been a long wait, and we know the uncertainty can make it difficult to make plans with Vue 3. So here we would like to provide some general guidance and detailed status updates to help our users adjust their expectations and plans accordingly.

尤大表示,他们团队不太容易给出用户很明确的Vue3 'ready' 的时间,因为预测软件的交付时间一般都是不准确的,Vue 作为一个非盈利的项目,他们团队希望专注在写出更好的框架给用户,而不是一味的去追赶 deadline。作为一个Vue的粉丝,很欣慰尤大团队在Vue3所作出的努力,表示支持他们。尤大也还说到,可能还需要一段漫长的等待时间,不确定性使得Vue3难以制定计划。但是,他们很愿意提供一些一般的指导和详细的状态更新,以帮助Vue的用户调整他们的期望和相应的计划。

The majority of the time spent on Vue 3 has been invested into designing and building a solid core, which brings about many exciting improvments (you can read more about it here). However, in order to mark the whole framework "ready", it's not just about the core. We also need to have compatible versions of the supporting libraries (Vue Router, Vuex, test utils), tools (CLI, eslint plugin, browser devtool extensions, IDE extensions), and documentation (both for new users and migration). While we have been working hard on all of these parts, it is very difficult to accurately predict a timeline given the amount of effort and coordination it takes to have all the pieces fit together. We originally hoped to have Vue 3 released in the first half of 2020, but we have to adjust it given the current progress. Our current target dates are mid July for the RC (release candidate) and early August for the official release of 3.0.

接着尤大说明了Vue3主要的时间都花在核心的设计上,为Vue3设计了更加坚固的“内核”,所以Vue3会带来很多令人兴奋的提升。但是除了Vue3的核心之外,要让Vue3完全可用,团队还要兼容Vue的整个生态:Vue Router, Vuex, 测试套件,工具(CLI, eslint 插件, 浏览器插件devtools,IDE插件等),文档(包括给新用户的文档和迁移文档),虽然他们一直在为这些方面努力,但考虑到将所有生态中的框架组合在一起所需要付出的努力和调整,要准确地预测时间是非常困难的。本来之前团队希望在年中的时候就发布Vue3 release版本,但是现在做出一些进度的调整,他们的目标日期是7月中旬发布RC(候选版本)和8月初发布3.0正式版本

接着尤大说明了一些提前使用Vue3的疑虑,他表示现在用户也可以尝试使用Vue3,Vue3生态的多数框架都处于beta或alpha状态,并且框架核心本身已经由早期使用者进行了广泛的测试,而阻止他们进入RC的唯一原因是浏览器devtools扩展(还在开发中)。尤大还用代码写了一棵有趣的决策树,指导用户使用Vue3相应的计划:

IWantVue3()

async function IWantVue3() {
  await read('https://github.com/vuejs/rfcs/tree/master/active-rfcs')

  if (isTrue("I just want to play with Vue 3"))) {
    // If you just want to try Vue 3 out - you can do it right now with Vite.
    // Vite (https://github.com/vitejs/vite) is a new dev/build tool that we
    // created that is lighter, faster and produces smaller bundles. It works
    // with Vue 3 out of the box.
    run(`npm init vite-app hello-vue3`)
    return
  }

  if (isTrue("I am planning to use Vue 3 for a new project")) {
    if (isTrue("I need IE11 support")) {
      await IE11CompatBuild() // July 2020
    }
    if (isTrue("RFCs are too dense, I need an easy-to-read guide")) {
      await migrationGuide() // July 2020
    }
    if (isTrue("I'd rather wait until it's really ready") {
      await finalRelease() // Targeting early August 2020
    })
    run(`npm init vite-app hello-vue3`)
    return
  }

  if (isTrue("I am planning to upgrade an existing Vue 2 project")) {
    await IE11CompatBuild()
    await migrationGuide()
    await ecosystem(
      // this is the tricky part: if you have an existing, non-trivial Vue 2
      // app, you likely are using some dependencies that are not yet
      // Vue-3-compatible, for example meta frameworks like Nuxt, or UI
      // component libraries like Vuetify. If that's the case, our suggestion
      // is don't be in a hurry to upgrade. It *will* take some time for the
      // ecosystem to catch up.
      // Also note that you can start using Vue Composition API in Vue 2 today
      // via https://github.com/vuejs/composition-api - we are also going to be
      // backporting compatible Vue 3 features to 2.x once 3.0 is out.
    )
    return
  }

  if (isTrue("I am the author of a Vue ecosystem library")) {
    // It's time to make your lib Vue 3 compatible!
    return
  }
}

最后尤大给出了Vue3主要框架的进度。

Vue3 Core

Vue 3 core已经发布beta版并测试两个多月了,团队已经合并了所有对计划有破坏的变更 rfc,在正式3.0发布之前没有进一步破坏变更的计划。在这个阶段,他们相信Vue 3核心是相当稳定的,为RC阶段准备好了。

VueRouter

在vue-router@3中,团队仍然有一些次要的路由钩子行为一致性问题还在讨论,但这些是唯一阻止路由被标记为Beta的问题。目前路由已经可用于新的、非关键的项目。

Vuex

Vuex 4.0和3.0之间唯一的区别,它是为了兼容Vue3,它已经准备好与Vue 3核心部分一起进入RC阶段。

Vue CLI

Vue CLI中的Vue 3支持目前是通过 vue-cli-plugin-vue-next 插件提供的。您可以构建一个新项目,然后运行vue add vue-next,切换到vue 3。当Vue 3达到RC时,它将成为项目创建过程中的一个选项。

尤大也为自己最近写的工具 Vite 打了一波广告,表示如果你不是特别喜欢webpack和需要支持IE11,你也可以用Vite启动一个Vue 3项目。

其它的项目

Project Status
vue-devtools WIP (beta channel with Vue 3 support in early July)
eslint-plugin-vue alpha [Github]
@vue/test-utils alpha [Github]
Babel jsx transform alpha [Github]
vue-class-component alpha [Github]
vue-loader alpha [Github]
rollup-plugin-vue alpha [Github]