From 21f1797ee8aecdae7a2bfb0f8b06ce88e987dfb8 Mon Sep 17 00:00:00 2001 From: inottn Date: Tue, 20 Aug 2024 20:18:46 +0800 Subject: [PATCH] fix: `assetsInfo` may be undefined (rspack) (#1927) --- src/utils/getFilenameFromUrl.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/utils/getFilenameFromUrl.js b/src/utils/getFilenameFromUrl.js index 2f034060f..0fe40c232 100644 --- a/src/utils/getFilenameFromUrl.js +++ b/src/utils/getFilenameFromUrl.js @@ -123,11 +123,14 @@ function getFilenameFromUrl(context, url, extra = {}) { if (extra.stats.isFile()) { foundFilename = filename; - const assetInfo = assetsInfo.get( - pathname.slice(publicPathObject.pathname.length), - ); + // Rspack does not yet support `assetsInfo`, so we need to check if `assetsInfo` exists here + if (assetsInfo) { + const assetInfo = assetsInfo.get( + pathname.slice(publicPathObject.pathname.length), + ); - extra.immutable = assetInfo ? assetInfo.immutable : false; + extra.immutable = assetInfo ? assetInfo.immutable : false; + } break; } else if (