Open simkuns opened 3 months ago
nuxt-build-cache+0.1.1.patch
diff --git a/node_modules/nuxt-build-cache/dist/module.mjs b/node_modules/nuxt-build-cache/dist/module.mjs
index 189fcc1..2b64ee3 100644
--- a/node_modules/nuxt-build-cache/dist/module.mjs
+++ b/node_modules/nuxt-build-cache/dist/module.mjs
@@ -79,7 +79,7 @@ async function getHashes(nuxt) {
f.data
/* ArrayBuffer */
)
- }));
+ })).sort((a, b) => a.name.localeCompare(b.name));
const sourceFiles = await readFilesRecursive(layer.config?.srcDir, {
shouldIgnore: isIgnored,
// TODO: Validate if works with absolute paths
In my project I have noticed that most of the time there is cache miss (No build cache found).
Upon further investigation I noticed that contents of the
hashes.json
for all builds is the same except file order changes.I checked the implementation of
readFilesRecursive
and it usesglobby
which is based onfast-glob
. https://github.com/sindresorhus/globby?tab=readme-ov-file#globby https://github.com/mrmlnc/fast-glob?tab=readme-ov-file#fast-globAdding
.sort((a, b) => a.name.localeCompare(b.name))
to https://github.com/pi0/nuxt-build-cache/blob/d77afa9f43c5366c074e02be69360d5bbc5c8b3b/src/cache.ts#L39 fixes the issue.