Skip to content

Commit

Permalink
fix(node-cache): removed node-cache
Browse files Browse the repository at this point in the history
  • Loading branch information
ThornWalli committed Nov 1, 2024
1 parent 446fd47 commit a3afce2
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 49 deletions.
16 changes: 0 additions & 16 deletions docs/src/guide/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
13 changes: 0 additions & 13 deletions package-lock.json

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

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
3 changes: 1 addition & 2 deletions src/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`,
Expand Down
16 changes: 2 additions & 14 deletions src/tmpl/plugin.tmpl.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -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) {
`;

Expand Down
10 changes: 7 additions & 3 deletions src/utils/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.'
Expand Down

0 comments on commit a3afce2

Please sign in to comment.