unplugin-vue-router
Advanced tools
Comparing version 0.0.6 to 0.0.7
@@ -7,5 +7,18 @@ declare module '@vue-router/routes' { | ||
declare module '@vue-router' { | ||
import type { RouterOptions, Router } from 'vue-router' | ||
import type { RouterOptions, Router, RouteRecordRaw } from 'vue-router' | ||
export * from 'vue-router' | ||
export function createRouter(options: Omit<RouterOptions, 'routes'>): Router | ||
/** | ||
* unplugin-vue-router version of `RouterOptions`. | ||
*/ | ||
export interface _RouterOptions extends Omit<RouterOptions, 'routes'> { | ||
/** | ||
* Allows modifying the routes before they are passed to the router. You can modify the existing array or return a | ||
* new one. | ||
* | ||
* @param routes - The routes generated by this plugin and exposed by `@vue-router/routes` | ||
*/ | ||
extendRoutes?: (routes: RouteRecordRaw[]) => RouteRecordRaw[] | void | ||
} | ||
export function createRouter(options: _RouterOptions): Router | ||
} |
import * as unplugin from 'unplugin'; | ||
import { T as TreeLeaf, O as Options } from './options-43eb89e9.js'; | ||
import { T as TreeLeaf, O as Options } from './options-b9339c41.js'; | ||
import { RouteParamsRaw, RouteParams, RouteMeta, RouteLocationNormalized, RouteRecordName, RouteLocationNormalizedLoaded, RouteQueryAndHash, RouteLocationOptions, RouteLocation, NavigationGuardNext, NavigationFailure, Router, RouterLinkProps as RouterLinkProps$1 } from 'vue-router'; | ||
@@ -4,0 +4,0 @@ import { Ref, AllowedComponentProps, ComponentCustomProps, VNodeProps, VNode } from 'vue'; |
@@ -1,1 +0,1 @@ | ||
export { D as DEFAULT_OPTIONS, O as Options } from './options-43eb89e9.js'; | ||
export { D as DEFAULT_OPTIONS, O as Options } from './options-b9339c41.js'; |
@@ -45,2 +45,3 @@ var __defProp = Object.defineProperty; | ||
dts: (0, import_local_pkg.isPackageExists)("typescript"), | ||
logs: false, | ||
_inspect: false | ||
@@ -47,0 +48,0 @@ }; |
import * as unplugin from 'unplugin'; | ||
import { O as Options } from './options-43eb89e9.js'; | ||
import { O as Options } from './options-b9339c41.js'; | ||
@@ -4,0 +4,0 @@ declare const _default: (options?: Options | undefined) => unplugin.RollupPlugin; |
import * as unplugin from 'unplugin'; | ||
import { O as Options } from './options-43eb89e9.js'; | ||
import { O as Options } from './options-b9339c41.js'; | ||
@@ -4,0 +4,0 @@ declare const _default: (options?: Options | undefined) => unplugin.VitePlugin; |
import * as webpack from 'webpack'; | ||
import { O as Options } from './options-43eb89e9.js'; | ||
import { O as Options } from './options-b9339c41.js'; | ||
@@ -4,0 +4,0 @@ declare const _default: (options?: Options | undefined) => webpack.WebpackPluginInstance; |
{ | ||
"name": "unplugin-vue-router", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"packageManager": "pnpm@7.1.7", | ||
"description": "Register global imports on demand for Vite and Webpack", | ||
"description": "File based typed routing for Vue Router", | ||
"keywords": [ | ||
"vue-router", | ||
"pages", | ||
"filesystem", | ||
"types", | ||
"typed", | ||
"router", | ||
"unplugin", | ||
"vite", | ||
"webpack", | ||
"rollup", | ||
"transform" | ||
"rollup" | ||
], | ||
"homepage": "https://github.com/antfu/unplugin-vue-router#readme", | ||
"homepage": "https://github.com/posva/unplugin-vue-router#readme", | ||
"bugs": { | ||
"url": "https://github.com/antfu/unplugin-vue-router/issues" | ||
"url": "https://github.com/posva/unplugin-vue-router/issues" | ||
}, | ||
@@ -20,3 +25,3 @@ "license": "MIT", | ||
"type": "git", | ||
"url": "git+https://github.com/antfu/unplugin-vue-router.git" | ||
"url": "git+https://github.com/posva/unplugin-vue-router.git" | ||
}, | ||
@@ -53,4 +58,17 @@ "main": "dist/index.js", | ||
], | ||
"gitHooks": { | ||
"pre-commit": "lint-staged", | ||
"commit-msg": "node scripts/verifyCommit.mjs" | ||
}, | ||
"lint-staged": { | ||
"*.js": [ | ||
"prettier --write" | ||
], | ||
"*.ts?(x)": [ | ||
"prettier --parser=typescript --write" | ||
] | ||
}, | ||
"dependencies": { | ||
"chokidar": "^3.5.3", | ||
"fast-glob": "^3.2.11", | ||
"local-pkg": "^0.4.1", | ||
@@ -69,17 +87,25 @@ "scule": "^0.2.1", | ||
"devDependencies": { | ||
"bumpp": "^8.1.0", | ||
"chalk": "^5.0.1", | ||
"conventional-changelog-cli": "^2.2.2", | ||
"enquirer": "^2.3.6", | ||
"esno": "^0.16.3", | ||
"fast-glob": "^3.2.11", | ||
"nodemon": "^2.0.16", | ||
"execa": "^6.1.0", | ||
"lint-staged": "^13.0.3", | ||
"minimist": "^1.2.6", | ||
"nodemon": "^2.0.18", | ||
"p-series": "^3.0.0", | ||
"pathe": "^0.3.1", | ||
"prettier": "^2.7.1", | ||
"rimraf": "^3.0.2", | ||
"rollup": "^2.74.0", | ||
"rollup": "^2.75.7", | ||
"semver": "^7.3.7", | ||
"ts-expect": "^1.3.0", | ||
"tsup": "^6.1.2", | ||
"typescript": "^4.6.4", | ||
"vite": "^2.9.9", | ||
"vitest": "^0.15.1", | ||
"typescript": "^4.7.4", | ||
"vite": "^2.9.13", | ||
"vitest": "^0.15.2", | ||
"vue": "^3.2.37", | ||
"vue-router": "^4.0.16", | ||
"webpack": "^5.72.1" | ||
"webpack": "^5.72.1", | ||
"yorkie": "^2.0.0" | ||
}, | ||
@@ -92,3 +118,4 @@ "scripts": { | ||
"play": "npm -C playground run dev", | ||
"release": "bumpp --commit --push --tag && pnpm publish", | ||
"release": "node scripts/release.mjs", | ||
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 1", | ||
"start": "esno src/index.ts", | ||
@@ -95,0 +122,0 @@ "test": "vitest" |
@@ -126,3 +126,3 @@ # unplugin-vue-router | ||
By default, this plugins checks the folder at `src/routes` for any `.vue` files and generates the corresponding routing structure basing itself in the file name. This way, you no longer need to maintain a `routes` array when adding routes to your application, **instead just add the new `.vue` component to the routes folder and let this plugin do the rest!**. | ||
By default, this plugins checks the folder at `src/routes` for any `.vue` files and generates the corresponding routing structure basing itself in the file name. This way, you no longer need to maintain a `routes` array when adding routes to your application, **instead just add the new `.vue` component to the routes folder and let this plugin do the rest!** | ||
@@ -288,2 +288,25 @@ Let's take a look at a simple example: | ||
## Extending existing routes | ||
You can extend existing routes by passing an `extendRoutes` function to `createRouter()`. **This should be uses as a last resort** (or until a feature is natively available here): | ||
```js | ||
import { createWebHistory, createRouter } from '@vue-router' | ||
const router = createRouter({ | ||
extendRoutes: (routes) => { | ||
const adminRoute = routes.find((r) => r.name === '/admin') | ||
if (!adminRoute) { | ||
adminRoute.meta ??= {} | ||
adminRoute.meta.requiresAuth = true | ||
} | ||
// completely optional since we are modifying the routes in place | ||
return routes | ||
}, | ||
history: createWebHistory(), | ||
}) | ||
``` | ||
As this plugin evolves, this function should be used less and less and only become necessary in unique edge cases. | ||
## Rationale | ||
@@ -290,0 +313,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
29
321
5
145467
6
23
3800
1
+ Addedfast-glob@^3.2.11
+ Added@nodelib/fs.scandir@2.1.5(transitive)
+ Added@nodelib/fs.stat@2.0.5(transitive)
+ Added@nodelib/fs.walk@1.2.8(transitive)
+ Addedfast-glob@3.3.2(transitive)
+ Addedfastq@1.17.1(transitive)
+ Addedmerge2@1.4.1(transitive)
+ Addedmicromatch@4.0.8(transitive)
+ Addedqueue-microtask@1.2.3(transitive)
+ Addedreusify@1.0.4(transitive)
+ Addedrun-parallel@1.2.0(transitive)