From 21776e5fc1a57e861be30d8f1093f327945bed22 Mon Sep 17 00:00:00 2001 From: Andrey Yolkin Date: Fri, 24 Nov 2023 17:10:27 +0300 Subject: [PATCH] refactor: migrate to `hookable` package (#24426) --- packages/cli/package.json | 2 +- packages/cli/src/command.js | 2 +- packages/core/package.json | 2 +- packages/core/src/nuxt.js | 6 +++++- packages/core/test/nuxt.test.js | 2 +- yarn.lock | 10 +++++----- 6 files changed, 14 insertions(+), 10 deletions(-) diff --git a/packages/cli/package.json b/packages/cli/package.json index 455b4166b9..373fa78222 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -29,7 +29,7 @@ "exit": "^0.1.2", "fs-extra": "^10.1.0", "globby": "^11.0.4", - "hable": "^3.0.0", + "hookable": "^4.4.1", "lodash": "^4.17.21", "minimist": "^1.2.8", "opener": "1.5.2", diff --git a/packages/cli/src/command.js b/packages/cli/src/command.js index 0e4103d71d..18edc5b3a7 100644 --- a/packages/cli/src/command.js +++ b/packages/cli/src/command.js @@ -2,7 +2,7 @@ import path from 'path' import consola from 'consola' import minimist from 'minimist' -import Hookable from 'hable' +import Hookable from 'hookable' import { name, version } from '../package.json' import { forceExit } from './utils' import { loadNuxtConfig } from './utils/config' diff --git a/packages/core/package.json b/packages/core/package.json index 8971c7a92b..9296707caa 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -16,7 +16,7 @@ "@nuxt/utils": "2.17.2", "consola": "^3.2.3", "fs-extra": "^10.1.0", - "hable": "^3.0.0", + "hookable": "^4.4.1", "hash-sum": "^2.0.0", "lodash": "^4.17.21" }, diff --git a/packages/core/src/nuxt.js b/packages/core/src/nuxt.js index 7016adcc32..cc5ea165f8 100644 --- a/packages/core/src/nuxt.js +++ b/packages/core/src/nuxt.js @@ -1,7 +1,7 @@ import { isPlainObject } from 'lodash' import consola from 'consola' -import Hookable from 'hable' +import Hookable from 'hookable' import { defineAlias } from '@nuxt/utils' import { getNuxtConfig } from '@nuxt/config' @@ -23,6 +23,10 @@ export default class Nuxt extends Hookable { this.resolver = new Resolver(this) this.moduleContainer = new ModuleContainer(this) + // Add legacy methods for backwards compatibility + this.clearHooks = this.removeHooks.bind(this) + this.clearHook = this.removeHook.bind(this) + // Deprecated hooks this.deprecateHooks({ // #3294 - 7514db73b25c23b8c14ebdafbb4e129ac282aabd diff --git a/packages/core/test/nuxt.test.js b/packages/core/test/nuxt.test.js index d73525c97b..b1052e9341 100644 --- a/packages/core/test/nuxt.test.js +++ b/packages/core/test/nuxt.test.js @@ -1,7 +1,7 @@ import { defineAlias } from '@nuxt/utils' import { getNuxtConfig } from '@nuxt/config' import { Server } from '@nuxt/server' -import Hookable from 'hable' +import Hookable from 'hookable' import Nuxt from '../src/nuxt' import ModuleContainer from '../src/module' diff --git a/yarn.lock b/yarn.lock index 9352e2ec3a..c562b75c76 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7588,11 +7588,6 @@ gzip-size@^6.0.0: dependencies: duplexer "^0.1.2" -hable@^3.0.0: - version "3.0.0" - resolved "https://registry.npmjs.org/hable/-/hable-3.0.0.tgz#6de089b2df946635cf8134b9e4859f1b62de255f" - integrity sha512-7+G0/2/COR8pwteYFqHIVYfQpuEiO2HXwJrhCBJVgrNrl9O5eaUoJVDGXUJX+0RpGncNVTuestexjk1afj01wQ== - handlebars@^4.7.7: version "4.7.7" resolved "https://registry.npmjs.org/handlebars/-/handlebars-4.7.7.tgz#9ce33416aad02dbd6c8fafa8240d5d98004945a1" @@ -7770,6 +7765,11 @@ hmac-drbg@^1.0.1: minimalistic-assert "^1.0.0" minimalistic-crypto-utils "^1.0.1" +hookable@^4.4.1: + version "4.4.1" + resolved "https://registry.npmjs.org/hookable/-/hookable-4.4.1.tgz#3d7154ac7e1f6f147e50fef583832f2645b9f04f" + integrity sha512-KWjZM8C7IVT2qne5HTXjM6R6VnRfjfRlf/oCnHd+yFxoHO1DzOl6B9LzV/VqGQK/IrFewq+EG+ePVrE9Tpc3fg== + hosted-git-info@^2.1.4: version "2.8.9" resolved "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.9.tgz#dffc0bf9a21c02209090f2aa69429e1414daf3f9"