From c8f39ad13bfde8734538f25fdeb99750830f0107 Mon Sep 17 00:00:00 2001 From: Frederick Fogerty Date: Thu, 27 Aug 2020 10:23:23 +0200 Subject: [PATCH] fix(gatsby-transform-url): inconsistency between src and srcWebp caused by imgix-core-js bug: https://github.com/imgix/imgix-core-js/issues/158 --- packages/gatsby-transform-url/src/index.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/gatsby-transform-url/src/index.ts b/packages/gatsby-transform-url/src/index.ts index e057ef8b..0dcedf69 100644 --- a/packages/gatsby-transform-url/src/index.ts +++ b/packages/gatsby-transform-url/src/index.ts @@ -51,8 +51,13 @@ function buildImageData( ar: imgixParams.ar != null ? `${imgixParams.ar}:1` : undefined, }; - const src = client.buildURL(path, transformedImgixParams); - const srcset = client.buildSrcSet(path, transformedImgixParams); + // We have to spread parameters because imgix-core-js builders mutate params. GH issue: https://github.com/imgix/imgix-core-js/issues/158 + const src = client.buildURL(path, { + ...transformedImgixParams, + }); + const srcset = client.buildSrcSet(path, { + ...transformedImgixParams, + }); const srcWebp = client.buildURL(path, { ...transformedImgixParams, fm: 'webp',