Cache redirected URLs in onLoad

This commit is contained in:
Alex Gleason committed 2025-08-11 13:50:01 -08:00
1 parent 82daf4044b
commit 0cb6096019
1 file changed
+4
+4
View File
@@ -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}`);
}