From c9459c4b5f9c4f63acb095751e3ed23d39a70559 Mon Sep 17 00:00:00 2001 From: Julien Date: Sat, 4 Jan 2025 16:06:35 +0100 Subject: [PATCH] refactor: use md5 instead of crc32 for version hash computing --- package.json | 1 - src/version_cache.ts | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 3b61771..ad63888 100644 --- a/package.json +++ b/package.json @@ -76,7 +76,6 @@ "dependencies": { "@poppinss/utils": "^6.9.2", "@tuyau/utils": "^0.0.6", - "crc-32": "^1.2.2", "edge-error": "^4.0.1", "html-entities": "^2.5.2", "locate-path": "^7.2.0", diff --git a/src/version_cache.ts b/src/version_cache.ts index 2df6b8c..02f5b93 100644 --- a/src/version_cache.ts +++ b/src/version_cache.ts @@ -7,8 +7,8 @@ * file that was distributed with this source code. */ +import { createHash } from 'node:crypto' import { readFile } from 'node:fs/promises' - import type { AssetsVersion } from './types.js' /** @@ -33,10 +33,10 @@ export class VersionCache { */ async #getManifestHash(): Promise { try { - const crc32 = await import('crc-32') const manifestPath = new URL('public/assets/.vite/manifest.json', this.appRoot) const manifestFile = await readFile(manifestPath, 'utf-8') - this.#cachedVersion = crc32.default.str(manifestFile) + this.#cachedVersion = createHash('md5').update(manifestFile).digest('hex') + return this.#cachedVersion } catch { /**