Remove unused dependency.

This commit is contained in:
Dillon Kearns 2023-01-08 11:51:38 -08:00
parent fcdc8aca8f
commit d5a6c3c53f
3 changed files with 0 additions and 59 deletions

View File

@ -1,38 +1,6 @@
const path = require("path");
const objectHash = require("object-hash");
const kleur = require("kleur");
/**
* To cache HTTP requests on disk with quick lookup and insertion, we store the hashed request.
* This uses SHA1 hashes. They are uni-directional hashes, which works for this use case. Most importantly,
* they're unique enough and can be expressed in a case-insensitive way so it works on Windows filesystems.
* And they are 40 hex characters, so the length won't be too long no matter what the request payload.
* @param {Object} request
*/
function requestToString(request) {
return objectHash(request);
}
/**
* @param {Object} request
*/
function fullPath(portsHash, request, hasFsAccess) {
const requestWithPortHash =
request.url === "elm-pages-internal://port"
? { portsHash, ...request }
: request;
if (hasFsAccess) {
return path.join(
process.cwd(),
// TODO use parameter or something other than global for this `global.isRunningGenerator` condition
".elm-pages",
"http-response-cache",
requestToString(requestWithPortHash)
);
} else {
return path.join("/", requestToString(requestWithPortHash));
}
}
/** @typedef {{kind: 'cache-response-path', value: string} | {kind: 'response-json', value: JSON}} Response */
/**
@ -47,11 +15,8 @@ function lookupOrPerform(portsFile, mode, rawRequest, hasFsAccess, useCache) {
cachePath: "./.elm-pages/http-cache",
cache: mode === "build" ? "no-cache" : "default",
});
const { fs } = require("./request-cache-fs.js")(hasFsAccess);
return new Promise(async (resolve, reject) => {
const request = toRequest(rawRequest);
const portsHash = (portsFile && portsFile.match(/-([^-]+)\.js$/)[1]) || "";
const responsePath = fullPath(portsHash, request, hasFsAccess);
let portBackendTask = {};
let portBackendTaskImportError = null;
@ -218,15 +183,6 @@ function toRequest(elmRequest) {
body: toBody(elmRequest.body),
};
}
/**
* @param {string} file
*/
function checkFileExists(fs, file) {
return fs.promises
.access(file, fs.constants.F_OK)
.then(() => true)
.catch(() => false);
}
/**
* @param {Body} body
*/

14
package-lock.json generated
View File

@ -27,7 +27,6 @@
"make-fetch-happen": "^11.0.2",
"memfs": "^3.4.7",
"micromatch": "^4.0.5",
"object-hash": "^2.2.0",
"serve-static": "^1.15.0",
"terser": "^5.16.1",
"vite": "^4.0.4",
@ -5092,14 +5091,6 @@
"node": "*"
}
},
"node_modules/object-hash": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/object-hash/-/object-hash-2.2.0.tgz",
"integrity": "sha512-gScRMn0bS5fH+IuwyIFgnh9zBdo4DV+6GhygmWM9HyNJSgS0hScp1f5vjtm7oIIOiT9trXrShAkLFSc2IqKNgw==",
"engines": {
"node": ">= 6"
}
},
"node_modules/object-inspect": {
"version": "1.12.2",
"resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.2.tgz",
@ -11121,11 +11112,6 @@
"integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==",
"dev": true
},
"object-hash": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/object-hash/-/object-hash-2.2.0.tgz",
"integrity": "sha512-gScRMn0bS5fH+IuwyIFgnh9zBdo4DV+6GhygmWM9HyNJSgS0hScp1f5vjtm7oIIOiT9trXrShAkLFSc2IqKNgw=="
},
"object-inspect": {
"version": "1.12.2",
"resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.2.tgz",

View File

@ -42,7 +42,6 @@
"make-fetch-happen": "^11.0.2",
"memfs": "^3.4.7",
"micromatch": "^4.0.5",
"object-hash": "^2.2.0",
"serve-static": "^1.15.0",
"terser": "^5.16.1",
"vite": "^4.0.4",