From 2c639174c400ebb2b74d6a2bc2ac83dba5887785 Mon Sep 17 00:00:00 2001 From: alpavlove Date: Thu, 5 Dec 2024 12:47:36 +0000 Subject: [PATCH] fix: an issue where `addMetadata` calls were stripped in production mode, ensuring consistent metadata availability (e.g., `cacheOutcome`) in both development and production environments --- .changeset/fluffy-starfishes-unite.md | 5 +++++ scripts/babel/transform-debug-target.mjs | 16 ---------------- 2 files changed, 5 insertions(+), 16 deletions(-) create mode 100644 .changeset/fluffy-starfishes-unite.md diff --git a/.changeset/fluffy-starfishes-unite.md b/.changeset/fluffy-starfishes-unite.md new file mode 100644 index 0000000000..ce0bd2fa92 --- /dev/null +++ b/.changeset/fluffy-starfishes-unite.md @@ -0,0 +1,5 @@ +--- +'@urql/core': minor +--- + +Fixes an issue where `addMetadata` calls were stripped in production mode, ensuring consistent metadata availability (e.g., `cacheOutcome`) in both development and production environments diff --git a/scripts/babel/transform-debug-target.mjs b/scripts/babel/transform-debug-target.mjs index f7d5039f8b..0a0e0e3aa4 100644 --- a/scripts/babel/transform-debug-target.mjs +++ b/scripts/babel/transform-debug-target.mjs @@ -4,19 +4,11 @@ const warningDevCheckTemplate = ` process.env.NODE_ENV !== 'production' ? NODE : undefined `.trim(); -const noopTransformTemplate = ` - process.env.NODE_ENV !== 'production' ? NODE : FALLBACK -`.trim(); - const plugin = ({ template, types: t }) => { const wrapWithDevCheck = template.expression(warningDevCheckTemplate, { placeholderPattern: /^NODE$/, }); - const wrapWithNoopTransform = template.expression(noopTransformTemplate, { - placeholderPattern: /^(NODE|FALLBACK)$/, - }); - let name = 'unknownExchange'; return { @@ -47,14 +39,6 @@ const plugin = ({ template, types: t }) => { } path.replaceWith(wrapWithDevCheck({ NODE: path.node })); - } else if (path.node.callee.name === 'addMetadata') { - path.node[visited] = true; - path.replaceWith( - wrapWithNoopTransform({ - NODE: path.node, - FALLBACK: path.node.arguments[0], - }) - ); } }, },