-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
feat(nuxt): config options for default keepalive, page & layout transitions #5859
Conversation
β Deploy Preview for nuxt3-docs canceled.
|
Thanks for rebasing. Shall we type |
Beautiful work @danielroe β€οΈ Shall we document more to use |
Currently, usage of |
(fixture seems broken) |
Could we take this opportunity to also give the possibility to set those values to |
Indeed, that is one of the key use-cases of this PR. As implemented here, it is possible to set them to false and it will disable keepalive, page & layout transitions. |
return _wrapIf(Transition, routeProps.route.meta.pageTransition ?? defaultPageTransition, | ||
wrapInKeepAlive(routeProps.route.meta.keepalive, isNested && nuxtApp.isHydrating | ||
// Include route children in parent suspense | ||
return _wrapIf(Transition, routeProps.route.meta.pageTransition ?? appConfig._nuxt.pageTransition, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For this, we could have a bundler flag (like NUXT_PAGE_TRANSITION
) that replaces value to false
on build time otherwise setting app config to false
won't be able to tree-shake... (but can be later. pointing to make clear about false handling with this PR)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. This PR does not enable tree-shaking out; it just sets default behaviour. We can't tree shake this way as user may wish to enable transitions/keepalive on a per-page basis.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would love to be able to tree-shake out the Transition/Keepalive components but will it would need a different approach than this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's true. We use appConfig currently only to specify default but could be also used to specify feature flags. (swapping condition order when value is false to always disable transitions which I think would make more sense for false handling)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe support an additional option, e.g. keepalive: 'disabled'
as the user may simply wish to disable them by default but not for all routes?
Thinking more about approaches, i think for specific nuxt bundled config, using an internal template with named exports ( |
Okay - so just to confirm, we'll refactor back to original approach of this PR, but using |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
π Linked issue
resolves nuxt/nuxt#14265
β Type of change
π Description
This allows support for configuring page & layout transition default values, as well as keepalive. (Otherwise there is the tedious task of doing so for every individual file.)
In order to do this, we now inject
#build/app.config.mjs
to automatically expose all values within theapp
key in Nuxt config, rather than creating ever-more virtual files for particular use-cases. (We would, for example, have had to do this for layouts and page transitions separately otherwise.) This means we were able to dropmeta.config.mjs
and in general is a useful pattern for futureapp
configuration.π Checklist