Skip to content

Commit

Permalink
perf: avoid deps on npm-registry-fetch, save install size
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Jul 2, 2024
1 parent 541c929 commit 3d74691
Show file tree
Hide file tree
Showing 9 changed files with 1,448 additions and 1,409 deletions.
4 changes: 2 additions & 2 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
},
"dependencies": {
"@iconify-json/ph": "^1.1.13",
"@iconify-json/simple-icons": "^1.1.107",
"@iconify-json/simple-icons": "^1.1.108",
"@nuxt/content": "^2.13.0",
"@nuxt/devtools": "1.3.1",
"@nuxt/fonts": "^0.7.1",
"@nuxt/image": "1.7.0",
"@nuxt/ui-pro": "^1.3.1",
"@nuxthq/studio": "^2.0.2",
"@nuxthq/studio": "^2.0.3",
"@nuxtjs/plausible": "^1.0.0",
"@vueuse/core": "^10.11.0",
"@vueuse/nuxt": "^10.11.0",
Expand Down
20 changes: 10 additions & 10 deletions docs/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"prepare": "pnpm -r --filter=\"./packages/*\" run dev:prepare"
},
"devDependencies": {
"@antfu/eslint-config": "^2.21.1",
"@antfu/eslint-config": "^2.21.2",
"@antfu/ni": "^0.21.12",
"@nuxt/devtools": "workspace:*",
"@nuxt/devtools-ui-kit": "workspace:*",
Expand All @@ -36,22 +36,22 @@
"@unocss/eslint-config": "^0.61.0",
"bumpp": "^9.4.1",
"conventional-changelog-cli": "^5.0.0",
"eslint": "^9.5.0",
"eslint": "^9.6.0",
"eslint-plugin-format": "^0.1.2",
"esno": "^4.7.0",
"execa": "^7.2.0",
"lint-staged": "^15.2.7",
"nuxt": "^3.12.2",
"pathe": "^1.1.2",
"simple-git-hooks": "^2.11.1",
"taze": "^0.13.9",
"taze": "^0.14.0",
"tiged": "^2.12.7",
"typescript": "^5.5.2",
"typescript": "^5.5.3",
"ua-parser-js": "^1.0.38",
"unocss": "^0.61.0",
"vite-hot-client": "^0.2.3",
"vue": "^3.4.30",
"vue-tsc": "^2.0.22"
"vue": "^3.4.31",
"vue-tsc": "^2.0.24"
},
"simple-git-hooks": {
"pre-commit": "npx lint-staged"
Expand Down
2 changes: 1 addition & 1 deletion packages/devtools-wizard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"global-directory": "^4.0.1",
"magicast": "^0.3.4",
"pathe": "^1.1.2",
"pkg-types": "^1.1.1",
"pkg-types": "^1.1.2",
"prompts": "^2.4.2",
"rc9": "^2.1.2",
"semver": "^7.6.2"
Expand Down
15 changes: 7 additions & 8 deletions packages/devtools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"error-stack-parser-es": "^0.1.4",
"execa": "^7.2.0",
"fast-glob": "^3.3.2",
"fast-npm-meta": "^0.1.1",
"flatted": "^3.3.1",
"get-port-please": "^3.1.2",
"hookable": "^5.5.3",
Expand All @@ -63,12 +64,11 @@
"launch-editor": "^2.8.0",
"local-pkg": "^0.5.0",
"magicast": "^0.3.4",
"npm-registry-fetch": "^17.1.0",
"nypm": "^0.3.8",
"nypm": "^0.3.9",
"ohash": "^1.1.3",
"pathe": "^1.1.2",
"perfect-debounce": "^1.0.0",
"pkg-types": "^1.1.1",
"pkg-types": "^1.1.2",
"rc9": "^2.1.2",
"scule": "^1.3.0",
"semver": "^7.6.2",
Expand All @@ -85,14 +85,13 @@
"@iconify-json/carbon": "^1.1.36",
"@iconify-json/logos": "^1.1.43",
"@iconify-json/ri": "^1.1.21",
"@iconify-json/simple-icons": "^1.1.107",
"@iconify-json/simple-icons": "^1.1.108",
"@iconify-json/tabler": "^1.1.115",
"@nuxt/content": "^2.13.0",
"@nuxt/devtools": "workspace:*",
"@nuxt/test-utils": "3.9.0",
"@parcel/watcher": "^2.4.1",
"@types/markdown-it-link-attributes": "^3.0.5",
"@types/npm-registry-fetch": "^8.0.7",
"@types/ua-parser-js": "^0.7.39",
"@unocss/nuxt": "^0.61.0",
"@unocss/preset-icons": "^0.61.0",
Expand All @@ -108,19 +107,19 @@
"markdown-it": "^14.1.0",
"markdown-it-link-attributes": "^4.0.1",
"nanoid": "^5.0.7",
"nitropack": "^2.9.6",
"nitropack": "^2.9.7",
"nuxt": "^3.12.2",
"ofetch": "^1.3.4",
"quicktype-core": "^23.0.170",
"shiki": "^1.9.1",
"shiki": "^1.10.0",
"theme-vitesse": "^0.8.0",
"ua-parser-js": "^1.0.38",
"unocss": "^0.61.0",
"unplugin-vue-markdown": "^0.26.2",
"vanilla-jsoneditor": "^0.23.7",
"vis-data": "^7.1.9",
"vis-network": "^9.1.9",
"vue-tsc": "^2.0.22",
"vue-tsc": "^2.0.24",
"vue-virtual-scroller": "2.0.0-beta.8",
"xterm": "^5.3.0",
"xterm-addon-fit": "^0.8.0"
Expand Down
15 changes: 3 additions & 12 deletions packages/devtools/src/npm/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { createRequire } from 'node:module'
import { logger, useNuxt } from '@nuxt/kit'
import { readPackageJSON } from 'pkg-types'
import semver from 'semver'
import { joinURL } from 'ufo'
import { getPackageInfo } from 'local-pkg'
import type { PackageUpdateInfo } from '../types'

Expand Down Expand Up @@ -45,23 +44,15 @@ export async function checkForUpdateOf(name: string, current?: string, nuxt = us
if (!current)
return

const { pickRegistry, json: fetchMeta } = await import('npm-registry-fetch')
const reg = pickRegistry(name)
const manifest = await fetchMeta(joinURL(reg, name), {
headers: {
'user-agent': `npm node/${process.version}`,
'accept': 'application/json',
},
spec: name,
}) as unknown as Packument
const { getLatestVersion } = await import('fast-npm-meta')
const { version: latest } = await getLatestVersion(name)

const latest = manifest?.['dist-tags']?.latest
const needsUpdate = !!latest && latest !== current && semver.lt(current, latest)

return {
name,
current,
latest,
latest: latest || current,
needsUpdate,
}
}
Expand Down
2 changes: 1 addition & 1 deletion playgrounds/module-starter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"@nuxt/module-builder": "~0.6.0",
"@nuxt/schema": "^3.12.2",
"@nuxt/test-utils": "^3.13.1",
"eslint": "^9.5.0",
"eslint": "^9.6.0",
"nuxt": "^3.12.2",
"vitest": "^1.6.0"
}
Expand Down
2 changes: 1 addition & 1 deletion playgrounds/tab-pinia/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
},
"devDependencies": {
"@exampledev/new.css": "^1.1.3",
"cypress": "^13.12.0",
"cypress": "^13.13.0",
"nuxt": "^3.12.2"
}
}
Loading

0 comments on commit 3d74691

Please sign in to comment.