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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@zero-song/navigate

v1.0.3

Published

路由包

Downloads

5

Readme

@zero-song/navigate

适用于 PC 端的路由跳转封装

Quick Start

lerna create navigate

新增 navigate/src/index.ts

package.json 中添加相关依赖

{
  "devDependencies": {
    "@babel/cli": "^7.21.0",
    "@babel/core": "^7.21.4",
    "@babel/plugin-external-helpers": "^7.18.6",
    "@babel/plugin-transform-runtime": "^7.21.4",
    "@babel/polyfill": "^7.12.1",
    "@babel/preset-env": "^7.21.4",
    "@babel/runtime-corejs3": "^7.21.0",
    "@rollup/plugin-babel": "^6.0.3",
    "@rollup/plugin-commonjs": "^24.1.0",
    "@rollup/plugin-node-resolve": "^15.0.2",
    "@rollup/plugin-replace": "^5.0.2",
    "@rollup/plugin-terser": "^0.4.1",
    "@types/node": "^18.15.11",
    "core-js": "^3.29.1",
    "cross-env": "^7.0.3",
    "rollup": "^3.20.2",
    "rollup-plugin-clear": "^2.0.7",
    "rollup-plugin-sourcemaps": "^0.6.3",
    "rollup-plugin-typescript2": "^0.34.1",
    "typescript": "^5.0.3"
  },
  "dependencies": {
    "@zero-song/hooks": "^1.0.0",
    "history": "^5.3.0"
  }
}

修改 main, 添加其他配置信息

{
  "main": "lib/index.js",
  "module": "es/index.js",
  "unpkg": "dist/index.js",
  "typings": "lib/index.d.ts",
  "files": ["dist", "lib", "es"],
  "publishConfig": {
    "registry": "https://registry.npmjs.org/",
    "access": "public"
  },
  "scripts": {
    "build:dev": "cross-env NODE_ENV=development rollup -c rollup.config.js --bundleConfigAsCjs ",
    "build:prod": "cross-env NODE_ENV=production rollup -c rollup.config.js --bundleConfigAsCjs ",
    "tsc": "tsc",
    "test": "node ./__tests__/navigate.test.js"
  }
}

新增 tsconfig.json 文件

{
  "compilerOptions": {
    "allowJs": true,
    "alwaysStrict": true,
    "checkJs": true,
    "declaration": true,
    "esModuleInterop": true,
    "experimentalDecorators": true,
    "lib": ["esnext", "es2017", "dom"],
    "module": "esnext",
    "moduleResolution": "node",
    "outDir": "lib",
    "strict": true,
    "strictNullChecks": false,
    "skipLibCheck": true,
    "stripInternal": true,
    "target": "esnext"
  },
  "include": ["src"],
  "exclude": ["node_modules", "lib", "dist", "es"]
}

安装依赖 yarn 升级所有依赖包版本 yarn upgrade latest 执行:yarn tsc (执行命令前先新增tsconfig.json文件) 新增 roll.config.js 打包配置文件 执行打包命令:yarn build:prod

回到 zero-song 目录下进行发布

  1. 先提交代码
  git add ./
  git commit -m 'init utils'
  git push
  1. 登录 npm: npm login
    输入登录账号、密码、邮箱,输入邮箱收到的短码,登录成功。

  2. 登录成功后执行发布命令 lerna publish,选择模式,输入'Yes',回车后等待发布成功。

Usage

import { history, navigate } from '@zero-song/navigate'