diff --git a/packages/@vuepress/core/lib/internal-plugins/frontmatterBlock/loader.js b/packages/@vuepress/core/lib/internal-plugins/frontmatterBlock/loader.js index d5a799f53e..bb29becedc 100644 --- a/packages/@vuepress/core/lib/internal-plugins/frontmatterBlock/loader.js +++ b/packages/@vuepress/core/lib/internal-plugins/frontmatterBlock/loader.js @@ -1,7 +1,7 @@ const { parseVueFrontmatter: { parseStrippedFrontmatter }} = require('@vuepress/shared-utils') const { frontmatterEmitter } = require('@vuepress/markdown-loader') const LRU = require('lru-cache') -const cache = LRU({ max: 1000 }) +const cache = new LRU({ max: 1000 }) module.exports = function (source, map) { const isProd = process.env.NODE_ENV === 'production' diff --git a/packages/@vuepress/core/package.json b/packages/@vuepress/core/package.json index fe3628600d..c02f07e12f 100644 --- a/packages/@vuepress/core/package.json +++ b/packages/@vuepress/core/package.json @@ -51,7 +51,7 @@ "koa-mount": "^3.0.0", "koa-range": "^0.3.0", "koa-static": "^4.0.2", - "lru-cache": "^4.1.2", + "lru-cache": "^5.1.1", "mini-css-extract-plugin": "0.4.4", "optimize-css-assets-webpack-plugin": "^4.0.0", "portfinder": "^1.0.13", diff --git a/packages/@vuepress/markdown-loader/index.js b/packages/@vuepress/markdown-loader/index.js index f4fd02ab9b..2043fc9da6 100644 --- a/packages/@vuepress/markdown-loader/index.js +++ b/packages/@vuepress/markdown-loader/index.js @@ -10,8 +10,8 @@ const { fs, path, hash, parseFrontmatter, inferTitle, extractHeaders } = require const LRU = require('lru-cache') const md = require('@vuepress/markdown') -const cache = LRU({ max: 1000 }) -const devCache = LRU({ max: 1000 }) +const cache = new LRU({ max: 1000 }) +const devCache = new LRU({ max: 1000 }) /** * Expose markdown loader. diff --git a/packages/@vuepress/markdown/__tests__/util.js b/packages/@vuepress/markdown/__tests__/util.js index 3920b7df1b..da3b688578 100644 --- a/packages/@vuepress/markdown/__tests__/util.js +++ b/packages/@vuepress/markdown/__tests__/util.js @@ -2,7 +2,7 @@ import fs from 'fs-extra' import LRU from 'lru-cache' import path from 'path' -const cache = LRU({ max: 1000 }) +const cache = new LRU({ max: 1000 }) export function Md () { return require('markdown-it')() diff --git a/packages/@vuepress/shared-utils/src/extractHeaders.ts b/packages/@vuepress/shared-utils/src/extractHeaders.ts index 1efb7d175b..0ae54d23eb 100644 --- a/packages/@vuepress/shared-utils/src/extractHeaders.ts +++ b/packages/@vuepress/shared-utils/src/extractHeaders.ts @@ -10,7 +10,7 @@ import deeplyParseHeaders from './deeplyParseHeaders' * @returns {array} */ -const cache = LRU({ max: 1000 }) +const cache = new LRU({ max: 1000 }) export = function (content: string, include = [], md: any) { const key = content + include.join(',')