npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

vue-router-inspector-panel

v0.1.0

Published

A development-only Vue 3 panel for inspecting vue-router routes and searching Vue component files.

Readme

vue-router-inspector-panel

Vue 3 + vue-router 4 的本地路由检查面板。它从完整的 Router 实例读取当前全部路由,因此通过 router.addRoute() 注入的接口异步路由也会包含在结果中。

同时提供一个 Vite 插件,用于扫描消费项目中的 .vue 文件,支持按文件名或目录搜索。

安装

npm install -D vue-router-inspector-panel

配置 Vite

// vite.config.ts
import vue from "@vitejs/plugin-vue";
import { defineConfig } from "vite";
import { vueRouterInspectorVitePlugin } from "vue-router-inspector-panel/vite";

export default defineConfig({
  plugins: [vue(), vueRouterInspectorVitePlugin()]
});

Vite 插件仅在开发服务器中运行,默认扫描 <projectRoot>/src/**/*.vue。可以指定多个目录:

vueRouterInspectorVitePlugin({ directories: ["src", "modules"] });

安装运行时插件

应在异步路由已经注入、router 包含完整路由后安装:

import "vue-router-inspector-panel/style.css";

await initAsyncRoutes(router);

if (import.meta.env.DEV) {
  const { VueRouterInspectorPlugin } =
    await import("vue-router-inspector-panel");
  app.use(VueRouterInspectorPlugin, { router });
}

安装后页面右下角会出现“路由”入口。

不使用 Vite 扫描插件

也可以由消费项目直接提供 Vue 文件路径:

const vueFiles = Object.keys(import.meta.glob("/src/**/*.vue"));

app.use(VueRouterInspectorPlugin, {
  router,
  vueFiles
});

组件路径解析

默认按以下顺序解析路由组件路径:

  1. 已加载 Vue 组件的 __file
  2. 懒加载组件函数中的 .vue.tsx import 路径。
  3. 无法解析时显示

特殊路由加载器可以提供自定义解析函数:

app.use(VueRouterInspectorPlugin, {
  router,
  componentPathResolver(route, component) {
    return route.meta.componentPath as string | undefined;
  }
});

默认使用 route.meta.backstage 标记动态路由。其他项目可以通过 dynamicRouteMetaKey 修改:

app.use(VueRouterInspectorPlugin, {
  router,
  dynamicRouteMetaKey: "dynamic"
});

路由与 Vue 文件关联

检查器会使用规范化后的完整组件路径进行精确匹配,避免不同目录下的同名 index.vue 被错误关联:

  • 路由列表显示对应 Vue 文件的“已匹配”“未扫描”或“无组件”状态。
  • Vue 文件列表显示引用该文件的全部路由,同一组件可对应多个路由。
  • Vue 文件搜索支持输入文件路径、路由路径、路由名称或标题进行反向查询。

手动挂载

import {
  mountRouterInspector,
  type RouterInspectorController
} from "vue-router-inspector-panel";

const controller: RouterInspectorController = mountRouterInspector({ router });
controller.unmount();

构建与发布检查

npm run typecheck
npm run build
npm test
npm run pack:check