Skip to content
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

Refactor defineLoader #246

Merged
merged 203 commits into from
Feb 21, 2024
Merged

Refactor defineLoader #246

merged 203 commits into from
Feb 21, 2024

Conversation

@posva posva force-pushed the refactor/create-define-loader branch from 9f2252b to d681268 Compare November 28, 2023 10:54
BREAKING CHANGE: since data loaders aren't meant to be awaited in script
setup (they are awaited at the navigation level), they now return a
promise of the raw data only, not of the UseDataLoaderReturn, to make it
clearer that this syntax is a bit special and should only be used within
nested loaders. This change also brings other benefits like allowing
lazy loaders to be awaited within loaders without changing their usage
outside, in components. Also, allowing different types of commit while
still allowing data to be awaited within loaders.
BREAKING CHANGE: While this was a private API, we are documenting it
here just in case. Replace `_defineBasicLoader` with `defineBasicLoader`
BREAKING CHANGE: The navigation guard is replaced in favor of a Vue
plugin:

Replace
```ts
import { setupLoaderGuard } from 'vue-router/auto'

setupLoaderGuard({ router, app })
```

with

```ts
import { DataLoaderPlugin } from 'vue-router/auto'

app.use(DataLoaderPlugin, { router })
```
@posva
Copy link
Owner Author

posva commented Feb 15, 2024

@SocketSecurity ignore npm/[email protected]

BREAKING CHANGE: Data Loaders have been redesigned to be more flexible
and account for other libraries. Notably, the caching behavior has been
moved out of the basic loader to an extended one and the basic loader
has no cache. All of the pending bugs have also been fixed.
I recommend you to give the RFC examples a new read to get
setup: https://uvr.esm.is/rfcs/data-loaders/. Most of the changes are
simplifying things by removing them.
Here is a list of the breaking changes to simplify
migration:

- The `dataFetching` option is no longer needed.
- Manual work needed to add loaders with `HasDataLoaderMeta` has been
  removed. It is just no longer needed. Loaders are picked up from lazy
  loaded components and must otherwise be directly added to a `meta.loaders`
  array. See the example at https://uvr.esm.is/rfcs/data-loaders/#basic-example
- The function `setupDataFetchingGuard` has been replaced with a Vue
  Plugin. See https://uvr.esm.is/rfcs/data-loaders/#data-loader-setup
  for details.
- If you were relying on `cacheTime`, use the `staleTime` option in the
  new [`defineColadaLoader()`](https://uvr.esm.is/rfcs/data-loaders/colada) based off [@pinia/colada](https://github.com/posva/pinia-colada)
- To reduce the dependency on file-based router, things have been
  refactored and none of the defineLoader functions are automatically
  imported anymore. You can add them yourself to the list of auto
  imports, or import them from `vue-router/auto`. The good news is you
  no longer need to use the plugin in order to benefit from the data
  loaders; they can be directly imported from
  `unplugin-vue-router/runtime`.

If you find missing information or improvements, please open a Pull
Request to improve the `CHANGELOG.md`.
Copy link

socket-security bot commented Feb 21, 2024

New and removed dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/@babel/[email protected] environment +2 2.49 MB nicolo-ribaudo
npm/@pinia/[email protected] None 0 156 kB posva
npm/@rollup/[email protected] None +3 223 kB shellscape
npm/@shikijs/[email protected] environment +55 3.31 MB antfu
npm/@tanstack/[email protected] environment +3 2.86 MB tannerlinsley
npm/@types/[email protected] None 0 4 MB types
npm/@vitest/[email protected] Transitive: environment, filesystem +22 6.68 MB antfu, oreanno, patak, ...1 more
npm/@vitest/[email protected] Transitive: environment, filesystem +23 2.44 MB vitestbot
npm/@vue-macros/[email protected] filesystem Transitive: environment, eval, unsafe +27 10.5 MB sxzz
npm/@vue/[email protected] environment, eval, filesystem, unsafe +15 9.17 MB yyx990803
npm/@vue/[email protected] eval Transitive: environment, filesystem, network, shell +22 5.81 MB lmiller1990
npm/@vue/[email protected] None 0 10.6 kB soda
npm/[email protected] environment, filesystem +10 305 kB paulmillr
npm/[email protected] filesystem +12 450 kB mrmlnc
npm/[email protected] Transitive: environment, filesystem, network +60 116 MB google-wombot
npm/[email protected] network, shell, unsafe +1 8.8 MB davidortner
npm/[email protected] environment, filesystem Transitive: eval, network, unsafe +67 3.53 MB typicode
npm/[email protected] Transitive: environment, filesystem, shell +28 1.24 MB okonet
npm/[email protected] environment, network 0 54.5 kB posva
npm/[email protected] None +4 976 kB pi0
npm/[email protected] environment, filesystem, shell +19 645 kB remy
npm/[email protected] Transitive: environment, eval, filesystem, network, shell, unsafe +392 59.1 MB danielroe
npm/[email protected] None 0 30.8 kB pi0
npm/[email protected] environment +1 413 kB posva
npm/[email protected] environment, filesystem, unsafe 0 11.2 MB prettier-bot

🚮 Removed packages: npm/@babel/[email protected], npm/@babel/[email protected], npm/@vitest/[email protected], npm/@vue/[email protected], npm/@vue/[email protected], npm/@vue/[email protected], npm/@vue/[email protected], npm/@vue/[email protected], npm/@vue/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected]

View full report↗︎

BREAKING CHANGE: Remove the deprecated APIs:
- `createPrefixTree()` -> `new PrefixTree()`
- `VueRouterExports` -> `VueRouterAutoImports`
@posva posva merged commit 15aa3d1 into main Feb 21, 2024
10 checks passed
@posva posva deleted the refactor/create-define-loader branch February 21, 2024 15:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment