diff --git a/playground/src/main.ts b/playground/src/main.ts index cf5803ae7..3bad7bf5f 100644 --- a/playground/src/main.ts +++ b/playground/src/main.ts @@ -1,6 +1,10 @@ import { createApp } from 'vue' import App from './App.vue' -import { createWebHistory, createRouter } from 'vue-router/auto' +import { + createWebHistory, + createRouter, + setupDataFetchingGuard, +} from 'vue-router/auto' const router = createRouter({ history: createWebHistory(), @@ -10,6 +14,8 @@ const router = createRouter({ }, }) +setupDataFetchingGuard(router) + const app = createApp(App) app.use(router) diff --git a/src/codegen/vueRouterModule.ts b/src/codegen/vueRouterModule.ts index ff7c5a43c..02be688fb 100644 --- a/src/codegen/vueRouterModule.ts +++ b/src/codegen/vueRouterModule.ts @@ -5,16 +5,11 @@ import type { ResolvedOptions } from '../options' // cannot be resolved. export function generateVueRouterProxy( routesModule: string, - { dataFetching }: ResolvedOptions + options: ResolvedOptions ) { return ` import { routes } from '${routesModule}' import { createRouter as _createRouter } from 'vue-router' -${ - dataFetching - ? `import { _setupDataFetchingGuard } from 'unplugin-vue-router/runtime'` - : `` -} export * from 'vue-router' export { @@ -32,13 +27,7 @@ export function createRouter(options) { options, { routes: typeof extendRoutes === 'function' ? extendRoutes(routes) : routes }, )) -${ - dataFetching - ? ` - _setupDataFetchingGuard(router) -` - : `` -} + return router } ` diff --git a/src/data-fetching/README.md b/src/data-fetching/README.md index 0d94a381a..4d95b050a 100644 --- a/src/data-fetching/README.md +++ b/src/data-fetching/README.md @@ -2,8 +2,10 @@ ⚠️ Warning: This is an experimental feature and API could change anytime +- [RFC discussion](https://github.com/vuejs/rfcs/discussions/460): Note that not everything is implemented yet. + ## Installation -Install the unplugin-vue-router library as described in its [main Readme](../../README.md) +Install the unplugin-vue-router library as described in its [main `README.md`](../../README.MD) ## Usage