refactor: use p-debounce everywhere (#977)

This commit is contained in:
Daniel Roe 2021-10-13 20:04:12 +01:00 committed by GitHub
parent 74829784c1
commit 1fbfdefe70
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 5 additions and 43 deletions

View File

@ -34,7 +34,6 @@
"chokidar": "^3.5.2", "chokidar": "^3.5.2",
"connect": "^3.7.0", "connect": "^3.7.0",
"consola": "^2.15.3", "consola": "^2.15.3",
"debounce": "^1.2.1",
"defu": "^5.0.0", "defu": "^5.0.0",
"destr": "^1.1.0", "destr": "^1.1.0",
"dot-prop": "^6.0.1", "dot-prop": "^6.0.1",
@ -73,7 +72,6 @@
"vue-server-renderer": "^2.6.14" "vue-server-renderer": "^2.6.14"
}, },
"devDependencies": { "devDependencies": {
"@types/debounce": "^1.2.1",
"@types/fs-extra": "^9.0.13", "@types/fs-extra": "^9.0.13",
"@types/http-proxy": "^1.17.7", "@types/http-proxy": "^1.17.7",
"@types/node-fetch": "^3.0.2", "@types/node-fetch": "^3.0.2",

View File

@ -4,7 +4,7 @@ import { IncomingMessage, ServerResponse } from 'http'
import { promises as fsp } from 'fs' import { promises as fsp } from 'fs'
import { loading as loadingTemplate } from '@nuxt/design' import { loading as loadingTemplate } from '@nuxt/design'
import chokidar, { FSWatcher } from 'chokidar' import chokidar, { FSWatcher } from 'chokidar'
import debounce from 'debounce' import debounce from 'p-debounce'
import { promisifyHandle, createApp, Middleware, useBase } from 'h3' import { promisifyHandle, createApp, Middleware, useBase } from 'h3'
import httpProxy from 'http-proxy' import httpProxy from 'http-proxy'
import { listen, Listener, ListenOptions } from 'listhen' import { listen, Listener, ListenOptions } from 'listhen'
@ -104,7 +104,7 @@ export function createDevServer (nitroContext: NitroContext) {
let watcher: FSWatcher let watcher: FSWatcher
function watch () { function watch () {
if (watcher) { return } if (watcher) { return }
const dReload = debounce(() => reload().catch(console.warn), 200, true) const dReload = debounce(() => reload().catch(console.warn), 200, { before: true })
watcher = chokidar.watch([ watcher = chokidar.watch([
resolve(nitroContext.output.serverDir, pattern), resolve(nitroContext.output.serverDir, pattern),
resolve(nitroContext._nuxt.buildDir, 'dist/server', pattern) resolve(nitroContext._nuxt.buildDir, 'dist/server', pattern)

View File

@ -26,14 +26,12 @@
"@nuxt/design": "0.1.3", "@nuxt/design": "0.1.3",
"@nuxt/kit": "3.0.0", "@nuxt/kit": "3.0.0",
"@types/clear": "^0", "@types/clear": "^0",
"@types/debounce-promise": "^3",
"@types/mri": "^1.1.1", "@types/mri": "^1.1.1",
"chokidar": "^3.5.2", "chokidar": "^3.5.2",
"clear": "^0.1.0", "clear": "^0.1.0",
"clipboardy": "^2.3.0", "clipboardy": "^2.3.0",
"colorette": "^2.0.16", "colorette": "^2.0.16",
"consola": "^2.15.3", "consola": "^2.15.3",
"debounce-promise": "^3.1.2",
"deep-object-diff": "^1.1.0", "deep-object-diff": "^1.1.0",
"degit": "^2.8.4", "degit": "^2.8.4",
"destr": "^1.1.0", "destr": "^1.1.0",
@ -42,6 +40,7 @@
"listhen": "^0.2.4", "listhen": "^0.2.4",
"mlly": "^0.2.6", "mlly": "^0.2.6",
"mri": "^1.2.0", "mri": "^1.2.0",
"p-debounce": "^4.0.0",
"pathe": "^0.2.0", "pathe": "^0.2.0",
"scule": "^0.2.1", "scule": "^0.2.1",
"superb": "^4.0.0", "superb": "^4.0.0",

View File

@ -1,6 +1,6 @@
import { resolve, relative } from 'pathe' import { resolve, relative } from 'pathe'
import chokidar from 'chokidar' import chokidar from 'chokidar'
import debounce from 'debounce-promise' import debounce from 'p-debounce'
import type { Nuxt } from '@nuxt/kit' import type { Nuxt } from '@nuxt/kit'
import consola from 'consola' import consola from 'consola'
import { createServer, createLoadingHandler } from '../utils/server' import { createServer, createLoadingHandler } from '../utils/server'

View File

@ -13,7 +13,6 @@
"prepack": "unbuild" "prepack": "unbuild"
}, },
"devDependencies": { "devDependencies": {
"@types/debounce": "^1.2.1",
"unbuild": "latest" "unbuild": "latest"
}, },
"dependencies": { "dependencies": {
@ -22,7 +21,6 @@
"@vitejs/plugin-vue-jsx": "^1.2.0", "@vitejs/plugin-vue-jsx": "^1.2.0",
"chokidar": "^3.5.2", "chokidar": "^3.5.2",
"consola": "^2.15.3", "consola": "^2.15.3",
"debounce": "^1.2.1",
"fs-extra": "^10.0.0", "fs-extra": "^10.0.0",
"magic-string": "^0.25.7", "magic-string": "^0.25.7",
"p-debounce": "^4.0.0", "p-debounce": "^4.0.0",

View File

@ -2635,7 +2635,6 @@ __metadata:
"@rollup/plugin-virtual": ^2.0.3 "@rollup/plugin-virtual": ^2.0.3
"@rollup/plugin-wasm": ^5.1.2 "@rollup/plugin-wasm": ^5.1.2
"@rollup/pluginutils": ^4.1.1 "@rollup/pluginutils": ^4.1.1
"@types/debounce": ^1.2.1
"@types/fs-extra": ^9.0.13 "@types/fs-extra": ^9.0.13
"@types/http-proxy": ^1.17.7 "@types/http-proxy": ^1.17.7
"@types/jsdom": ^16.2.13 "@types/jsdom": ^16.2.13
@ -2647,7 +2646,6 @@ __metadata:
chokidar: ^3.5.2 chokidar: ^3.5.2
connect: ^3.7.0 connect: ^3.7.0
consola: ^2.15.3 consola: ^2.15.3
debounce: ^1.2.1
defu: ^5.0.0 defu: ^5.0.0
destr: ^1.1.0 destr: ^1.1.0
dot-prop: ^6.0.1 dot-prop: ^6.0.1
@ -2795,12 +2793,10 @@ __metadata:
resolution: "@nuxt/vite-builder@workspace:packages/vite" resolution: "@nuxt/vite-builder@workspace:packages/vite"
dependencies: dependencies:
"@nuxt/kit": 3.0.0 "@nuxt/kit": 3.0.0
"@types/debounce": ^1.2.1
"@vitejs/plugin-vue": ^1.9.3 "@vitejs/plugin-vue": ^1.9.3
"@vitejs/plugin-vue-jsx": ^1.2.0 "@vitejs/plugin-vue-jsx": ^1.2.0
chokidar: ^3.5.2 chokidar: ^3.5.2
consola: ^2.15.3 consola: ^2.15.3
debounce: ^1.2.1
fs-extra: ^10.0.0 fs-extra: ^10.0.0
magic-string: ^0.25.7 magic-string: ^0.25.7
p-debounce: ^4.0.0 p-debounce: ^4.0.0
@ -3358,20 +3354,6 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@types/debounce-promise@npm:^3":
version: 3.1.4
resolution: "@types/debounce-promise@npm:3.1.4"
checksum: 8de5ec0eade0483569f01ffb8e5b59be3a295a577893c75abb8b5dcdcbde204ee8029edf874096f7105a4cdb46b0321de57b05ce730aa675ea20318d465fc9d7
languageName: node
linkType: hard
"@types/debounce@npm:^1.2.1":
version: 1.2.1
resolution: "@types/debounce@npm:1.2.1"
checksum: bea6d414acefbee50adfe87cee10f8a855d033e4778567ab03bdc3cb2648b6bf9237ca53f4ee76fe4be75f77f86d4688411499626fe409bc870f53631d24231f
languageName: node
linkType: hard
"@types/eslint-scope@npm:^3.7.0": "@types/eslint-scope@npm:^3.7.0":
version: 3.7.1 version: 3.7.1
resolution: "@types/eslint-scope@npm:3.7.1" resolution: "@types/eslint-scope@npm:3.7.1"
@ -7855,20 +7837,6 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"debounce-promise@npm:^3.1.2":
version: 3.1.2
resolution: "debounce-promise@npm:3.1.2"
checksum: 29bac4524c423cc852319d7455363909ea3d933a3b9e3eb1149d963cffc34c475fe37219d0bafc61af566500b5d663cba579bbad7ee4023bef06f8394ed900ad
languageName: node
linkType: hard
"debounce@npm:^1.2.1":
version: 1.2.1
resolution: "debounce@npm:1.2.1"
checksum: 682a89506d9e54fb109526f4da255c5546102fbb8e3ae75eef3b04effaf5d4853756aee97475cd4650641869794e44f410eeb20ace2b18ea592287ab2038519e
languageName: node
linkType: hard
"debug@npm:2.6.9, debug@npm:^2.2.0, debug@npm:^2.3.3, debug@npm:^2.6.8, debug@npm:^2.6.9": "debug@npm:2.6.9, debug@npm:^2.2.0, debug@npm:^2.3.3, debug@npm:^2.6.8, debug@npm:^2.6.9":
version: 2.6.9 version: 2.6.9
resolution: "debug@npm:2.6.9" resolution: "debug@npm:2.6.9"
@ -13694,14 +13662,12 @@ fsevents@~2.3.2:
"@nuxt/design": 0.1.3 "@nuxt/design": 0.1.3
"@nuxt/kit": 3.0.0 "@nuxt/kit": 3.0.0
"@types/clear": ^0 "@types/clear": ^0
"@types/debounce-promise": ^3
"@types/mri": ^1.1.1 "@types/mri": ^1.1.1
chokidar: ^3.5.2 chokidar: ^3.5.2
clear: ^0.1.0 clear: ^0.1.0
clipboardy: ^2.3.0 clipboardy: ^2.3.0
colorette: ^2.0.16 colorette: ^2.0.16
consola: ^2.15.3 consola: ^2.15.3
debounce-promise: ^3.1.2
deep-object-diff: ^1.1.0 deep-object-diff: ^1.1.0
degit: ^2.8.4 degit: ^2.8.4
destr: ^1.1.0 destr: ^1.1.0
@ -13711,6 +13677,7 @@ fsevents@~2.3.2:
listhen: ^0.2.4 listhen: ^0.2.4
mlly: ^0.2.6 mlly: ^0.2.6
mri: ^1.2.0 mri: ^1.2.0
p-debounce: ^4.0.0
pathe: ^0.2.0 pathe: ^0.2.0
scule: ^0.2.1 scule: ^0.2.1
superb: ^4.0.0 superb: ^4.0.0