From a3afce206b74d278a785a757b773b2644e0147e4 Mon Sep 17 00:00:00 2001 From: Thorn Walli Date: Fri, 1 Nov 2024 15:27:55 +0100 Subject: [PATCH] fix(node-cache): removed `node-cache` --- docs/src/guide/options.md | 16 ---------------- package-lock.json | 13 ------------- package.json | 1 - src/module.js | 3 +-- src/tmpl/plugin.tmpl.js | 16 ++-------------- src/utils/options.js | 10 +++++++--- 6 files changed, 10 insertions(+), 49 deletions(-) diff --git a/docs/src/guide/options.md b/docs/src/guide/options.md index a41682f842..ad6018b3ed 100644 --- a/docs/src/guide/options.md +++ b/docs/src/guide/options.md @@ -274,22 +274,6 @@ Global option for the [`IntersectionObserver`](https://developer.mozilla.org/en- | `component` | `String` | yes | [`rootMargin`](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver/rootMargin) value for [`BoosterHydrate`](/guide/usage#import-components). | `0%` | | `asset` | `String` | yes | [`rootMargin`](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver/rootMargin) value for all static ressources (`v-font`, `BoosterPicture` & `BoosterImage`). | `0%` | -## `imageSizeCache` - -- Type: `Object` - - Default: `{ stdTTL: 3600, checkperiod: 1800 }` - -The `imageSizeCache` option is used to cache the image sizes of the `BoosterImage` and `BoosterPicture` components. This reduces the number of requests to the server and speeds up the loading process. - -Learn more about the options in the [node-cache documentation](https://www.npmjs.com/package/node-cache#options). - -````js -{ - stdTTL: 3600, - checkperiod: 1800 -} -```` - ## `disableNuxtFontaine` - Type: `Boolean` diff --git a/package-lock.json b/package-lock.json index 6d1382364c..9c8e8c2fb9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,7 +19,6 @@ "htmlparser2": "9.1.0", "image-meta": "0.2.1", "mime-types": "2.1.35", - "node-cache": "5.1.2", "pathe": "1.1.2", "sort-css-media-queries": "2.4.0" }, @@ -16754,18 +16753,6 @@ "devOptional": true, "license": "MIT" }, - "node_modules/node-cache": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/node-cache/-/node-cache-5.1.2.tgz", - "integrity": "sha512-t1QzWwnk4sjLWaQAS8CHgOJ+RAfmHpxFWmc36IWTiWHQfs0w5JDMBS1b1ZxQteo0vVVuWJvIUKHDkkeK7vIGCg==", - "license": "MIT", - "dependencies": { - "clone": "2.x" - }, - "engines": { - "node": ">= 8.0.0" - } - }, "node_modules/node-fetch": { "version": "2.7.0", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", diff --git a/package.json b/package.json index 0345350d74..6c45967837 100644 --- a/package.json +++ b/package.json @@ -61,7 +61,6 @@ "htmlparser2": "9.1.0", "image-meta": "0.2.1", "mime-types": "2.1.35", - "node-cache": "5.1.2", "pathe": "1.1.2", "sort-css-media-queries": "2.4.0" }, diff --git a/src/module.js b/src/module.js index c36750d24a..918f3e204a 100644 --- a/src/module.js +++ b/src/module.js @@ -120,8 +120,7 @@ async function addBuildTemplates(nuxt, options) { targetFormats: options.targetFormats, crossorigin: getCrossorigin(options.crossorigin), supportedBrowserDetector, - loader: options.loader, - imageSizeCache: options.imageSizeCache + loader: options.loader }); }, filename: MODULE_NAME + `/plugin.${mode}.js`, diff --git a/src/tmpl/plugin.tmpl.js b/src/tmpl/plugin.tmpl.js index 0974851551..c6e6915ae7 100644 --- a/src/tmpl/plugin.tmpl.js +++ b/src/tmpl/plugin.tmpl.js @@ -6,12 +6,6 @@ import FontList from '#booster/classes/FontList'; import { useNuxtApp, useBoosterHead, useRequestHeaders, useRequestURL, useRequestFetch } from '#imports'; import './fonts.css';`; - if (options.mode !== 'client') { - code += ` -import NodeCache from 'node-cache'; -`; - } - code += ` export default defineNuxtPlugin({ @@ -54,15 +48,9 @@ export default defineNuxtPlugin({ `; - if (options.mode === 'client') { - code += ` -const dimensionCache = new Map();`; - } else { - code += ` -const dimensionCache = new NodeCache({ useClones: false, ...${JSON.stringify(options.imageSizeCache)} });`; - } - code += ` +const dimensionCache = new Map(); + async function getImageSize (src) { `; diff --git a/src/utils/options.js b/src/utils/options.js index 93c1b3eb88..31655f0720 100644 --- a/src/utils/options.js +++ b/src/utils/options.js @@ -39,13 +39,17 @@ export function getDefaultOptions() { lazyOffset: { component: '0%', asset: '0%' - }, - - imageSizeCache: { stdTTL: 3600, checkperiod: 1800 } + } }; } export function deprecationsNotification(options) { + if ('imageSizeCache' in options) { + logger.warn( + 'Option `imageSizeCache` is deprecated, is no longer required.' + ); + delete options.loader; + } if ('loader' in options) { logger.warn( 'Option `loader` is deprecated, there is no integrated loader anymore.'