From 1fbfdefe7003a585ac555bb65b8cba49a070de96 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Wed, 13 Oct 2021 20:04:12 +0100 Subject: [PATCH] refactor: use `p-debounce` everywhere (#977) --- packages/nitro/package.json | 2 -- packages/nitro/src/server/dev.ts | 4 ++-- packages/nuxi/package.json | 3 +-- packages/nuxi/src/commands/dev.ts | 2 +- packages/vite/package.json | 2 -- yarn.lock | 35 +------------------------------ 6 files changed, 5 insertions(+), 43 deletions(-) diff --git a/packages/nitro/package.json b/packages/nitro/package.json index 89bba38dff..a07ab7e484 100644 --- a/packages/nitro/package.json +++ b/packages/nitro/package.json @@ -34,7 +34,6 @@ "chokidar": "^3.5.2", "connect": "^3.7.0", "consola": "^2.15.3", - "debounce": "^1.2.1", "defu": "^5.0.0", "destr": "^1.1.0", "dot-prop": "^6.0.1", @@ -73,7 +72,6 @@ "vue-server-renderer": "^2.6.14" }, "devDependencies": { - "@types/debounce": "^1.2.1", "@types/fs-extra": "^9.0.13", "@types/http-proxy": "^1.17.7", "@types/node-fetch": "^3.0.2", diff --git a/packages/nitro/src/server/dev.ts b/packages/nitro/src/server/dev.ts index 3beed262d4..0c7cfbd282 100644 --- a/packages/nitro/src/server/dev.ts +++ b/packages/nitro/src/server/dev.ts @@ -4,7 +4,7 @@ import { IncomingMessage, ServerResponse } from 'http' import { promises as fsp } from 'fs' import { loading as loadingTemplate } from '@nuxt/design' import chokidar, { FSWatcher } from 'chokidar' -import debounce from 'debounce' +import debounce from 'p-debounce' import { promisifyHandle, createApp, Middleware, useBase } from 'h3' import httpProxy from 'http-proxy' import { listen, Listener, ListenOptions } from 'listhen' @@ -104,7 +104,7 @@ export function createDevServer (nitroContext: NitroContext) { let watcher: FSWatcher function watch () { 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([ resolve(nitroContext.output.serverDir, pattern), resolve(nitroContext._nuxt.buildDir, 'dist/server', pattern) diff --git a/packages/nuxi/package.json b/packages/nuxi/package.json index e8cb89f153..8c902b4f3c 100644 --- a/packages/nuxi/package.json +++ b/packages/nuxi/package.json @@ -26,14 +26,12 @@ "@nuxt/design": "0.1.3", "@nuxt/kit": "3.0.0", "@types/clear": "^0", - "@types/debounce-promise": "^3", "@types/mri": "^1.1.1", "chokidar": "^3.5.2", "clear": "^0.1.0", "clipboardy": "^2.3.0", "colorette": "^2.0.16", "consola": "^2.15.3", - "debounce-promise": "^3.1.2", "deep-object-diff": "^1.1.0", "degit": "^2.8.4", "destr": "^1.1.0", @@ -42,6 +40,7 @@ "listhen": "^0.2.4", "mlly": "^0.2.6", "mri": "^1.2.0", + "p-debounce": "^4.0.0", "pathe": "^0.2.0", "scule": "^0.2.1", "superb": "^4.0.0", diff --git a/packages/nuxi/src/commands/dev.ts b/packages/nuxi/src/commands/dev.ts index e8a489a061..00819598d0 100644 --- a/packages/nuxi/src/commands/dev.ts +++ b/packages/nuxi/src/commands/dev.ts @@ -1,6 +1,6 @@ import { resolve, relative } from 'pathe' import chokidar from 'chokidar' -import debounce from 'debounce-promise' +import debounce from 'p-debounce' import type { Nuxt } from '@nuxt/kit' import consola from 'consola' import { createServer, createLoadingHandler } from '../utils/server' diff --git a/packages/vite/package.json b/packages/vite/package.json index ea8f22a5c3..3e2e21d853 100644 --- a/packages/vite/package.json +++ b/packages/vite/package.json @@ -13,7 +13,6 @@ "prepack": "unbuild" }, "devDependencies": { - "@types/debounce": "^1.2.1", "unbuild": "latest" }, "dependencies": { @@ -22,7 +21,6 @@ "@vitejs/plugin-vue-jsx": "^1.2.0", "chokidar": "^3.5.2", "consola": "^2.15.3", - "debounce": "^1.2.1", "fs-extra": "^10.0.0", "magic-string": "^0.25.7", "p-debounce": "^4.0.0", diff --git a/yarn.lock b/yarn.lock index 447b9acc76..8773efeb62 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2635,7 +2635,6 @@ __metadata: "@rollup/plugin-virtual": ^2.0.3 "@rollup/plugin-wasm": ^5.1.2 "@rollup/pluginutils": ^4.1.1 - "@types/debounce": ^1.2.1 "@types/fs-extra": ^9.0.13 "@types/http-proxy": ^1.17.7 "@types/jsdom": ^16.2.13 @@ -2647,7 +2646,6 @@ __metadata: chokidar: ^3.5.2 connect: ^3.7.0 consola: ^2.15.3 - debounce: ^1.2.1 defu: ^5.0.0 destr: ^1.1.0 dot-prop: ^6.0.1 @@ -2795,12 +2793,10 @@ __metadata: resolution: "@nuxt/vite-builder@workspace:packages/vite" dependencies: "@nuxt/kit": 3.0.0 - "@types/debounce": ^1.2.1 "@vitejs/plugin-vue": ^1.9.3 "@vitejs/plugin-vue-jsx": ^1.2.0 chokidar: ^3.5.2 consola: ^2.15.3 - debounce: ^1.2.1 fs-extra: ^10.0.0 magic-string: ^0.25.7 p-debounce: ^4.0.0 @@ -3358,20 +3354,6 @@ __metadata: languageName: node 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": version: 3.7.1 resolution: "@types/eslint-scope@npm:3.7.1" @@ -7855,20 +7837,6 @@ __metadata: languageName: node 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": version: 2.6.9 resolution: "debug@npm:2.6.9" @@ -13694,14 +13662,12 @@ fsevents@~2.3.2: "@nuxt/design": 0.1.3 "@nuxt/kit": 3.0.0 "@types/clear": ^0 - "@types/debounce-promise": ^3 "@types/mri": ^1.1.1 chokidar: ^3.5.2 clear: ^0.1.0 clipboardy: ^2.3.0 colorette: ^2.0.16 consola: ^2.15.3 - debounce-promise: ^3.1.2 deep-object-diff: ^1.1.0 degit: ^2.8.4 destr: ^1.1.0 @@ -13711,6 +13677,7 @@ fsevents@~2.3.2: listhen: ^0.2.4 mlly: ^0.2.6 mri: ^1.2.0 + p-debounce: ^4.0.0 pathe: ^0.2.0 scule: ^0.2.1 superb: ^4.0.0