From 0cb6096019c1e2f7820671c27a17df9e090f0b9d Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Mon, 11 Aug 2025 13:50:01 -0800 Subject: [PATCH] Cache redirected URLs in onLoad --- src/lib/build/esmPlugin.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/lib/build/esmPlugin.ts b/src/lib/build/esmPlugin.ts index 0242291e..dbb1894d 100644 --- a/src/lib/build/esmPlugin.ts +++ b/src/lib/build/esmPlugin.ts @@ -96,6 +96,10 @@ export function esmPlugin(packageLock: PackageLock, target?: string): Plugin { build.onLoad({ filter: /.*/, namespace: "esm" }, async (args) => { const res = await fetch(args.path); + if (res.redirected) { + redirectedURLs.set(args.path, res.url); + } + if (!res.ok) { throw new Error(`Failed to fetch ${args.path}`); }