revert lru-cache to v6.0.0

This commit is contained in:
Leonardo Venturini
2024-06-10 09:09:42 -04:00
parent 1d43c3836f
commit c91daf9d6e
13 changed files with 57 additions and 60 deletions

View File

@@ -2,7 +2,7 @@ const fs = Plugin.fs;
const path = Plugin.path;
const createHash = Npm.require('crypto').createHash;
const assert = Npm.require('assert');
const { LRUCache } = Npm.require('lru-cache');
const LRUCache = Npm.require('lru-cache');
// Base class for CachingCompiler and MultiFileCachingCompiler.
CachingCompilerBase = class CachingCompilerBase {
@@ -252,11 +252,8 @@ CachingCompiler = class CachingCompiler extends CachingCompilerBase {
// Maps from a hashed cache key to a compileResult.
this._cache = new LRUCache({
maxSize: this._cacheSize,
sizeCalculation: (value) => {
const size = this.compileResultSize(value);
return size === 0 ? 1 : size;
},
max: this._cacheSize,
length: (value) => this.compileResultSize(value),
});
}

View File

@@ -24,9 +24,9 @@ extends CachingCompilerBase {
// cacheKeys is an object mapping from absolute import path to hashed
// cacheKey for each file referenced by this file (including itself).
this._cache = new LRUCache({
maxSize: this._cacheSize,
max: this._cacheSize,
// We ignore the size of cacheKeys here.
sizeCalculation: (value) => this.compileResultSize(value.compileResult),
length: (value) => this.compileResultSize(value.compileResult),
});
}

View File

@@ -6,7 +6,7 @@ Package.describe({
});
Npm.depends({
'lru-cache': '10.2.2'
'lru-cache': '6.0.0'
})
Package.onUse(function(api) {

View File

@@ -62,34 +62,34 @@
}
},
"@aws-sdk/client-cognito-identity": {
"version": "3.590.0",
"resolved": "https://registry.npmjs.org/@aws-sdk/client-cognito-identity/-/client-cognito-identity-3.590.0.tgz",
"integrity": "sha512-Nfn23x7yZgp1umB+Avvsw9t8XIFWEqNQcpJ10Q8RcI9bQ0SvR4OcnnVsBA0WFL53FVzVM2FAkjNrCMRaSe6xWw=="
"version": "3.592.0",
"resolved": "https://registry.npmjs.org/@aws-sdk/client-cognito-identity/-/client-cognito-identity-3.592.0.tgz",
"integrity": "sha512-mk3JOBsk5hlrLTZFuoGIhFKFflOdxqMKmOgyUFs5+gBLuH0/lN3wNWJxk+BiY1nHzkxhBND1hDHc5dvZRugBJA=="
},
"@aws-sdk/client-sso": {
"version": "3.590.0",
"resolved": "https://registry.npmjs.org/@aws-sdk/client-sso/-/client-sso-3.590.0.tgz",
"integrity": "sha512-6xbC6oQVJKBRTyXyR3C15ksUsPOyW4p+uCj7dlKYWGJvh4vGTV8KhZKS53oPG8t4f1+OMJWjr5wKuXRoaFsmhQ=="
"version": "3.592.0",
"resolved": "https://registry.npmjs.org/@aws-sdk/client-sso/-/client-sso-3.592.0.tgz",
"integrity": "sha512-w+SuW47jQqvOC7fonyjFjsOh3yjqJ+VpWdVrmrl0E/KryBE7ho/Wn991Buf/EiHHeJikoWgHsAIPkBH29+ntdA=="
},
"@aws-sdk/client-sso-oidc": {
"version": "3.590.0",
"resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.590.0.tgz",
"integrity": "sha512-3yCLPjq6WFfDpdUJKk/gSz4eAPDTjVknXaveMPi2QoVBCshneOnJsV16uNKlpVF1frTHrrDRfKYmbaVh6nFBvQ=="
"version": "3.592.0",
"resolved": "https://registry.npmjs.org/@aws-sdk/client-sso-oidc/-/client-sso-oidc-3.592.0.tgz",
"integrity": "sha512-11Zvm8nm0s/UF3XCjzFRpQU+8FFVW5rcr3BHfnH6xAe5JEoN6bJN/n+wOfnElnjek+90hh+Qc7s141AMrCjiiw=="
},
"@aws-sdk/client-sts": {
"version": "3.590.0",
"resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.590.0.tgz",
"integrity": "sha512-f4R1v1LSn4uLYZ5qj4DyL6gp7PXXzJeJsm2seheiJX+53LSF5L7XSDnQVtX1p9Tevv0hp2YUWUTg6QYwIVSuGg=="
"version": "3.592.0",
"resolved": "https://registry.npmjs.org/@aws-sdk/client-sts/-/client-sts-3.592.0.tgz",
"integrity": "sha512-KUrOdszZfcrlpKr4dpdkGibZ/qq3Lnfu1rjv1U+V1QJQ9OuMo9J3sDWpWV9tigNqY0aGllarWH5cJbz9868W/w=="
},
"@aws-sdk/core": {
"version": "3.588.0",
"resolved": "https://registry.npmjs.org/@aws-sdk/core/-/core-3.588.0.tgz",
"integrity": "sha512-O1c2+9ce46Z+iiid+W3iC1IvPbfIo5ev9CBi54GdNB9SaI8/3+f8MJcux0D6c9toCF0ArMersN/gp8ek57e9uQ=="
"version": "3.592.0",
"resolved": "https://registry.npmjs.org/@aws-sdk/core/-/core-3.592.0.tgz",
"integrity": "sha512-gLPMXR/HXDP+9gXAt58t7gaMTvRts9i6Q7NMISpkGF54wehskl5WGrbdtHJFylrlJ5BQo3XVY6i661o+EuR1wg=="
},
"@aws-sdk/credential-provider-cognito-identity": {
"version": "3.590.0",
"resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-cognito-identity/-/credential-provider-cognito-identity-3.590.0.tgz",
"integrity": "sha512-28vRC0BYaDVWU9AzGBywTRmwiwQfkixfOZGcY6e5J6cRjVoawomvHmC2mJd11SjoDcVLUQF+z4Z9z1ZCr1GcpA=="
"version": "3.592.0",
"resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-cognito-identity/-/credential-provider-cognito-identity-3.592.0.tgz",
"integrity": "sha512-uHiMPCkFhZOhlSfKgVqPhMdruiOuVkLUn07gQqvxHYhFKkEOPV+6BZbPKBwBTXr8TIREztQzCMPswa5pGk2zbQ=="
},
"@aws-sdk/credential-provider-env": {
"version": "3.587.0",
@@ -102,14 +102,14 @@
"integrity": "sha512-Su1SRWVRCuR1e32oxX3C1V4c5hpPN20WYcRfdcr2wXwHqSvys5DrnmuCC+JoEnS/zt3adUJhPliTqpfKgSdMrA=="
},
"@aws-sdk/credential-provider-ini": {
"version": "3.590.0",
"resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-ini/-/credential-provider-ini-3.590.0.tgz",
"integrity": "sha512-Y5cFciAK38VIvRgZeND7HvFNR32thGtQb8Xop6cMn33FC78uwcRIu9Hc9699XTclCZqz4+Xl1WU+dZ+rnFn2AA=="
"version": "3.592.0",
"resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-ini/-/credential-provider-ini-3.592.0.tgz",
"integrity": "sha512-3kG6ngCIOPbLJZZ3RV+NsU7HVK6vX1+1DrPJKj9fVlPYn7IXsk8NAaUT5885yC7+jKizjv0cWLrLKvAJV5gfUA=="
},
"@aws-sdk/credential-provider-node": {
"version": "3.590.0",
"resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-node/-/credential-provider-node-3.590.0.tgz",
"integrity": "sha512-Ky38mNFoXobGrDQ11P3dU1e+q1nRJ7eZl8l15KUpvZCe/hOudbxQi/epQrCazD/gRYV2fTyczdLlZzB5ZZ8DhQ=="
"version": "3.592.0",
"resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-node/-/credential-provider-node-3.592.0.tgz",
"integrity": "sha512-BguihBGTrEjVBQ07hm+ZsO29eNJaxwBwUZMftgGAm2XcMIEClNPfm5hydxu2BmA4ouIJQJ6nG8pNYghEumM+Aw=="
},
"@aws-sdk/credential-provider-process": {
"version": "3.587.0",
@@ -117,9 +117,9 @@
"integrity": "sha512-V4xT3iCqkF8uL6QC4gqBJg/2asd/damswP1h9HCfqTllmPWzImS+8WD3VjgTLw5b0KbTy+ZdUhKc0wDnyzkzxg=="
},
"@aws-sdk/credential-provider-sso": {
"version": "3.590.0",
"resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-sso/-/credential-provider-sso-3.590.0.tgz",
"integrity": "sha512-v+0j/I+je9okfwXsgmLppmwIE+TuMp5WqLz7r7PHz9KjzLyKaKTDvfllFD+8oPpBqnmOWiJ9qTGPkrfhB7a/fQ=="
"version": "3.592.0",
"resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-sso/-/credential-provider-sso-3.592.0.tgz",
"integrity": "sha512-fYFzAdDHKHvhtufPPtrLdSv8lO6GuW3em6n3erM5uFdpGytNpjXvr3XGokIsuXcNkETAY/Xihg+G9ksNE8WJxQ=="
},
"@aws-sdk/credential-provider-web-identity": {
"version": "3.587.0",
@@ -127,9 +127,9 @@
"integrity": "sha512-XqIx/I2PG7kyuw3WjAP9wKlxy8IvFJwB8asOFT1xPFoVfZYKIogjG9oLP5YiRtfvDkWIztHmg5MlVv3HdJDGRw=="
},
"@aws-sdk/credential-providers": {
"version": "3.590.0",
"resolved": "https://registry.npmjs.org/@aws-sdk/credential-providers/-/credential-providers-3.590.0.tgz",
"integrity": "sha512-Z4SHk/GCoM5JEJOH3+xr2I7VvPGdeGPHL1cck/UFIN1Fap1wT3uIsTW92Rhru2AvnhQnAPpDUOHO9/hDJk1MDA=="
"version": "3.592.0",
"resolved": "https://registry.npmjs.org/@aws-sdk/credential-providers/-/credential-providers-3.592.0.tgz",
"integrity": "sha512-fHAt001Aemiy9p8VtLKWiPQ36g1YgiLC1pm31W+WmKxU663dbt2yYTIAyVOB1nQC7HrVCOZEg2FU0TtuZt/wXQ=="
},
"@aws-sdk/middleware-host-header": {
"version": "3.577.0",

View File

@@ -15,7 +15,7 @@ Package.registerBuildPlugin({
npmDependencies: {
"@babel/runtime": "7.23.5",
"source-map": "0.7.4",
"lru-cache": "10.2.2",
"lru-cache": "6.0.0",
"micromatch": "4.0.5",
},
sources: [

View File

@@ -1,6 +1,6 @@
import sourcemap from "source-map";
import { createHash } from "crypto";
import { LRUCache } from "lru-cache";
import LRUCache from "lru-cache";
import { loadPostCss, watchAndHashDeps, usePostCss } from './postcss.js';
import { Log } from 'meteor/logging';

View File

@@ -32,9 +32,9 @@
"integrity": "sha512-/pyBZWSLD2n0dcHE3hq8s8ZvcETHtEuF+3E7XVt0Ig2nvsVQXdghHVcEkIWjy9A0wKfTn97a/PSDYohKIlnP/w=="
},
"@types/node": {
"version": "20.14.0",
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.0.tgz",
"integrity": "sha512-5cHBxFGJx6L4s56Bubp4fglrEpmyJypsqI6RgzMfBHWUJQGWAAi8cWcgetEbZXHYXo9C2Fa4EEds/uSyS4cxmA=="
"version": "20.14.2",
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.2.tgz",
"integrity": "sha512-xyu6WAMVwv6AKFLB+e/7ySZVr/0zLCzOa7rSpq6jNwpqOrUbcACDWC+53d4n2QHOnDou0fbIsg8wZu/sxrnI4Q=="
},
"@types/qs": {
"version": "6.9.15",

View File

@@ -13,7 +13,7 @@ var packageJson = {
promise: "8.1.0",
"@meteorjs/reify": "0.25.2",
"@babel/parser": "7.17.0",
"lru-cache": "10.2.2",
"lru-cache": "6.0.0",
underscore: "1.13.6",
"source-map-support": "https://github.com/meteor/node-source-map-support/tarball/81bce1f99625e62af73338f63afcf2b44c6cfa5e",
"@types/semver": "5.5.0",

View File

@@ -63,7 +63,7 @@ var packageJson = {
// version constraint imposed by optimism/package.json.
optimism: "0.16.1",
"@wry/context": "0.6.0",
'lru-cache': '10.2.2',
'lru-cache': '6.0.0',
"anser": "2.0.1",
'xmlbuilder2': '1.8.1',
"ws": "7.4.5",

View File

@@ -9,7 +9,7 @@ var _ = require('underscore');
var Profile = require('../tool-env/profile').Profile;
import assert from "assert";
import {readAndWatchFileWithHash, sha1, WatchSet,} from '../fs/watch';
import { LRUCache } from 'lru-cache';
import LRUCache from 'lru-cache';
import {sourceMapLength} from '../utils/utils.js';
import {Console} from '../console/console.js';
import ImportScanner from './import-scanner';
@@ -63,10 +63,10 @@ const CACHE_SIZE = process.env.METEOR_LINKER_CACHE_SIZE || 1024*1024*100;
const CACHE_DEBUG = !! process.env.METEOR_TEST_PRINT_LINKER_CACHE_DEBUG;
const LINKER_CACHE_SALT = 26; // Increment this number to force relinking.
const LINKER_CACHE = new LRUCache({
maxSize: CACHE_SIZE,
max: CACHE_SIZE,
// Cache is measured in bytes. We don't care about servePath.
// Key is JSONification of all options plus all hashes.
sizeCalculation (files) {
length (files) {
return files.reduce((soFar, current) => {
return soFar + current.data.length + sourceMapLength(current.sourceMap);
}, 0);

View File

@@ -48,7 +48,7 @@ const { compile: reifyCompile } = require("@meteorjs/reify/lib/compiler");
const { parse: reifyBabelParse } = require("@meteorjs/reify/lib/parsers/babel");
import Resolver, { Resolution } from "./resolver";
import { LRUCache } from 'lru-cache';
import LRUCache from 'lru-cache';
const fakeFileStat = {
isFile() {
@@ -292,8 +292,8 @@ function setImportedStatus(file: File, status: string | boolean) {
// of ImportScanner (which do not persist across builds).
const IMPORT_SCANNER_CACHE = new LRUCache({
maxSize: Math.pow(2, 23),
sizeCalculation(ids: Record<string, ImportInfo>) {
max: Math.pow(2, 23),
length(ids: Record<string, ImportInfo>) {
let total = 40; // size of key
each(ids, (_info, id) => { total += id.length; });
return total;

View File

@@ -1,6 +1,6 @@
import { parse } from '@meteorjs/babel';
import { analyze as analyzeScope } from 'escope';
import { LRUCache } from "lru-cache";
import LRUCache from "lru-cache";
import { Profile } from '../tool-env/profile';
import Visitor from "@meteorjs/reify/lib/visitor.js";
import { findPossibleIndexes } from "@meteorjs/reify/lib/utils.js";
@@ -13,8 +13,8 @@ function isRegExp(value) {
}
var AST_CACHE = new LRUCache({
maxSize: Math.pow(2, 26),
sizeCalculation(ast) {
max: Math.pow(2, 26),
length(ast) {
return ast.loc.end.line;
}
});
@@ -260,8 +260,8 @@ function isPropertyWithName(node, name) {
// It only cares about assignments to variables; an assignment to a field on an
// object (`Foo.Bar = true`) neither causes `Foo` nor `Foo.Bar` to be returned.
const globalsCache = new LRUCache({
maxSize: Math.pow(2, 12),
sizeCalculation(globals) {
max: Math.pow(2, 12),
length(globals) {
let sum = 0;
Object.keys(globals).forEach(name => sum += name.length);
return sum === 0 ? 1 : sum;

View File

@@ -4,7 +4,7 @@ var buildmessage = require('../utils/buildmessage.js');
var watch = require('../fs/watch');
var Profile = require('../tool-env/profile').Profile;
import assert from 'assert';
import { LRUCache } from 'lru-cache';
import LRUCache from 'lru-cache';
import { sourceMapLength } from '../utils/utils.js';
import files from '../fs/files';
import { findAssignedGlobals } from './js-analyze.js';
@@ -16,8 +16,8 @@ const CACHE_SIZE = process.env.METEOR_APP_PRELINK_CACHE_SIZE || 1024*1024*20;
// Cache individual files prelinked
const APP_PRELINK_CACHE = new LRUCache({
maxSize: CACHE_SIZE,
sizeCalculation (prelinked) {
max: CACHE_SIZE,
length (prelinked) {
return prelinked.source.length + sourceMapLength(prelinked.sourceMap);
}
});