We are excited to announce the release of Vue 2.5 Level E! This release includes improvements of various features and we recommend checking out the release note for full details. In this post we are going to highlight some of the more prominent changes: better TypeScript integration, better error handling, better support for functional components in single-file components, and environment-agnostic server-side rendering.
Better TypeScript Integration
Note: TypeScript users should also update the following packages to the latest version for type declaration compatibility:
Better Error Handling
In 2.4 and earlier versions, we typical use the global
config.errorHandler option for handling unexpected errors in our applications. We also have the
renderError component option for handling errors in render functions. However, we lack a mechanism for handling generic errors inside a specific part of the application.
In 2.5 we have introduced the new
errorCaptured hook. A component with this hook captures all errors (excluding those fired in async callbacks) from its child component tree (excluding itself). If you are familiar with React, this is similar to the concept of Error Boundaries introduced in React 16. The hook receives the same arguments as the global `errorHandler`, and you can leverage this hook to gracefully handle and display the error.
Better Support for Functional Components in
vue-loader >= 13.3.0 and Vue 2.5, functional components defined as a Single-File Component in a
*.vue file now enjoys proper template compilation, Scoped CSS and hot-reloading support. This makes it much easier to convert leaf-components into functional ones for performance optimizations.
Shoutout to core team member Blake Newman for his contribution to these features.
Environment Agnostic SSR