New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
v4.1 #1397
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
✅ Deploy Preview for vue-router canceled.
|
Size report
|
Codecov Report
@@ Coverage Diff @@
## main #1397 +/- ##
=======================================
Coverage ? 90.74%
=======================================
Files ? 24
Lines ? 1102
Branches ? 339
=======================================
Hits ? 1000
Misses ? 63
Partials ? 39 Continue to review full report at Codecov.
|
Co-authored-by: Eduardo San Martin Morote <posva13@gmail.com>
Native symbols are already used by Vue so it makes no sense to fallback in vue router
Close #1048 Allows loading a route location to be passed to `<RouterView>`
Achieve it with a build plugin instead; https://github.com/posva/unplugin-vue-router Types were too slow due to their recursive nature and relying on tuples too much. A build-time type generation is not only reliable and fast but also enable creating other patterns.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This branch is periodically publish as
vue-router@edge
:to try it out!
Vue Router 4.1
We are excited to announce the release of Vue Router 4.1 with a few new interesting features, better support for Node ESM and no breaking changes.
Omitting the
component
/components
option in routesIt's now possible to completely omit the
component
option when defining routes with children. While nested routes are about defining layouts, they are also directly connected to apath
and users often found themselves defining a pass through component that would just render a<RouterView>
component to reuse thepath
structure. You can simplify this to:In other words, you can now nest paths without having to define a component.
Passing History State in navigations
Passing History State through
router.push()
has been implemented and used by the router since its version 4.0 but hasn't been exposed as a public API until now. This enables passing astate
property when callingrouter.push()
orrouter.replace()
. This is useful to pass global state to be associated with the history entry that cannot be shared by copying the URL. One common example of this are Modals:To see a full example, check the modal e2e test, it has been updated to use the
state
property.It's worth noting this shouldn't be used to pass fetched data or complex objects such as classes because of type of properties and size limitations. Check the History State documentation for more information about the
state
property.Give the nature of the
<RouterView>
'sroute
prop, there is also a new functionloadRouteLocation()
that can be used on a resolved route location to load a route with lazy loading:Typed Routes
In v4.1 we were initially planning to introduce types to automatically detect the params from a
path
property, creating autocomplete and type safety inrouter.push()
and<RouterLink>
'sto
prop but it turned out to be extremely slow after 50 routes due to the nature of the types relying on nesting and complex tuples. Instead we are introducing a build plugin to generate the types of the routes for you based your file structure. This is similar to Nuxt and Vite Plugin Pages but with full type support. The plugin supports Vite, Webpack, and rollup and it's currently experimental to gather feedback from the community. We hope to release a stable version of it in the following months.Check out the plugin GitHub repository for installation instructions and documentation.
Here are some other examples
CJS/MJS support for Node
We know expose a few extra entry points for Node but kept the old ones as well to prevent any disruption to the existing users. You can find more information about this in the corresponding pull request.